diff --git a/MODULE.bazel b/MODULE.bazel index 97352b15500c..13f0591b81a9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -109,13 +109,18 @@ pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") [ pip.parse( - hub_name = "drake_mypy", + hub_name = "drake_{hub}".format(hub = hub), python_version = python_version, - requirements_lock = "//setup:python/mypy/requirements.txt", + requirements_lock = "//setup:python/{hub}/requirements.txt".format(hub = hub), ) for python_version in PYTHON_VERSIONS + for hub in [ + "lief", + "mypy", + ] ] +use_repo(pip, "drake_lief") use_repo(pip, "drake_mypy") # Load dependencies which are "public", i.e., made available to downstream diff --git a/setup/python/lief/BUILD.bazel b/setup/python/lief/BUILD.bazel new file mode 100644 index 000000000000..3f8f01639b19 --- /dev/null +++ b/setup/python/lief/BUILD.bazel @@ -0,0 +1,19 @@ +load("@rules_python//python/uv:lock.bzl", "lock") +load("//tools/lint:lint.bzl", "add_lint_tests") + +package(default_visibility = ["//visibility:public"]) + +lock( + name = "lock", + srcs = ["requirements.in"], + out = "requirements.txt", + args = [ + "--upgrade", + "--universal", + # This is our minimum supported version. + # When changing this, see drake/tools/workspace/python/README.md. + "--python-version=3.12", + ], +) + +add_lint_tests() diff --git a/setup/python/lief/requirements.in b/setup/python/lief/requirements.in new file mode 100644 index 000000000000..9a53a55576ee --- /dev/null +++ b/setup/python/lief/requirements.in @@ -0,0 +1 @@ +lief diff --git a/setup/python/lief/requirements.txt b/setup/python/lief/requirements.txt new file mode 100644 index 000000000000..a6d57219a4d4 --- /dev/null +++ b/setup/python/lief/requirements.txt @@ -0,0 +1,81 @@ +# This file was autogenerated by uv via the following command: +# bazel run //setup/python/lief:lock.update +lief==1.0.0 \ + --hash=sha256:0628dea883631d33a84498e79c96e9cffff24ed898f9204d139ab1a51e079478 \ + --hash=sha256:0e4c0934c27bea29752bdac494c2611c676d27d54139c96098f57b22d065deeb \ + --hash=sha256:18b05ce0244be151c58fedbd8b08687ed69713533cab9af23060a73f4441e847 \ + --hash=sha256:1a20cd029b539eb5888882b377617544da012e1bbb2ce575a524c87aaec1102b \ + --hash=sha256:1d782903e43f71bf9ac7224463a30ef74e975914d463a462288437affe8ad3d2 \ + --hash=sha256:23253bbc154ff0dc5253a8929a2a407d11d459694c409d053b93308e623125ff \ + --hash=sha256:23f42c7f4ae2df5492eb3a4ed449a2ae16bec107d9baf987bd618fde1ce53564 \ + --hash=sha256:25ea4a80545eb4d1ffe75f49fceca526ce85130bd263bcd81a0fa66178ab1e7f \ + --hash=sha256:26777c1ec1ac55d3b981cad0fdb61d38de21da4b83810d637a5f4d0190470bf6 \ + --hash=sha256:26f2d29dadd36b850f38f58ecca97eebbd3bf201a1ec13355a31177b44f4cc50 \ + --hash=sha256:2edb6c75944a90e1f9b6fb0e086844b7d00311344149f4007dd4f029476f8fe2 \ + --hash=sha256:2ee72db426d304a37d7bcfe246de3ea1e524ff95104c39f132b88835e6408fa6 \ + --hash=sha256:30c48bb32afdcea98df04cd456e7199e84a629396faf475ca9c8880a4b4c1ce3 \ + --hash=sha256:34d12d846529e5d5157a7feaf54d1bd8b6c2905cb6c46cc1f7c94fa9e9bd1f6a \ + --hash=sha256:37810cadad1fd796b6a681fe7eac084489103a7b2fed306776f9932b38c8d4ac \ + --hash=sha256:3cf41cda0c748687e58295117004d44b499005e396a34f58ac8a514bfc899491 \ + --hash=sha256:3fd100c594bd5451d4c22b67e42d286860869ebb56d98f635c1daa56a11760e1 \ + --hash=sha256:41ff868f5328fc8e5237a9e1f4718590e0ee9180c1422b3e4948b7116ba4517c \ + --hash=sha256:4680aeaa0eb9f21540f37ab5f97820fdf8f08b9c67c42b4435e232ca8cc22a27 \ + --hash=sha256:47c60ba68c3a1f53d872bb004a4e7d2a6f2572372d79a362fa3bd3369f5b8945 \ + --hash=sha256:48e360eea660d019312e377954f327e4fe0918781ee45e9056cd641f50bb6355 \ + --hash=sha256:4d2f1565110abc06070c0f6dcababab64606721fd1401477857558d9575ad663 \ + --hash=sha256:4d49b2fa555163692dbecba147a55847abf641fee3c6d72315db14d084b4a160 \ + --hash=sha256:4e3abaac54cb548b7e8d279f3008e990ee5184eea0fa85524056a9522e36ed54 \ + --hash=sha256:4e6ae6b3bfd4bc4b2f8a805d0dc74b00de9da173d9a4b2bd581d774bb2cdd19d \ + --hash=sha256:514ba1c9c94f0cd09986bfb1db71fd678acd19f826058fe9cefbba0e7b9a5d86 \ + --hash=sha256:580e786d72fc34a0402b0af66ed755e668293946705b8193b766c501f00bc448 \ + --hash=sha256:5881e7698fb9b7ea6398dc86db78c6ae65331d7473c713d5a24318e264048334 \ + --hash=sha256:5aa92fa9501d60c0dbc8fe88d40fa9f19708fad958674eaea1b52cf4217e734d \ + --hash=sha256:5ab0c89879066a36467fb8b85485710e40ea982c90f46de3486d6633b1d43e2f \ + --hash=sha256:5b40bb3591c2db6aea6208b51ef7cb9a9e05c8be5c9437314857d1fda1e61f21 \ + --hash=sha256:5f7f187745c81a81231d9785bed73bae90f495531c5ea40449370e37441b45a2 \ + --hash=sha256:64b48a18be73768f6259e4c0fd0ac65202c2eae54a8629be026296027a42c539 \ + --hash=sha256:66d63183afe5dcf6721b28a59be758636d85751d2567ada602f6ce40b6d9c508 \ + --hash=sha256:6a02dcd93c9dba14d3f007bc3a2a84ebf2706b704a5ab32ea6bf71987d4a9f5b \ + --hash=sha256:6b5d975f45e8830bc12da346d3dd317803d8852f1b61838e655741178e46d300 \ + --hash=sha256:6be55884009b1eea2314c6d918a945c8bc72584928957771956b600fdcecaa19 \ + --hash=sha256:714c96894048f15c8fcecbe6ef4a95416a0f256a20cc6130f8f2398ee717ca06 \ + --hash=sha256:7677a7b8fffd4de096d7ca1db64d1a6c3007e02650ed256fb93b2f3f9ea74097 \ + --hash=sha256:7a9c376fd607a9480777d0928ae37fd48547937b3a54bb5d130512061e5e953c \ + --hash=sha256:7e8fde88db83014bce91269188393c41ec81ddd47f32726a1f8f93a5be6be42e \ + --hash=sha256:7ed5d9511cd7313bb56c95c4f580e8e332615ae0bd45e05b43990f1b563ceef3 \ + --hash=sha256:811b2354f48fa08c49b106eafc9c1b26006371dc24d3d04bfdd9939863df6e6a \ + --hash=sha256:92bf3b06c19a1ebd9e7978de47cc61040752ec452f7906bc3aac8d57abb23a8b \ + --hash=sha256:956ee963e2a2ed318d08fd9fe4ff948906c483db1b88f7a62dac24db76ffa4b0 \ + --hash=sha256:95fb7dc84960068ab881bc681e646cab55f3d736c07bb07e91d5cbc8738885a7 \ + --hash=sha256:96277e45d58de45a33249079dac43e50db1c96da162fbe1ad02fbaa82e3bd06f \ + --hash=sha256:980aeaff59734b48927b3f9a2915c7d834c16d75d9a36a581e4f0dbd082481a8 \ + --hash=sha256:9b5be5f2c08a9fbcf3f37f19aa297fb567ec36e939c24ecbe6d45c4a7b3a981b \ + --hash=sha256:9ef6ed0bd319ace01168c4fe5fcf09dbf2245e339f249fad80a2bcebb0439d3d \ + --hash=sha256:a4d1c2e764ab609fbc81d140b4949039dc728e83e060a68437b3eb0350121a29 \ + --hash=sha256:a9b7bae94a3a160af9b52f15265e55a59a1f3bb305ae9280cfe9ce84cf2c5d0e \ + --hash=sha256:a9e4b9e165bde0163624e159c8c7a096e3d6f671371c70d008baac7ac1f04f0d \ + --hash=sha256:ae13bc7797c779a0528c5c4339afca38669860d681f958cc04a9b2e979cdc783 \ + --hash=sha256:b0ba45425a9963eec324002169881f3bfe23b34aab20d90e2370f1550a80b78b \ + --hash=sha256:b14131d013439d2562d0da09b3c316c7df9e3be25c4a4553a0b324be84785f74 \ + --hash=sha256:b2d9a1c08ce23112ee1141d9c3e799d03695923c9e383c90edd0b0856b36483d \ + --hash=sha256:b3f173de0e49ad89fc4ea1e74508da3220814a44728060b494d85b8998726760 \ + --hash=sha256:b5f954b86f6c99437a461ed794bbc2d5e003e6a24e462b49f4978bce228b3801 \ + --hash=sha256:bac71c133a9412006a07010eefa6438032db8641aedcc8f6ace8fe845fb97067 \ + --hash=sha256:c68c3c19eb75acbca43970fd68a6ccd5fb8795582d31457dcfda744307b54c00 \ + --hash=sha256:ca7774b0d88f4528a1c153d7a9d2798800d6389847b966861fad9f2edb17a593 \ + --hash=sha256:ca999ccd12aba1c09d4d1337624c1fbc3a4084c1714f12a5be8bb9d1484f0d42 \ + --hash=sha256:caad33b4fe1eebf8d18acac3a8e2bbfc10f89706f7555e459e6d2588eb8f80fd \ + --hash=sha256:cc8838a75f93ee9dbd784e6da7ee527d11d16a83de18f8c975344231429da8f8 \ + --hash=sha256:cd211a2f11afba7330bc7a51e494a658e8695711912ea00e54efad5cf1cf5afe \ + --hash=sha256:cd7512a23b20c7c47a11bc27925e8c324c062a393e23716d7cee866c4d92db1f \ + --hash=sha256:d552235f6c7b999b1837946b61cc64537501fac4fda1663c2cb76482b27b609f \ + --hash=sha256:e317252e743d7f0020598b9120ecc81ba1c569c68d30d50d99dbd1992036d7a4 \ + --hash=sha256:e9037bda164285b2a59ee3910dfb70e775b2e3ba793edc565725e0bf926b09e9 \ + --hash=sha256:ea1220b0b68a9b2cd6d1b3f05276c877d136f5b39e3a01d3433df70a92803071 \ + --hash=sha256:ecd440475e677c6834af996d34a2babbad1af6a3addaaa3822fd021972c41311 \ + --hash=sha256:f12816bb3d4781fdc98db4df312a8da744c5a93f587fa4919124fcb9b277d510 \ + --hash=sha256:f58e26e2e4d110cd6a42d86ab497cd4bedc47d72690fae557023ac536d85edcc \ + --hash=sha256:f6c2007bf96704cedc5cee8ae303ba7008840b9a2214ca9f4f43a6faa703834f \ + --hash=sha256:fbaf64c338086da0a5d67b0e440b7010f2fd4b1d6edc68db303693759320ebfb \ + --hash=sha256:fcaf9a28f004bc5f49637dd1a5cdfb8f937feb58febb5f70ebec29c0c1c3584c + # via -r setup/python/lief/requirements.in diff --git a/setup/python/pdm.lock b/setup/python/pdm.lock index 0ef678bd1f91..efb547910e5f 100644 --- a/setup/python/pdm.lock +++ b/setup/python/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "test", "wheel"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:4f54f1d71bb6865744cab2e41975d6605bae54af65b5426191cd355059000557" +content_hash = "sha256:507305e2457404a91a1870ff6ea848bdac74f181850a3df298bc9850b170aa7c" [[metadata.targets]] requires_python = ">=3.12" @@ -2418,21 +2418,6 @@ files = [ {file = "werkzeug-3.1.8.tar.gz", hash = "sha256:9bad61a4268dac112f1c5cd4630a56ede601b6ed420300677a869083d70a4c44"}, ] -[[package]] -name = "wheel" -version = "0.47.0" -requires_python = ">=3.9" -summary = "Command line tool for manipulating wheel files" -groups = ["wheel"] -marker = "sys_platform == \"darwin\"" -dependencies = [ - "packaging>=24.0", -] -files = [ - {file = "wheel-0.47.0-py3-none-any.whl", hash = "sha256:212281cab4dff978f6cedd499cd893e1f620791ca6ff7107cf270781e587eced"}, - {file = "wheel-0.47.0.tar.gz", hash = "sha256:cc72bd1009ba0cf63922e28f94d9d83b920aa2bb28f798a31d0691b02fa3c9b3"}, -] - [[package]] name = "widgetsnbextension" version = "4.0.15" diff --git a/setup/python/pyproject.toml b/setup/python/pyproject.toml index b1ce6968e09b..ce92ec448ef0 100644 --- a/setup/python/pyproject.toml +++ b/setup/python/pyproject.toml @@ -37,7 +37,6 @@ wheel = [ "auditwheel; sys_platform == 'linux'", "build", "delocate; sys_platform == 'darwin'", - "wheel; sys_platform == 'darwin'", ] [tool.pdm] diff --git a/tools/wheel/image/build-drake.sh b/tools/wheel/image/build-drake.sh index 0534e52e8eb3..9782aa688546 100755 --- a/tools/wheel/image/build-drake.sh +++ b/tools/wheel/image/build-drake.sh @@ -19,7 +19,7 @@ cat > /tmp/drake-wheel-build/drake-build/drake.bazelrc << EOF build --disk_cache=/var/cache/bazel/disk_cache build --repository_cache=/var/cache/bazel/repository_cache build --repo_env=DRAKE_WHEEL=1 -# Enable MOSEK lazy loading. Right now this is only done for Linux builds. +# Enable MOSEK lazy loading. build --@drake//solvers:mosek_lazy_load=True EOF diff --git a/tools/wheel/image/build-wheel.sh b/tools/wheel/image/build-wheel.sh index 6d63a981f0f6..6bdff13a6b4a 100755 --- a/tools/wheel/image/build-wheel.sh +++ b/tools/wheel/image/build-wheel.sh @@ -131,42 +131,6 @@ python -m build --wheel if [[ "$(uname)" == "Darwin" ]]; then delocate-wheel -w wheelhouse -v dist/drake*.whl - - # Remove libmosek from wheels. - if [[ -n "${MOSEK_ENABLED}" ]]; then - for w in wheelhouse/drake*.whl; do - mkdir fixup-wheel - wheel unpack --dest fixup-wheel "$w" - - rm fixup-wheel/drake-*/pydrake/lib/libmosek* - rm fixup-wheel/drake-*/pydrake/lib/libtbb* - rm fixup-wheel/drake-*/pydrake/doc/mosek/mosek-eula.pdf - rm fixup-wheel/drake-*/pydrake/doc/mosek/LICENSE.third_party - - change_lpath \ - --old='@loader_path/libtbb' \ - --old='@loader_path/libmosek' \ - --new='@loader_path/../../mosek/libtbb' \ - --new='@loader_path/../../mosek/libmosek' \ - fixup-wheel/drake-*/pydrake/lib/*.so - change_lpath \ - --old='@loader_path/lib/libtbb' \ - --old='@loader_path/lib/libmosek' \ - --new='@loader_path/../mosek/libtbb' \ - --new='@loader_path/../mosek/libmosek' \ - fixup-wheel/drake-*/pydrake/*.so - change_lpath \ - --old='@loader_path/../lib/libtbb' \ - --old='@loader_path/../lib/libmosek' \ - --new='@loader_path/../../mosek/libtbb' \ - --new='@loader_path/../../mosek/libmosek' \ - fixup-wheel/drake-*/pydrake/*/*.so - - rm "$w" - wheel pack --dest wheelhouse fixup-wheel/drake-*/ - rm -rf fixup-wheel - done - fi else GLIBC_VERSION=$(ldd --version | sed -n '1{s/.* //;s/[.]/_/p}') diff --git a/tools/wheel/macos/build-wheel.sh b/tools/wheel/macos/build-wheel.sh index 8b6e3466d6d0..230a7ff9f684 100755 --- a/tools/wheel/macos/build-wheel.sh +++ b/tools/wheel/macos/build-wheel.sh @@ -46,6 +46,8 @@ cat > "$build_root/drake.bazelrc" << EOF build --disk_cache=$HOME/.cache/drake-wheel-build/bazel/disk_cache build --repository_cache=$HOME/.cache/drake-wheel-build/bazel/repository_cache build --repo_env=DRAKE_WHEEL=1 +# Enable MOSEK lazy loading. +build --@drake//solvers:mosek_lazy_load=True # See tools/wheel/wheel_builder/macos.py for more on this env variable. build --macos_minimum_os="${MACOSX_DEPLOYMENT_TARGET}" EOF @@ -56,9 +58,7 @@ EOF # for other mentions of MOSEK version bounds and fix those as well. WITH_MOSEK=ON PYTHON_MINOR=$($python_executable -c "import sys; print(sys.version_info.minor)") -if [[ ${PYTHON_MINOR} -ge 15 ]]; then - WITH_MOSEK=OFF -fi +[ ${PYTHON_MINOR} -ge 15 ] && WITH_MOSEK=OFF # Install Drake. # N.B. When you change anything here, also fix wheel/image/build-drake.sh. diff --git a/tools/workspace/implib_so_internal/package.BUILD.bazel b/tools/workspace/implib_so_internal/package.BUILD.bazel index f1caa6698aae..aa82b8080bae 100644 --- a/tools/workspace/implib_so_internal/package.BUILD.bazel +++ b/tools/workspace/implib_so_internal/package.BUILD.bazel @@ -1,6 +1,7 @@ # -*- bazel -*- load("@drake//tools/skylark:py.bzl", "py_binary") +load("@drake_lief//:requirements.bzl", lief_requirement = "requirement") py_binary( name = "gen", @@ -13,6 +14,9 @@ py_binary( python_version = "PY3", srcs_version = "PY3", visibility = ["//visibility:public"], + deps = [ + lief_requirement("lief"), + ], ) exports_files(["drake_repository_metadata.json"]) diff --git a/tools/workspace/implib_so_internal/repository.bzl b/tools/workspace/implib_so_internal/repository.bzl index 84007dffdd58..f966b9923cfc 100644 --- a/tools/workspace/implib_so_internal/repository.bzl +++ b/tools/workspace/implib_so_internal/repository.bzl @@ -5,10 +5,10 @@ def implib_so_internal_repository( mirrors = None): github_archive( name = name, - repository = "yugr/Implib.so", + repository = "TaylorSasser/Implib.so", upgrade_type = "commit", - commit = "30e547b2e8d608f7cd69bc8ec88d047034a40e35", - sha256 = "0f5e111ce0648215a288c273639a045bde1f1b40139fbd85d06fd25e03af13a2", # noqa + commit = "ead05abb7d1e70d2a412a463208ddbe881037e37", + sha256 = "bef5299700faab5454dc72dd1f71f779330c8bca149a3e1fa7c40d4c159bca9b", # noqa build_file = ":package.BUILD.bazel", mirrors = mirrors, ) diff --git a/tools/workspace/mosek/gen_implib.bzl b/tools/workspace/mosek/gen_implib.bzl new file mode 100644 index 000000000000..638ef37ddd2a --- /dev/null +++ b/tools/workspace/mosek/gen_implib.bzl @@ -0,0 +1,36 @@ +_PY_CC_TOOLCHAIN_TYPE = "@rules_python//python/cc:toolchain_type" + +def _impl(ctx): + args = ctx.actions.args() + args.add("--dlopen-callback", ctx.attr.dlopen_callback) + args.add("--outdir", ctx.outputs.outs[0].dirname) + args.add(ctx.file.src.path) + + py_toolchain = ctx.toolchains[_PY_CC_TOOLCHAIN_TYPE] + + ctx.actions.run( + mnemonic = "GenImplib", + executable = ctx.executable.tool, + arguments = [args], + inputs = [ctx.file.src], + outputs = ctx.outputs.outs, + ) + + return [DefaultInfo( + files = depset(ctx.outputs.outs), + )] + +gen_implib = rule( + implementation = _impl, + attrs = { + "src": attr.label(allow_single_file = True, mandatory = True), + "tool": attr.label( + mandatory = True, + executable = True, + cfg = "target", + ), + "dlopen_callback": attr.string(mandatory = True), + "outs": attr.output_list(mandatory = True), + }, + toolchains = ["@rules_python//python/cc:toolchain_type"], +) diff --git a/tools/workspace/mosek/package.BUILD.bazel b/tools/workspace/mosek/package.BUILD.bazel index ff9f0eb51f92..2d6b2cb9dbde 100644 --- a/tools/workspace/mosek/package.BUILD.bazel +++ b/tools/workspace/mosek/package.BUILD.bazel @@ -4,6 +4,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") load("@drake//tools/install:install.bzl", "install", "install_files") load("@drake//tools/skylark:cc.bzl", "cc_import", "cc_library") +load("@drake//tools/workspace/mosek:gen_implib.bzl", "gen_implib") package(default_visibility = ["//visibility:private"]) @@ -89,12 +90,12 @@ _IMPLIB_SRCS = [ "{}.init.c".format(_MOSEK_SO_NAME), ] -genrule( +gen_implib( name = "_gen_implib", - srcs = [_MOSEK_MAJMIN_GLOB[0]], + src = _MOSEK_MAJMIN_GLOB[0], outs = _IMPLIB_SRCS, - cmd = "$(execpath @implib_so_internal//:gen) --dlopen-callback=drake_dlopen_mosek --outdir=$(RULEDIR) $<", - tools = ["@implib_so_internal//:gen"], + dlopen_callback = "drake_dlopen_mosek", + tool = "@implib_so_internal//:gen", ) cc_library( diff --git a/tools/workspace/python/venv_upgrade b/tools/workspace/python/venv_upgrade index fc1f442dff38..a1cb360361a2 100755 --- a/tools/workspace/python/venv_upgrade +++ b/tools/workspace/python/venv_upgrade @@ -5,8 +5,8 @@ # - Users can make edits to drake/setup/python/pyproject.toml, and then # run this script to compile it to drake/setup/python/pdm.lock. # -# - Users can make edits to drake/setup/python/mypy/requirements.in, and then -# run this script to compile it to drake/setup/python/mypy/requirements.txt. +# - Users can make edits to drake/setup/python/{hub}/requirements.in, and then +# run this script to compile it to drake/setup/python/{hub}/requirements.txt. # # The --reuse option may be given to apply changes to pyproject.toml while # attempting to preserve existing version pins. @@ -123,10 +123,13 @@ done # Check for changes to the pdm lock file. files_to_commit+=( "$(git diff --name-only HEAD -- "${lockfile}")" ) -# Upgrade the mypy lock file. -readonly mypy_requirements="./setup/python/mypy/requirements.txt" -bazel run //setup/python/mypy:lock.update -files_to_commit+=( "$(git diff --name-only HEAD -- "${mypy_requirements}")" ) +# Upgrade the uv-managed lockfiles. +readonly uv_hubs=("lief" "mypy") +for hub in "${uv_hubs[@]}"; do + hub_requirements="./setup/python/${hub}/requirements.txt" + bazel run //setup/python/${hub}:lock.update + files_to_commit+=( "$(git diff --name-only HEAD -- "${hub_requirements}")" ) +done # If committing, do the commit. if [ -n "${commit}" ]; then