-
Notifications
You must be signed in to change notification settings - Fork 760
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
Enable PEP 517 builds for unnamed requirements #2600
Conversation
This doesn't actually leverage these improvements anywhere, it just enables them. |
f113df8
to
3498022
Compare
// We can only prevent builds by name for packages with names. For editable | ||
// packages and unnamed requirements, we can't prevent the build. |
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.
Hm.. this is an interesting caveat. We should probably mention this in the --only-binary
docs?
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.
Yeah I don’t really see any way around it. It was also already true for editables, interestingly.
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.
We could default to “false” here instead of true. That might be safer? At least for non-editables.
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.
That actually seems better since you can always add a package name to fix it.
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.
TIL that pip install does not enforce --no-binary
for direct URL requirements. For example, pip install "anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz" --only-binary anyio --no-cache --force-reinstall
works fine.
3498022
to
19e34cd
Compare
Summary
This PR enables the source distribution database to be used with unnamed requirements (i.e., URLs without a package name). The (significant) upside here is that we can now use PEP 517 hooks to resolve unnamed requirement metadata and reuse any computation in the cache.
The changes to
crates/uv-distribution/src/source/mod.rs
are quite extensive, but mostly mechanical. The core idea is that we introduce a newBuildableSource
abstraction, which can either be a distribution, or an unnamed URL:All the methods on the source distribution database now accept
BuildableSource
.BuildableSource
has aname()
method, but it returnsOption<&PackageName>
, and everything is required to work with and without a package name.The main drawback of this approach (which isn't a terrible one) is that we can no longer include the package name in the cache. (We do continue to use the package name for registry-based distributions, since those always have a name.). The package name was included in the cache route for two reasons: (1) it's nice for debugging; and (2) we use it to power
uv cache clean flask
, to identify the entries that are relevant for Flask.To solve this, I changed the
uv cache clean
code to look one level deeper. So, when we want to determine whether to remove the cache entry for a given URL, we now look into the directory to see if there are any wheels that match the package name. This isn't as nice, but it does work (and we have test coverage for it -- all passing).I also considered removing the package name from the cache routes for non-registry wheels, for consistency... But, it would require a cache bump, and it didn't feel important enough to merit that.