Deepmind Tree Bazel Build Portfile Help Request

Steven Smith steve.t.smith at gmail.com
Tue Jul 7 19:15:03 UTC 2020


New issue `port destroot` tries to build with bazel again, and this breaks because of permissions issues.

Is there a simple way to just copy the stuff it already built into destroot?

I’ve tried the standard destroot commands from the python port group and the pip commands used in py-tensorflow. Both cause a rerun of bazel (ugh) and breakage.

Also, I’m not sure what’s causing this python import breakage of the bazel build:

> $ cd /opt/local/ports/python/py-dm-tree/work/tree-0.1.6.20200602/build/lib.macosx-10.15-x86_64-3.7/
> $ ls tree/
> __init__.py                  tree_benchmark.py
> _tree.cpython-37m-darwin.so  tree_test.py
> $ python -c 'import tree'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "tree/__init__.py", line 48, in <module>
>     from tree import _tree  # pylint: disable=g-import-not-at-top
> ImportError: cannot import name _tree



Latest draft Portfile:

> # -*- 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           java 1.0
> PortGroup           python 1.0
> 
> github.setup        deepmind tree 63e7c35242369cd307e9cb3407c8ab608b226a22
> # no official release; version from __init__.py plus github commit date
> version             0.1.6.20200602
> name                py-dm-${github.project}
> revision 0
> 
> platforms           darwin
> license             Apache-2
> maintainers         nomaintainer
> 
> description         Deepmind tree is a library for working with nested\
>                     data structures.
> long_description    ${description} In a way, tree generalizes the builtin\
>                     map function which only supports flat sequences, and\
>                     allows to apply a function to each "leaf" preserving\
>                     the overall structure.
> 
> homepage            https://github.com/deepmind/tree
> distname            ${github.project}-${version}
> 
> checksums           rmd160  f355b4b190be6f5d56ffd0f4b3ad0b031223ccb8 \
>                     sha256  953229df22300f490690e2dedf6dfcd73c68422d12efd9e18cb8a775eaf1e4c3 \
>                     size    35259
> 
> python.versions     37 38
> 
> # Required java version
> java.version        11+
> # JDK port to install if required java not found
> java.fallback       openjdk14
> # JDK only needed at build time, but java PG sets lib dependency so
> # declare no conflict to allow redistribution of binaries.
> license_noconflict  ${java.fallback}
> 
> 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}} {
>     depends_build-append \
>                     port:bazel \
>                     port:py${python.version}-setuptools
> 
>     depends_run-append \
>                     port:py${python.version}-six \
> 
>     depends_test-append \
>                     port:py${python.version}-absl \
>                     port:py${python.version}-attrs \
>                     port:py${python.version}-numpy \
>                     port:py${python.version}-pytest \
>                     port:py${python.version}-wrapt
> 
>     # Limit the number of parallel jobs to the number of physical, not logical, cpus.
>     # First current setting to ensure we would be reducing the current setting.
>     set physicalcpus [sysctl hw.physicalcpu]
>     if { ${build.jobs} > ${physicalcpus} } {
>         build.jobs ${physicalcpus}
>     }
> 
>     # Build using the wonderful bazel build system ...
>     set bazel_output_user_root ${workpath}
>     set bazel_cmd "bazel --max_idle_secs=15 --output_user_root=${bazel_output_user_root}"
>     set bazel_build_opts "--subcommands --compilation_mode=opt --verbose_failures"
>     # Limit bazel resource utilisation
>     set bazel_build_opts "${bazel_build_opts} --jobs ${build.jobs} --local_ram_resources=HOST_RAM*0.75 --local_cpu_resources=HOST_CPUS*.75"
>     # Explicitly pass SDK https://github.com/bazelbuild/rules_go/issues/1554
>     # Check versioned SDK actually exists... https://trac.macports.org/ticket/60317
>     if {[string first ${configure.sdk_version} ${configure.sdkroot}] != -1} {
>         set bazel_build_opts "${bazel_build_opts} --macos_sdk_version=${configure.sdk_version}"
>     } else {
>         ui_warn "configure.sdkroot='${configure.sdkroot}' does not match configure.sdk_version='${configure.sdk_version}'"
>     }
>     # hack to try and transfer MP c, c++ and ld options to bazel...
>     foreach opt [list {*}${configure.cflags} ] {
>         set bazel_build_opts "${bazel_build_opts} --conlyopt \"${opt}\""
>     }
>     foreach opt [list {*}${configure.cxxflags} ] {
>         set bazel_build_opts "${bazel_build_opts} --cxxopt \"${opt}\""
>     }
>     foreach opt [list {*}${configure.ldflags} ] {
>         set bazel_build_opts "${bazel_build_opts} --linkopt \"${opt}\""
>     }
>     ui_debug "Bazel build command : ${bazel_cmd}"
>     ui_debug "Bazel build options : ${bazel_build_opts}"
> 
>     # diff -NaurdwB ./dm-tree-orig/setup.py ./dm-tree-new/setup.py | sed -E -e 's/\.\/dm-tree-(orig|new)*\/(setup\.py)(\.[[:alnum:]]+)*/\.\/setup.py/' > ./setup.py.patch
>     patchfiles      setup.py.patch
> 
>     post-patch {
>         reinplace \
>             "s|@BAZEL_CMD@|[python_listify ${bazel_cmd}]|g" \
>             ${worksrcpath}/setup.py
>         reinplace \
>             "s|@BAZEL_BUILD_OPTS@|[python_listify ${bazel_build_opts}]|g" \
>             ${worksrcpath}/setup.py
>         xinstall -d ${bazel_output_user_root}/tmp
>     }
> 
>     build.env-append \
>         TMPDIR=${workpath}/tmp \
>         JAVA_HOME=${java.home}
> 
>     set bazel_lib ${worksrcpath}/build/lib
>     post-build {
>         if {![file isdirectory ${bazel_lib}]} {
>             foreach dir [glob -directory ${worksrcpath}/build -nocomplain -type d lib.*] {
>                 set bazel_lib ${dir}
>                 break
>             }
>         }
>         test.env-append PYTHONPATH=${bazel_lib}
>     }
>     
>     destroot.cmd  pip-${python.branch}
>     destroot.args           \
>         --ignore-installed  \
>         --no-cache-dir      \
>         --no-dependencies   \
>         --root ${destroot}  \
>         ${worksrcpath}
>     destroot.post_args
> 
>     test.run        yes
>     test.cmd        py.test-${python.branch}
>     test.target
>     test.env-append "PATH=$env(PATH):${workpath}/bin"
> 
>     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
> } else {
>     livecheck.type      pypi
> }


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20200707/624f5e3c/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3898 bytes
Desc: not available
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20200707/624f5e3c/attachment-0001.bin>


More information about the macports-dev mailing list