Allow conflicting extras in explicit index assignments#9160
Allow conflicting extras in explicit index assignments#9160charliermarsh merged 4 commits intomainfrom
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
konstin
left a comment
There was a problem hiding this comment.
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.
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, |
BurntSushi
left a comment
There was a problem hiding this comment.
Nice! I think this all makes sense to me.
| project_sources: &'data BTreeMap<PackageName, Sources>, | ||
| project_indexes: &'data [Index], | ||
| extra: Option<ExtraName>, | ||
| group: Option<GroupName>, |
There was a problem hiding this comment.
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.
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.
Figured it out by removing a lifetime.
| entry | ||
| .conflict | ||
| .as_ref() | ||
| .map_or(true, |conflict| env.included_by_group(conflict.as_ref())) |
|
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
Highlight for me is support for conflicting deps: astral-sh/uv#9160 GitOrigin-RevId: 61315111b6f581823b36ce123c444c8403bc6032
Highlight for me is support for conflicting deps: astral-sh/uv#9160 GitOrigin-RevId: 61315111b6f581823b36ce123c444c8403bc6032
Highlight for me is support for conflicting deps: astral-sh/uv#9160 GitOrigin-RevId: 61315111b6f581823b36ce123c444c8403bc6032
Highlight for me is support for conflicting deps: astral-sh/uv#9160 GitOrigin-RevId: 61315111b6f581823b36ce123c444c8403bc6032
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
extrafield. 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
extrafield 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.