Strip the free-threaded suffix before handing a version to uv - #2403
Open
SirHegel wants to merge 1 commit into
Open
Strip the free-threaded suffix before handing a version to uv#2403SirHegel wants to merge 1 commit into
SirHegel wants to merge 1 commit into
Conversation
Both places that build a uv command pass the environment's python setting
straight to --python-version. uv resolves for a version rather than for a
build, so a free-threaded selector is not something it can parse:
error: invalid value '3.14t' for '--python-version': Python version
`3.14t` could not be parsed: after parsing `3.14`, found `t`
hatch-test lists 3.14t in its default matrix, so hatch env lock fails out
of the box.
Run the value through normalize_distribution_name first, which is already
used for the same purpose in virtual.py. It only drops the suffix when
the base version actually has a free-threaded variant, so 3.9t, pypy3.10
and a plain 3.14 are all left alone.
Fixes pypa#2393.
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.
Fixes #2393.
Both places that build a uv command pass the environment's
pythonsetting straight to--python-version:src/hatch/env/lockers/uv.py(uv pip compile)src/hatch/env/virtual.py(uv pip sync)uv resolves for a version, not for a build, so a free-threaded selector is not something it can parse:
hatch-testlists3.14tin its default matrix (src/hatch/env/internal/test.py), so this is hit without any custom configuration.The change
Run the value through
normalize_distribution_namefirst. It is already used for exactly this invirtual.py::_get_available_distribution, and it only drops the suffix when the base version really has a free-threaded variant:3.14t3.143.13t3.133.143.143.9t3.9t— 3.9 has no free-threaded build, left alonepypy3.10pypy3.10Checked against uv 0.12.5:
--python-version 3.14compiles,3.14tis the error above.Tests
I did not add one. There is no existing harness for these two command builders — nothing in
tests/constructs aVirtualEnvironmentor callsUVLocker._compile— andnormalize_distribution_nameis the tested part. Happy to add coverage if you would like it, but I did not want to stand up a fixture for it uninvited.tests/envreports the same 187 collection errors before and after this change on my machine, so I could not use it as a signal either way; they look like a missing environment variable in my local setup rather than anything from this.