Repository navigation
Infer platform_python_implementation from known implementation names - #23334
charliermarsh wants to merge 1 commit into
Conversation
b7b8181 to
a284f7e
Compare
| (literal!("cpython"), literal!("CPython")), | ||
| (literal!("pypy"), literal!("PyPy")), | ||
| (literal!("graalpy"), literal!("GraalVM")), | ||
| (literal!("pyston"), literal!("CPython")), |
There was a problem hiding this comment.
[P2] Keep CPython wheel coverage disjoint from Pyston
If 1.0 ships only a pyston38 wheel and 1.0+local ships only a cp38 wheel for the same platform, fork_version_registry now sees no environment covered only by 1.0. The CPython wheel still emits platform_python_implementation == 'CPython', which this implication makes true for every Pyston environment. The lock can therefore discard the only wheel Pyston can install: uv generates pyston38, not cp38, tags for Pyston. The merge base already overestimated CPython coverage for a Pyston environment, but its two wheel markers were disjoint. Keep the implication and emit implementation_name == 'cpython' for CPython tags in this PR; assert that the two wheels’ inferred markers are disjoint.
| key: MarkerValueString::PlatformPythonImplementation, | ||
| operator: MarkerOperator::Equal, | ||
| value: arcstr::literal!("GraalPy"), | ||
| value: arcstr::literal!("GraalVM"), |
There was a problem hiding this comment.
[P3] Test the GraalPy wheel-to-marker conversion
Reverting just this literal to GraalPy would make a GraalPy wheel appear incompatible with implementation_name == 'graalpy', but the new algebra tests would still pass: they construct both markers directly. Add one graalpy311-graalpy242_311_native wheel case to the existing test_implied_python_markers so it exercises the resolver conversion as well.
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
a284f7e to
fc2d3f1
Compare
| key: MarkerValueString::PlatformPythonImplementation, | ||
| operator: MarkerOperator::Equal, | ||
| value: arcstr::literal!("GraalPy"), | ||
| value: arcstr::literal!("GraalVM"), |
There was a problem hiding this comment.
[P3] Keep the GraalPy reported-name mapping in the marker algebra
Tags::from_env selects the GraalPy language tag from the implementation name graalpy. Emitting platform_python_implementation == 'GraalVM' here duplicates the mapping in exclusions() and makes the wheel marker broader: it still overlaps implementation_name != 'graalpy', since the implication is deliberately one-way. Emit implementation_name == 'graalpy' as the Pyston arm does, and let the algebra infer GraalVM. This can follow in the companion wheel-marker change.
| "python_full_version == '3.10.*' and platform_python_implementation == 'PyPy'", | ||
| ); | ||
| assert_python_markers( | ||
| "example-1.0-pyston38-none-any.whl", |
There was a problem hiding this comment.
[P3] Use an installable Pyston wheel in the marker test
The assertion exercises the new language-tag conversion, but Tags::from_env never emits pyston38-none-any: it pairs pyston38 with the native Pyston ABI, and its ABI-free Pyston tags use py*. Changing just the filename to example-1.0-pyston38-pyston_23_x86_64_linux_gnu-linux_x86_64.whl keeps the same expected Python marker while testing a wheel uv can actually select.
fc2d3f1 to
2e0a217
Compare
| // The converse is ambiguous. For example, Pyston also reports `CPython`. | ||
| for (name, implementation) in [ | ||
| (literal!("cpython"), literal!("CPython")), | ||
| (literal!("pypy"), literal!("PyPy")), |
There was a problem hiding this comment.
[P3] Suggest removing a redundant environment instead of replacing it with false
With environments = ["platform_python_implementation == 'PyPy'", "implementation_name == 'pypy'"], the second selector is now entirely covered by the first. The overlap diagnostic computes !lhs && rhs and suggests replacing the second selector with python_version < '0'. Following that hint makes uv lock fail its Python-requirement check. The merge base already gave this hint for duplicate selectors; the new implication exposes it for these two distinct keys. A follow-up can check hint.is_false() before formatting and suggest removing the redundant selector instead.
| [package.optional-dependencies] | ||
| binary = [ | ||
| { name = "psycopg-binary", marker = "implementation_name != 'pypy'" }, | ||
| { name = "psycopg-binary" }, |
There was a problem hiding this comment.
[P3] Cover dependency pruning in a PyPy-only lock
This snapshot still locks psycopg-binary; it shows that an edge marker simplifies, not that tool.uv.environments prevents an unreachable package from being resolved. Add one case beside lock_constrained_environment: set implementation_name == 'pypy' as the environment and declare an unavailable dependency guarded by sys_platform == 'win32' and platform_python_implementation != 'PyPy'. With --no-index, the base would try to resolve that dependency and fail; the fixed command should lock only the project. This exercises the reported failure without relying on Jupyter or PyPI.
Summary
For a project that supports only PyPy,
uv lockcan include Jupyter Core’s Windows dependency,pywin32, even though Jupyter explicitly excludes it on PyPy.Jupyter uses
platform_python_implementation != 'PyPy'in its dependency marker. uv treats that condition and the project’simplementation_name == 'pypy'as independent, so it considers a Windows environment where both hold. Jupyter’s dependencyWe now teach the marker algebra which value of
platform_python_implementationa knownimplementation_nameimplies. Withpypy, the value isPyPy, so uv can rule out the dependency and omitpywin32from the resolution. The implication runs in one direction because bothcpythonandpystonreportCPython. Forgraalpy, the reported value isGraalVM. We also correct the resolver’s inferred values for GraalPy and Pyston wheels so that each wheel covers its own interpreter.The marker tree already simplifies expressions using known relationships between operating system markers. We extend that logic to the two interpreter keys. Once a branch fixes the implementation name, we can evaluate comparisons against the reported value on that branch. Other implementation names remain unconstrained.
This should land with #23335 and #23310. Once we recognize that Pyston reports
CPython, we also need to useimplementation_nameto distinguish a CPython wheel from a Pyston wheel when choosing a release.