Skip to content
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

add provides-extras to lockfile #11063

Merged
merged 6 commits into from
Feb 11, 2025
Merged

add provides-extras to lockfile #11063

merged 6 commits into from
Feb 11, 2025

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented Jan 29, 2025

Fixes #10953

@Gankra Gankra requested a review from charliermarsh January 29, 2025 14:20
@Gankra
Copy link
Contributor Author

Gankra commented Jan 29, 2025

I still need to add a snapshot test where this is non-empty.

@@ -1786,6 +1786,16 @@ impl Package {
.collect::<Result<_, _>>()
.map_err(LockErrorKind::RequirementRelativePath)?
};
let provides_extras = if id.source.is_immutable() {
Vec::new()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something we need to consider: if we want to start using this to enforce that a given extra exists (at install time, by reading from the lockfile), we won't be able to tell the difference between "empty" and "absent". So we either need to not do that, or bump the lockfile version so we can tell the difference, or write these even when empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a preference on which approach? "bump lockfile version" sounds principled but dunno if it's a Big Deal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. @zanieb, do you have an opinion? Bumping the lockfile version means that older uv versions will reject newer lockfiles (but we can still read older lockfiles in newer uv versions).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might just want to always write this (and always write requires-dist too). It's not, like, a huge change... Since we only show this for local packages anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to always writing this we'd also need to make this like... an Option<Vec<ExtraName>> to distinguish whether we found it in the lockfile, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that we'd continue to omit it for immutable sources, is that doable? It should massively reduce the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did remove a lot of them, yeah. (updated the commit)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally in favor of less breaking lockfile changes :) it's decent timing with 0.6 coming up, but from what I understand this doesn't justify the churn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just to enable more validation on cli arguments, yeah. Not really worth a break.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't think we should bump for it. I do wonder if we should treat requires-dist the same way, though: always write it, even if empty?

I think users will likely be annoyed that the lockfile is churning more (even without a bump) in that you're now getting different results if you lock with a later version (even though it should be backwards-compatible), but I don't know how we avoid that.

.expect("metadata is present")
.provides_extras
.clone()
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to change to_toml to write these out. The impl is manual.

@Gankra Gankra force-pushed the gankra/lock-extra branch 3 times, most recently from c88bee2 to 58d63de Compare January 29, 2025 16:41
@Gankra Gankra added this to the v0.6.0 milestone Jan 29, 2025
@charliermarsh charliermarsh mentioned this pull request Feb 8, 2025
@Gankra Gankra changed the base branch from main to tracking/060 February 11, 2025 17:03
@Gankra
Copy link
Contributor Author

Gankra commented Feb 11, 2025

CI / check system | python3.13 on windows x86-64 (pull_request)

this task is extremely haunted on this PR and I wish I had any reason to think this PR breaks it...

@Gankra
Copy link
Contributor Author

Gankra commented Feb 11, 2025

Error: Cache folder path is retrieved for pip but doesn't exist on disk: c:\users\runneradmin\appdata\local\pip\cache. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.

god worst reason to die too

@charliermarsh
Copy link
Member

god worst reason to die too

I think @zanieb fixed this on main so this branch might just be behind.

@Gankra Gankra merged commit b0c471f into tracking/060 Feb 11, 2025
72 of 73 checks passed
@Gankra Gankra deleted the gankra/lock-extra branch February 11, 2025 19:38
Gankra added a commit that referenced this pull request Feb 12, 2025
zanieb pushed a commit that referenced this pull request Feb 13, 2025
zanieb pushed a commit that referenced this pull request Feb 13, 2025
zanieb pushed a commit that referenced this pull request Feb 13, 2025
zanieb added a commit that referenced this pull request Feb 14, 2025
## Summary

This is an alternative to the approach we took in #11063 whereby we
always included `provides-extra` and `requires-dist`, since we needed
some way to differentiate between "no extras" and "lockfile was
generated by a uv version that didn't include extras".

Instead, this PR adds a minor version (called a "revision") to the
lockfile that we can use to indicate support for this feature. While
lockfile version bumps are backwards-incompatible, older uv versions
_can_ read lockfiles with a later revision -- they just won't understand
all the data.

In a future major version bump, we could simplify things and change the
schema to use a (major, minor) format instead of these two separate
fields. But this is the only way to do it that's backwards-compatible
with existing uv versions.

---------

Co-authored-by: Zanie Blue <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add provides-extra to the lockfile
3 participants