Deepmind Tree Bazel Build Portfile Help Request

Steven Smith steve.t.smith at gmail.com
Tue Jul 7 22:58:00 UTC 2020


Whoops, that’s my error. bazel does respect that.

Here’s a working Portfile for py-dm-tree that could be used to simplify the py-tensorflow Portfile in a few spots:

> # -*- 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}-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
>     }
> 
>     build.env-append \
>         JAVA_HOME=${java.home}
> 
>     set bazel_lib ${worksrcpath}/build/lib
>     pre-destroot {
>         xinstall -d ${destroot}${python.pkgd}
>         if {![file isdirectory ${bazel_lib}]} {
>             foreach dir [glob -directory ${worksrcpath}/build -nocomplain -type d lib.*] {
>                 set bazel_lib ${dir}
>                 break
>             }
>         }
>     }
> 
>     destroot {
>         copy ${bazel_lib}/${github.project} ${destroot}${python.pkgd}
>     }
> 
>     pre-test {
>         if {![file isdirectory ${bazel_lib}]} {
>             foreach dir [glob -directory ${worksrcpath}/build -nocomplain -type d lib.*] {
>                 set bazel_lib ${dir}
>                 break
>             }
>             test.env-replace \
>                 PYTHONPATH=${worksrcpath}/build/lib \
>                 PYTHONPATH=${bazel_lib}
>         }
>     }
> 
>     test.run        yes
>     test.cmd        python${python.branch}
>     test.target     ${github.project}/tree_test.py
>     test.env-append PYTHONPATH=${bazel_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
> } else {
>     livecheck.type      pypi
> }






> On Jul 7, 2020, at 6:52 PM, Ryan Schmidt <ryandesign at macports.org> wrote:
> 
> And that's a bug that they could fix by respecting the value of the TMPDIR environment variable.
> 
>> On Jul 7, 2020, at 17:21, Steven Smith wrote:
>> 
>> “The wonderful bazel build system” expects to see ./tmp, not ./.tmp.
>> 
>>> On Jul 7, 2020, at 3:45 PM, Ryan Schmidt <ryandesign at macports.org> wrote:
>>> 
>>> On Jul 7, 2020, at 12:53, Steven Smith wrote:
>>> 
>>>> Fixed the issue: requires creation of TMPDIR
>>>> 
>>>> xinstall -d ${worksrcpath}/tmp
>>> 
>>> MacPorts already sets the TMPDIR environment variable to ${workpath}/.tmp and creates that directory for you. Sounds like this build system needs to be fixed to use $TMPDIR if set.
>>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20200707/dbb8259c/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/dbb8259c/attachment-0001.bin>


More information about the macports-dev mailing list