-
Notifications
You must be signed in to change notification settings - Fork 803
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
Allow conflicting extras in explicit index assignments #9160
Conversation
7a9cb14
to
479be8f
Compare
This needs documentation, but I'm gonna wait for approval. |
b15ad5b
to
2a7e41b
Compare
I worry about the confusion of
But otherwise I'm into it! We could be more verbose and say |
abacdc0
to
08ba726
Compare
This now also supports dependency groups equally. |
Umm. Maybe |
I could also try to make it such that we error if we see the dependency requested as a production dependency, when it has a source with an extra on it? |
I can't think of a case from
This seems reasonable, or at least a warning. |
Ok, I'll start by adding some dedicated errors around this stuff. I think with good error messages (e.g., detect if |
c3777a5
to
d7a9215
Compare
Ok, I added some dedicated error messages around this. |
ebef8bb
to
c64d46b
Compare
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.
This is a cool application of conflicting extras!
#[derive(Debug, Clone)] | ||
struct Entry { | ||
index: IndexUrl, | ||
conflict: Option<ConflictItem>, |
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.
This is the subset of forks in which this entry occurs, not a conflict we generated?
crates/uv-pep508/src/marker/tree.rs
Outdated
|
||
match extra_expression { | ||
MarkerExpression::Extra { name, .. } => name.into_extra(), | ||
_ => None, |
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.
Is that reachable?
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.
Nice! I think this all makes sense to me.
pub(crate) fn from_requirement<'data>( | ||
requirement: uv_pep508::Requirement<VerbatimParsedUrl>, | ||
project_name: &'data PackageName, | ||
project_dir: &'data Path, | ||
project_sources: &'data BTreeMap<PackageName, Sources>, | ||
project_indexes: &'data [Index], | ||
extra: Option<ExtraName>, | ||
group: Option<GroupName>, |
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.
Should these be Option<&ExtraName>
and Option<&GroupName>
? It looks like the Clippy lint for this was suppressed explicitly, so I'm guessing there's a reason for it, but it doesn't immediately stand out to me.
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.
They should but I can't for the life of me figure out how to get it to work at the call site.
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.
Figured it out by removing a lifetime.
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.
Ahhh yeah I see now. Nice.
entry | ||
.conflict | ||
.as_ref() | ||
.map_or(true, |conflict| env.included_by_group(conflict.as_ref())) |
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.
Nice
Just to clarify, this looks like it includes |
c64d46b
to
a0562d1
Compare
It does yes. I mentioned that here but I guess not in the PR summary. |
a0562d1
to
3895d9a
Compare
3895d9a
to
62cef2e
Compare
Highlight for me is support for conflicting deps: astral-sh/uv#9160
Summary
This PR enables something like the "final boss" of PyTorch setups -- explicit support for CPU vs. GPU-enabled variants via extras:
It builds atop the conflicting extras work to allow sources to be marked as specific to a dedicated extra being enabled or disabled.
As part of this work, sources now have an
extra
field. If a source has anextra
, it means that the source is only applied to the requirement when defined within that optional group. For example,{ index = "torch-cpu", extra = "cpu" }
above only applies to"torch==2.5.1+cpu"
.The
extra
field does not mean that the source is "enabled" when the extra is activated. For example, this wouldn't work:In this case, the sources would effectively be ignored. Extras are really confusing... but I think this is correct? We don't want enabling or disabling extras to affect resolution information that's outside of the relevant optional group.