GeezerVison is showing github.com — fix: percent-decode pylock file names derived from url by atsuoishimoto · Pull Request #1314 · pypa/packaging
Conversation
In a uv project like the following, running pip wheel -r pylocl.toml with pip 26.1.2 fails:
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.14.0"
dependencies = [
"torch>=2.11.0",
]
[tool.uv.sources]
torch = [
{ index = "pytorch-cpu" },
]
[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
$ uv export --format pylock.toml > pylock.toml
$ python3.14 -m pip wheel -r pylock.toml
WARNING: Using pylock.toml as a requirements source is an experimental feature. It may be removed/changed in a future release without prior warning.
ERROR: Invalid pylock file 'pylock.toml': Invalid wheel filename 'torch-2.12.1%2Bcpu-cp314-cp314-linux_s390x.whl' in 'packages[9].wheels[0]'
In some cases, uv omits the optional artifact name field. pip then derives the filename from the URL basename using packaging.pylock._url_name, but the basename is not percent-decoded. As a result, wheels with local versions such as 2.12.1+cu130, where + is encoded as %2B in the URL, are rejected as invalid wheel filenames.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
lets-build-an-ocean reacted with thumbs up emoji
Local versions like 2.12.1+cu130 are encoded as 2.12.1%2Bcu130 in a
url; decode the basename so the resulting wheel/sdist file name is
valid.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Interesting. What does the pylock spec say about % encoding of urls?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I do not think pylock needs any special escaping rule here; this follows from treating the field as a URL and then converting the URL path component back to a filename.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at this closer. Sounds good.
I have mild worries about double decoding, but maybe it's obvious from the URL spec that tools must encode URLs when writing pylock.toml.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I verified uv writes percent encoded lock files when exporting.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
henryiii
changed the title
Percent-decode pylock file names derived from url
fix: percent-decode pylock file names derived from url
Jul 17, 2026
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
henryiii
henryiii approved these changes
+1 more reviewer
sbidoul
sbidoul approved these changes
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|