fix(pip): allow for different extras for different target platforms #3385
Merged
aignas merged 13 commits intobazel-contrib:mainfrom Nov 10, 2025
Merged
fix(pip): allow for different extras for different target platforms #3385aignas merged 13 commits intobazel-contrib:mainfrom
aignas merged 13 commits intobazel-contrib:mainfrom
Conversation
aignas
commented
Nov 1, 2025
Collaborator
Author
|
@hartikainen, could you please check if this PR fixes the issue? |
aignas
commented
Nov 1, 2025
| ), | ||
| ], | ||
| "pypi_312_torch_cp312_cp312_win_amd64_3a570e5c": [ | ||
| "pypi_312_torch_cp312_cp312_win_amd64_3a570e5c_windows_x86_64": [ |
Collaborator
Author
There was a problem hiding this comment.
This is not ideal that we are adding extra suffixes here, but I would need to refactor the code a lot to do various book keeping otherwise. TBH, we could potentially just use the target platform here instead of the whl specification or choose the shorter of the 2 variants:
<prefix>_<sanitized whl_name><prefix>_<distro_name>_<suffixes>
Contributor
|
My initial tests with these changes are promising. Using my example in main...hartikainen:rules_python:test/multi-platform-python, rebased off of From 4b22c63, without changes from this PR (failure): Details$ cd ./examples/bzlmod/multi-platform
$ RULES_PYTHON_ENABLE_PIPSTAR=1 bazel run //:main
ERROR: /private/var/tmp/_bazel_user/9567799826d8cc6628021154b048c90b/external/rules_python+/python/private/pypi/extension.bzl:266:21: Traceback (most recent call last):
File "/private/var/tmp/_bazel_user/9567799826d8cc6628021154b048c90b/external/rules_python+/python/private/pypi/extension.bzl", line 625, column 25, in _pip_impl
mods = parse_modules(module_ctx, enable_pipstar = rp_config.enable_pipstar)
File "/private/var/tmp/_bazel_user/9567799826d8cc6628021154b048c90b/external/rules_python+/python/private/pypi/extension.bzl", line 501, column 36, in parse_modules
out = _create_whl_repos(
File "/private/var/tmp/_bazel_user/9567799826d8cc6628021154b048c90b/external/rules_python+/python/private/pypi/extension.bzl", line 266, column 21, in _create_whl_repos
fail("attempting to create a duplicate library {} for {}".format(
Error in fail: attempting to create a duplicate library pypi_312_jax_py3_none_any_62833036 for jax
ERROR: Analysis of target '//:main' failed; build aborted: error evaluating module extension @@rules_python+//python/extensions:pip.bzl%pip
INFO: Elapsed time: 1.033s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
FAILED:
Fetching repository @@rules_python++python+python_3_12_aarch64-apple-darwin; starting
Fetching repository @@rules_cc++cc_configure_extension+local_config_cc; starting
Fetching module extension @@rules_python+//python/extensions:pip.bzl%pip; Fetch package lists from PyPI indexFrom db4c5ef, with changes from this PR (success): Details$ cd ./examples/bzlmod/multi-platform
$ RULES_PYTHON_ENABLE_PIPSTAR=1 bazel run //:main
INFO: Analyzed target //:main (134 packages loaded, 9869 targets configured).
INFO: Found 1 target...
Target //:main up-to-date:
bazel-bin/main
INFO: Elapsed time: 2.421s, Critical Path: 0.03s
INFO: 1 process: 5545 action cache hit, 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/main
args=Args()
INFO:2025-11-01 13:24:15,877:jax._src.xla_bridge:830: Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: dlopen(libtpu.so, 0x0001): tried: 'libtpu.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibtpu.so' (no such file), '/usr/lib/libtpu.so' (no such file, not in dyld cache), 'libtpu.so' (no such file)
I 13:24:15 [xla_bridge.py:830]: Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: dlopen(libtpu.so, 0x0001): tried: 'libtpu.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibtpu.so' (no such file), '/usr/lib/libtpu.so' (no such file, not in dyld cache), 'libtpu.so' (no such file)
I 13:24:15 [xla_bridge.py:830]: Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: dlopen(libtpu.so, 0x0001): tried: 'libtpu.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibtpu.so' (no such file), '/usr/lib/libtpu.so' (no such file, not in dyld cache), 'libtpu.so' (no such file)
(x, x.device)=(Array([1, 2, 3], dtype=int32), CpuDevice(id=0))
I 13:24:15 [io.py:152]: Using JAX default device: TFRT_CPU_0.
I 13:24:15 [io.py:152]: Using JAX default device: TFRT_CPU_0.
I 13:24:15 [io.py:39]: No CUDA GPU devices found in jax.devices("cuda").
I 13:24:15 [io.py:39]: No CUDA GPU devices found in jax.devices("cuda").
I 13:24:15 [io.py:152]: Using JAX default device: TFRT_CPU_0.
I 13:24:15 [io.py:152]: Using JAX default device: TFRT_CPU_0.
I 13:24:15 [io.py:39]: No CUDA GPU devices found in jax.devices("cuda").
I 13:24:15 [io.py:39]: No CUDA GPU devices found in jax.devices("cuda"). |
rickeylev
approved these changes
Nov 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this PR we first evaluate the markers in the requirements
files before going any further to aggregate them and process further.
This makes the separation of logic a little bit more clear.
I wanted to do this before I add more tests to after debugging
the failures observed when enabling pipstar.
Whilst cleaning up further I realized that I can fix the handling of
packages where some platforms may end up not needing extras whilst others
do. This is achieved by reusing the same code that allows us to have
different versions per platform.
Work towards #2949
Fixes #3374