Skip to content

Conversation

@aignas
Copy link
Collaborator

@aignas aignas commented Nov 1, 2025

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

@aignas aignas changed the title WIP: simplify the marker eval refactor(pip): simplify the marker eval Nov 1, 2025
@aignas aignas marked this pull request as ready for review November 1, 2025 14:07
@aignas aignas changed the title refactor(pip): simplify the marker eval fix(pip): allow for different no extras with extras Nov 1, 2025
@aignas
Copy link
Collaborator Author

aignas commented Nov 1, 2025

@hartikainen, could you please check if this PR fixes the issue?

),
],
"pypi_312_torch_cp312_cp312_win_amd64_3a570e5c": [
"pypi_312_torch_cp312_cp312_win_amd64_3a570e5c_windows_x86_64": [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@aignas aignas changed the title fix(pip): allow for different no extras with extras fix(pip): allow for different extras for different target platforms Nov 1, 2025
@hartikainen
Copy link
Contributor

hartikainen commented Nov 1, 2025

My initial tests with these changes are promising. Using my example in main...hartikainen:rules_python:test/multi-platform-python, rebased off of main fails but rebased off of these changes works. See outputs below:

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 index

From 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").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pip.parse fails for a package with multiple extras over multiple requirements files

2 participants