# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0
PortGroup           python 1.0

github.setup        tensorflow data-validation 0.28.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
name                py-${github.author}-${github.project}

license             Apache-2
maintainers         nomaintainer

description         A library for exploring and validating machine learning data.

long_description    TensorFlow Data Validation (TFDV) is a library for \
                    exploring and validating machine learning data. It \
                    is designed to be highly scalable and to work well \
                    with TensorFlow and TensorFlow Extended (TFX).

homepage            https://www.tensorflow.org/tfx/data_validation

checksums           rmd160  862287cc1c298441542424bb6eb0e9a6c39e0994 \
                    sha256  fa9367844402e2979dcf954bf39eab2c1bdb6ceb64a618f8105d1cf3afaaae17 \
                    size    755352

python.versions     39

proc python_listify {tcl_list} {
    set python_list {}
    foreach item [lreverse ${tcl_list}] {
        set python_list "'${item}', ${python_list}"
    }
    return ${python_list}
}

if {${name} ne ${subport}} {
    PortGroup       bazel 1.0

    bazel.version   3.7
    
    # Disable bazel configure and build phase configuration
    bazel.build_cmd
    bazel.configure_cmd

    depends_build-append \
                    port:py${python.version}-setuptools

    depends_run-append \
                    port:py${python.version}-absl \
                    port:py${python.version}-apache-beam \
                    port:py${python.version}-avro \
                    port:py${python.version}-joblib \
                    port:py${python.version}-numpy \
                    port:py${python.version}-pandas \
                    port:py${python.version}-protobuf3 \
                    port:py${python.version}-pyarrow \
                    port:py${python.version}-six \
                    path:${python.pkgd}/tensorflow:py${python.version}-tensorflow \
                    port:py${python.version}-tensorflow-metadata \
                    port:py${python.version}-tensorflow-transform \
                    port:py${python.version}-tfx-bsl

    depends_test-append \
                    port:py${python.version}-pytest

    # replace with patch files after this repo is a little more stable
    post-patch {
        reinplace -E "s|\\\[(self\\._bazel_cmd), 'run', '-c', 'opt'] \\+ self\\._additional_build_options|\[\\1, [python_listify [option bazel.build_cmd_opts]] 'build', [python_listify [option bazel.build_opts]]]|" \
                    ${worksrcpath}/setup.py
    }

    bazel.path-append  ${python.prefix}/bin

    build.asroot    yes

    test.run        yes
    test.cmd        py.test-${python.branch}
    test.target
    test.env-append \
                    PYTHONPATH=${worksrcpath}/build/lib

    post-destroot {
        set docdir ${prefix}/share/doc/${subport}
        xinstall -d ${destroot}${docdir}
        xinstall -m 0644 -W ${worksrcpath} LICENSE README.md \
            ${destroot}${docdir}
    }

    livecheck.type  none
}
