-
Notifications
You must be signed in to change notification settings - Fork 762
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
uv-resolver: fix marker propagation #5597
Conversation
This PR represents a different approach to marker propagation in an attempt to unblock #4640. In particular, instead of propagating markers when forks are created, we wait until resolution is complete to propagate all markers to all dependencies in each fork. This ends up being both more robust (we should never miss anything) and simpler to implement because it doesn't require mutating a `PubGrubPackage` (which was pretty annoying). I think the main downside here is that this can sometimes add markers where they aren't needed. This actually winds up making quite a few snapshot changes. I went through each of them. Some of them look like legitimate bug fixes. Some of them look like superfluous additions. And some of them look like they would be removed if we had perfect marker normalization. But I don't think any of the changes are _wrong_.
{ name = "idna" }, | ||
{ name = "sniffio" }, | ||
{ name = "idna", marker = "python_version < '3.12'" }, | ||
{ name = "sniffio", marker = "python_version < '3.12'" }, |
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.
I think these are superfluous because the dependency on anyio
from a
above is already gated on marker expressions.
(I think this change overall brings us closer to "write out the full marker expressions for each distribution" that could potentially obviate the need for a DAG traversal.)
{ name = "typing-extensions", marker = "(python_full_version <= '3.10' and python_version == '3.10') or (python_full_version <= '3.10' and python_version < '3.10') or (python_full_version <= '3.10' and python_version < '3.10' and python_version > '3.10') or (python_full_version <= '3.10' and python_version > '3.10') or (python_full_version > '3.10' and python_version == '3.10') or (python_full_version > '3.10' and python_version < '3.10') or (python_full_version > '3.10' and python_version < '3.10' and python_version > '3.10') or (python_full_version > '3.10' and python_version > '3.10')" }, | ||
{ name = "attrs" }, | ||
{ name = "iniconfig" }, | ||
{ name = "typing-extensions", marker = "python_full_version <= '3.10' or python_full_version > '3.10'" }, |
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.
I believe these are all correct simplifications from what was here previously.
@@ -582,7 +582,7 @@ fn fork_filter_sibling_dependencies() -> Result<()> { | |||
version = "1.0.0" | |||
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" } | |||
dependencies = [ | |||
{ name = "package-d", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" } }, | |||
{ name = "package-d", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform == 'darwin'" }, |
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.
I think this one and the one above are superfluous (again, assuming a DAG traversal).
{ name = "package-foo", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" } }, | ||
{ name = "package-foo", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" } }, | ||
{ name = "package-foo", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform == 'linux'" }, | ||
{ name = "package-foo", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform != 'linux'" }, |
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 one looks like a legitimate bug fix, since previous we had unconditional dependencies on two different versions of package-foo
here. I filed #5598 in reaction to this.
@@ -6612,7 +6612,7 @@ fn universal_conflicting() -> Result<()> { | |||
# via trio | |||
outcome==1.3.0.post0 ; sys_platform == 'darwin' or sys_platform == 'win32' | |||
# via trio | |||
pycparser==2.21 ; (implementation_name != 'pypy' and os_name == 'nt' and sys_platform == 'darwin') or (os_name == 'nt' and sys_platform == 'win32') | |||
pycparser==2.21 ; (sys_platform == 'darwin' or sys_platform == 'win32') and ((implementation_name != 'pypy' and os_name == 'nt' and sys_platform == 'darwin') or (os_name == 'nt' and sys_platform == 'win32')) |
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.
I believe the extra term added here is strictly redundant.
# via | ||
# -r requirements.in | ||
# torchvision | ||
torch==2.0.0+cu118 | ||
torch==2.0.0+cu118 ; platform_machine == 'x86_64' |
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 looks like another legitimate bug fix, where previously we could install two different versions of torch
.
# via | ||
# -r requirements.in | ||
# example | ||
cffi==1.17.0rc1 | ||
cffi==1.17.0rc1 ; os_name == 'Linux' |
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.
Another bug fix!
This PR represents a different approach to marker propagation in an
attempt to unblock #5583. In particular, instead of propagating markers
when forks are created, we wait until resolution is complete to
propagate all markers to all dependencies in each fork. This ends up
being both more robust (we should never miss anything) and simpler to
implement because it doesn't require mutating a
PubGrubPackage
(whichwas pretty annoying). I think the main downside here is that this can
sometimes add markers where they aren't needed.
This actually winds up making quite a few snapshot changes. I went
through each of them. Some of them look like legitimate bug fixes. Some
of them look like superfluous additions. And some of them look like they
would be removed if we had perfect marker normalization. But I don't
think any of the changes are wrong.