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

less aggressive overlapping markers #5887

Merged
merged 7 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ jobs:
steps:
- name: Create Dev Drive using ReFS
run: |
$Volume = New-VHD -Path C:/uv_dev_drive.vhdx -SizeBytes 14GB |
$Volume = New-VHD -Path C:/uv_dev_drive.vhdx -SizeBytes 20GB |
Mount-VHD -Passthru |
Initialize-Disk -Passthru |
New-Partition -AssignDriveLetter -UseMaximumSize |
Expand Down
5 changes: 5 additions & 0 deletions crates/uv-resolver/src/resolution/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ impl ResolutionGraph {
Range::from(requires_python.bound().clone()),
);
}
// The above simplification may turn some markers into
// "always false." In which case, we should remove that
// edge since it can never be traversed in any marker
// environment.
petgraph.retain_edges(|graph, edge| !graph[edge].is_false());
}

let fork_markers = if let [resolution] = resolutions {
Expand Down
599 changes: 211 additions & 388 deletions crates/uv-resolver/src/resolver/mod.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/uv/tests/branching_urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn branching_urls_overlapping() -> Result<()> {
----- stdout -----

----- stderr -----
error: Requirements contain conflicting URLs for package `iniconfig`:
error: Requirements contain conflicting URLs for package `iniconfig` in split `python_version >= '3.11' and python_version < '3.12'`:
- https://files.pythonhosted.org/packages/9b/dd/b3c12c6d707058fa947864b67f0c4e0c39ef8610988d7baea9578f3c48f3/iniconfig-1.1.1-py2.py3-none-any.whl
- https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl
"###
Expand Down Expand Up @@ -678,7 +678,7 @@ fn branching_urls_of_different_sources_conflict() -> Result<()> {
----- stdout -----

----- stderr -----
error: Requirements contain conflicting URLs for package `iniconfig`:
error: Requirements contain conflicting URLs for package `iniconfig` in split `python_version >= '3.11' and python_version < '3.12'`:
- git+https://github.com/pytest-dev/iniconfig@93f5930e668c0d1ddf4597e38dd0dea4e2665e7a
- https://files.pythonhosted.org/packages/9b/dd/b3c12c6d707058fa947864b67f0c4e0c39ef8610988d7baea9578f3c48f3/iniconfig-1.1.1-py2.py3-none-any.whl
"###
Expand Down
4 changes: 4 additions & 0 deletions crates/uv/tests/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,10 @@ fn update() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
environment-markers = [
"python_version <= '3.7'",
"python_version > '3.7'",
]

[options]
exclude-newer = "2024-03-25 00:00:00 UTC"
Expand Down
14 changes: 9 additions & 5 deletions crates/uv/tests/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,10 @@ fn lock_conditional_dependency_extra() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.7"
environment-markers = [
"python_version < '3.10'",
"python_version >= '3.10'",
]

[options]
exclude-newer = "2024-03-25 00:00:00 UTC"
Expand Down Expand Up @@ -1645,7 +1649,7 @@ fn lock_conditional_dependency_extra() -> Result<()> {

[package.optional-dependencies]
socks = [
{ name = "pysocks" },
{ name = "pysocks", marker = "python_version < '3.10'" },
]

[[package]]
Expand Down Expand Up @@ -3569,12 +3573,12 @@ fn lock_python_version_marker_complement() -> Result<()> {
version = 1
requires-python = ">=3.8"
environment-markers = [
"python_full_version > '3.10' and python_version > '3.10'",
"python_full_version > '3.10' and python_version == '3.10'",
"python_full_version > '3.10' and python_version < '3.10'",
"python_full_version <= '3.10' and python_version > '3.10'",
"python_full_version <= '3.10' and python_version == '3.10'",
"python_full_version <= '3.10' and python_version < '3.10'",
"python_full_version > '3.10' and python_version == '3.10'",
"python_full_version > '3.10' and python_version > '3.10'",
"python_full_version <= '3.10' and python_version == '3.10'",
"python_full_version <= '3.10' and python_version > '3.10'",
]

[options]
Expand Down
91 changes: 46 additions & 45 deletions crates/uv/tests/lock_scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ fn fork_marker_disjoint() -> Result<()> {

----- stderr -----
warning: `uv lock` is experimental and may change without warning
× No solution found when resolving dependencies:
× No solution found when resolving dependencies for split (sys_platform == 'linux'):
╰─▶ Because project==0.1.0 depends on package-a{sys_platform == 'linux'}>=2 and package-a{sys_platform == 'linux'}<2, we can conclude that project==0.1.0 cannot be used.
And because only project==0.1.0 is available and you require project, we can conclude that the requirements are unsatisfiable.
"###
Expand Down Expand Up @@ -2896,7 +2896,8 @@ fn fork_overlapping_markers_basic() -> Result<()> {
requires-python = ">=3.8"
environment-markers = [
"python_version < '3.10'",
"python_version >= '3.10'",
"python_version >= '3.11'",
"python_version >= '3.10' and python_version < '3.11'",
]

[[package]]
Expand Down Expand Up @@ -3442,16 +3443,30 @@ fn preferences_dependent_forking_tristable() -> Result<()> {
name = "package-bar"
version = "1.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform != 'linux'",
]
dependencies = [
{ name = "package-c", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform == 'linux'" },
{ name = "package-d", marker = "sys_platform != 'linux'" },
{ name = "package-reject-cleaver-1" },
{ name = "package-reject-cleaver-1", marker = "sys_platform != 'linux'" },
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_bar-1.0.0.tar.gz", hash = "sha256:5d7142b60729bd25206dde836b8f629c72a29593156dee4c4551ad23b7096e8c" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_bar-1.0.0-py3-none-any.whl", hash = "sha256:a590cb59852676a12e3537efe2c812c0640a32408a2ea7f6e5611c7190683865" },
]

[[package]]
name = "package-bar"
version = "2.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform == 'linux'",
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_bar-2.0.0.tar.gz", hash = "sha256:cc856e6aca342176e6ba518a298198258b7be3ee7a6b86319c1d8b731e54991e" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_bar-2.0.0-py3-none-any.whl", hash = "sha256:80195408d22da78f3d6ac3cc955840b5fcb2a76d774120e2aa007c7e7cbc2b4e" },
]

[[package]]
name = "package-c"
version = "2.0.0"
Expand Down Expand Up @@ -3481,8 +3496,8 @@ fn preferences_dependent_forking_tristable() -> Result<()> {
version = "1.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
dependencies = [
{ name = "package-bar", marker = "sys_platform != 'linux'" },
{ 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-bar", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform != 'linux'" },
{ name = "package-foo", marker = "sys_platform == 'linux'" },
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_cleaver-1.0.0.tar.gz", hash = "sha256:49ec5779d0722586652e3ceb4ca2bf053a79dc3fa2d7ccd428a359bcc885a248" }
wheels = [
Expand All @@ -3505,30 +3520,16 @@ fn preferences_dependent_forking_tristable() -> Result<()> {
name = "package-foo"
version = "1.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform == 'linux'",
]
dependencies = [
{ name = "package-c", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform == 'linux'" },
{ name = "package-reject-cleaver-1", marker = "sys_platform == 'linux'" },
{ name = "package-c", version = "3.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform != 'linux'" },
{ name = "package-reject-cleaver-1" },
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_foo-1.0.0.tar.gz", hash = "sha256:7c1a2ca51dd2156cf36c3400e38595e11b09442052f4bd1d6b3d53eb5b2acf32" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_foo-1.0.0-py3-none-any.whl", hash = "sha256:524dfd846c31a55bb6d6a0d0cec80d42c0a87c78aabbe0f1d5426c60493bd41b" },
]

[[package]]
name = "package-foo"
version = "2.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform != 'linux'",
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_foo-2.0.0.tar.gz", hash = "sha256:1607aa970fac2e237de28636bf53b022b0c391ecc9039e34438638c8743cc83b" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_tristable_foo-2.0.0-py3-none-any.whl", hash = "sha256:8a757092c63519d20d312dacf83ed3c9cc8156495279305a2249175e0407e4df" },
]

[[package]]
name = "package-reject-cleaver-1"
version = "1.0.0"
Expand Down Expand Up @@ -3571,10 +3572,10 @@ fn preferences_dependent_forking_tristable() -> Result<()> {
version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "package-bar" },
{ name = "package-bar", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform != 'linux'" },
{ name = "package-bar", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform == 'linux'" },
{ name = "package-cleaver" },
{ 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'" },
{ name = "package-foo" },
]
"###
);
Expand Down Expand Up @@ -3720,18 +3721,33 @@ fn preferences_dependent_forking() -> Result<()> {
name = "package-bar"
version = "1.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform != 'linux'",
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_bar-1.0.0.tar.gz", hash = "sha256:7eef4e0c910b9e4cadf6c707e60a2151f7dc6407d815112ec93a467d76226f5e" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_bar-1.0.0-py3-none-any.whl", hash = "sha256:3cdaac4b0ba330f902d0628c0b1d6e62692f52255d02718d04f46ade7c8ad6a6" },
]

[[package]]
name = "package-bar"
version = "2.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform == 'linux'",
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_bar-2.0.0.tar.gz", hash = "sha256:f440dbb8c3b848be467c9d3cd4970963fae3144de12454fd48fe9077eb76e9ea" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_bar-2.0.0-py3-none-any.whl", hash = "sha256:24fd0534fec4053f4cac960244943ef13d1bad26bbb5fffe6944a8cf898f26f0" },
]

[[package]]
name = "package-cleaver"
version = "1.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
dependencies = [
{ name = "package-bar", marker = "sys_platform != 'linux'" },
{ 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-bar", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform != 'linux'" },
{ name = "package-foo", marker = "sys_platform == 'linux'" },
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_cleaver-1.0.0.tar.gz", hash = "sha256:0347b927fdf7731758ea53e1594309fc6311ca6983f36553bc11654a264062b2" }
wheels = [
Expand All @@ -3742,35 +3758,20 @@ fn preferences_dependent_forking() -> Result<()> {
name = "package-foo"
version = "1.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform == 'linux'",
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_foo-1.0.0.tar.gz", hash = "sha256:abf1c0ac825ee5961e683067634916f98c6651a6d4473ff87d8b57c17af8fed2" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_foo-1.0.0-py3-none-any.whl", hash = "sha256:85348e8df4892b9f297560c16abcf231828f538dc07339ed121197a00a0626a5" },
]

[[package]]
name = "package-foo"
version = "2.0.0"
source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }
environment-markers = [
"sys_platform != 'linux'",
]
sdist = { url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_foo-2.0.0.tar.gz", hash = "sha256:ad54d14a4fd931b8ccb6412edef71fe223c36362d0ccfe3fa251c17d4f07e4a9" }
wheels = [
{ url = "https://astral-sh.github.io/packse/PACKSE_VERSION/files/preferences_dependent_forking_foo-2.0.0-py3-none-any.whl", hash = "sha256:bae278cf259c0e031e52b6cbb537d945e0e606d045e980b90d406d0f1e06aae9" },
]

[[package]]
name = "project"
version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "package-bar" },
{ name = "package-bar", version = "1.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform != 'linux'" },
{ name = "package-bar", version = "2.0.0", source = { registry = "https://astral-sh.github.io/packse/PACKSE_VERSION/simple-html/" }, marker = "sys_platform == 'linux'" },
{ name = "package-cleaver" },
{ 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'" },
{ name = "package-foo" },
]
"###
);
Expand Down
19 changes: 13 additions & 6 deletions crates/uv/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6811,13 +6811,18 @@ fn universal_multi_version() -> Result<()> {
.arg("-c")
.arg("constraints.txt")
.arg("--universal"), @r###"
success: false
exit_code: 1
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in -c constraints.txt --universal
iniconfig==1.0.0 ; python_version == '3.12'
# via -r requirements.in
iniconfig==2.0.0 ; python_version > '3.12'
# via -r requirements.in

----- stderr -----
× No solution found when resolving dependencies:
╰─▶ Because you require iniconfig{python_version > '3.12'}==2.0.0 and iniconfig{python_version == '3.12'}==1.0.0, we can conclude that the requirements are unsatisfiable.
Resolved 2 packages in [TIME]
"###
);

Expand Down Expand Up @@ -7725,13 +7730,15 @@ fn universal_disjoint_prereleases_allow() -> Result<()> {
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --universal --prerelease allow
cffi==1.16.0rc2
cffi==1.16.0rc2 ; os_name != 'linux'
# via -r requirements.in
cffi==1.16.0 ; os_name == 'linux'
# via -r requirements.in
pycparser==2.22
# via cffi

----- stderr -----
Resolved 2 packages in [TIME]
Resolved 3 packages in [TIME]
"###
);

Expand Down
Loading
Loading