Skip to content

"Illegal ambiguous match" error with experimental_index_url #2759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tbarrella opened this issue Apr 9, 2025 · 3 comments
Open

"Illegal ambiguous match" error with experimental_index_url #2759

tbarrella opened this issue Apr 9, 2025 · 3 comments
Labels
type: pip pip/pypi integration

Comments

@tbarrella
Copy link

🐞 bug report

Affected Rule

pip.parse

Is this a regression?

not sure

Description

When pip.parse with experimental_index_url uses per-platform requirements files and package versions don't match across files, it's possible (at least on OSX, for some packages) that using the package fails with "Illegal ambiguous match"

🔬 Minimal Reproduction

https://github.com/tbarrella/ambiguous

🔥 Exception or Error


Illegal ambiguous match on configurable attribute "actual" in @@rules_python++pip+pypi//debugpy:pkg:
@@rules_python++pip+pypi//_config:is_cp313_py_none_any_osx_aarch64
@@rules_python++pip+pypi//_config:is_cp313_cp313_osx_universal2
Multiple matches are not allowed unless one is unambiguously more specialized or they resolve to the same value. See https://bazel.build/reference/be/functions#select.

Illegal ambiguous match on configurable attribute "actual" in @@rules_python++pip+pypi//tornado:pkg:
@@rules_python++pip+pypi//_config:is_cp313_sdist_osx_aarch64
@@rules_python++pip+pypi//_config:is_cp313_abi3_osx_universal2
Multiple matches are not allowed unless one is unambiguously more specialized or they resolve to the same value. See https://bazel.build/reference/be/functions#select.

🌍 Your Environment

Operating System:

  
macOS, M2, 15.3.1
  

Output of bazel version:

  
Bazelisk version: 1.25.0
Build label: 8.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Tue Feb 25 18:53:44 2025 (1740509624)
Build timestamp: 1740509624
Build timestamp as int: 1740509624
  

Rules_python version:

  
1.3.0
  

Anything else relevant?

@aignas aignas added the type: pip pip/pypi integration label Apr 9, 2025
@aignas
Copy link
Collaborator

aignas commented May 24, 2025

The root cause of this is different from #2648.

The reproduction is trying to include different versions for different target platforms and it seems that it is failing due to us including more than what would be minimally necessary. I was already thinking about the fix for this but did not have time to do it but in quick terms here is what I am thinking about.


First select_whls is returning a list of compatible wheels with the target platform.

  1. the freethreaded/non-freethreaded
  2. manylinux/musllinux
  3. universal2 vs arch wheels

Instead of having all of them, we could just have one wheel that is matching the target platform.

However, the target platform definition is not customizable and in order to have it customizable, we have to first implement #2909. Once that is done, we can revisit this issue.


A workaround for this is to not use different versions for different target platforms or to remove the hashes for some of the requirements.

@rickeylev
Copy link
Collaborator

One trick to avoid ambiguous match is to use a chain of select-default, e.g

alias(
  name = "x" actual = select({
  ":ft_yes": ...,
  "//conditions:default": ":ft_no",
  })
)

alias(
  name = "ft_no", actual = select({
    ":linux": ...,
    ":mac": ...
  })
)

@aignas
Copy link
Collaborator

aignas commented May 25, 2025

But to be fully correct we would have to first select the target platform and only then the wheel based config setting.

That would be another solution to this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: pip pip/pypi integration
Projects
None yet
Development

No branches or pull requests

3 participants