From 9e066574b84d5714fa79ab9605b34b91336396a3 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Tue, 6 Aug 2024 08:07:55 -0400 Subject: [PATCH] support overlapping local and non-local requirements in forks --- crates/uv-resolver/src/resolver/mod.rs | 5 ---- crates/uv/tests/pip_compile.rs | 40 ++++++++++++++------------ 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index d9a4b8c9e1c8..58b8bb3fe88d 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -2117,11 +2117,6 @@ impl ForkState { if let Some(specifier) = specifier { let locals = locals.get(name, &self.markers); - // Prioritize local versions over the original version range. - if !locals.is_empty() { - *version = Range::empty(); - } - // It's possible that there are multiple matching local versions requested with // different marker expressions. All of these are potentially compatible until we // narrow to a specific fork. diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 616f0015f25a..ae350666a51e 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -7170,7 +7170,7 @@ fn universal_disjoint_local_requirement() -> Result<()> { /// expressions, we should fork the root requirement. #[test] fn universal_disjoint_base_or_local_requirement() -> Result<()> { - let context = TestContext::new("3.12"); + let context = TestContext::new("3.10"); let pyproject_toml = context.temp_dir.child("pyproject.toml"); pyproject_toml.write_str(indoc! {r#" @@ -7178,11 +7178,11 @@ fn universal_disjoint_base_or_local_requirement() -> Result<()> { name = "example" version = "0.0.0" dependencies = [ - "torch==2.0.0; python_version < '3.10'", - "torch==2.0.0+cu118 ; python_version >= '3.10' and python_version <= '3.12'", + "torch==2.0.0; python_version < '3.11'", + "torch==2.0.0+cu118 ; python_version >= '3.11' and python_version <= '3.12'", "torch==2.0.0+cpu ; python_version > '3.12'" ] - requires-python = ">=3.11" + requires-python = ">=3.10" "#})?; let requirements_in = context.temp_dir.child("requirements.in"); @@ -7203,42 +7203,46 @@ fn universal_disjoint_base_or_local_requirement() -> Result<()> { ----- stdout ----- # This file was autogenerated by uv via the following command: # uv pip compile --cache-dir [CACHE_DIR] requirements.in --universal - cmake==3.28.4 ; python_version <= '3.12' and platform_machine == 'x86_64' and platform_system == 'Linux' + cmake==3.28.4 ; python_version <= '3.12' and python_version >= '3.11' and platform_machine == 'x86_64' and platform_system == 'Linux' # via triton - . + . ; python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11') # via -r requirements.in - filelock==3.13.1 + filelock==3.13.1 ; python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11') or (python_version <= '3.12' and python_version >= '3.11' and platform_machine == 'x86_64' and platform_system == 'Linux') # via # torch # triton - jinja2==3.1.3 + jinja2==3.1.3 ; python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11') # via torch - lit==18.1.2 ; python_version <= '3.12' and platform_machine == 'x86_64' and platform_system == 'Linux' + lit==18.1.2 ; python_version <= '3.12' and python_version >= '3.11' and platform_machine == 'x86_64' and platform_system == 'Linux' # via triton - markupsafe==2.1.5 + markupsafe==2.1.5 ; (python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11')) and (python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11')) # via jinja2 - mpmath==1.3.0 + mpmath==1.3.0 ; (python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11')) and (python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11')) # via sympy - networkx==3.2.1 + networkx==3.2.1 ; python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11') # via torch - sympy==1.12 + sympy==1.12 ; python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11') # via torch - torch==2.0.0+cpu + torch==2.0.0 ; python_version < '3.11' or (python_version <= '3.12' and python_version > '3.12' and python_version >= '3.11') + # via + # -r requirements.in + # example + torch==2.0.0+cpu ; python_version > '3.12' # via # -r requirements.in # example - torch==2.0.0+cu118 ; python_version <= '3.12' + torch==2.0.0+cu118 ; python_version <= '3.12' and python_version >= '3.11' # via # -r requirements.in # example # triton - triton==2.0.0 ; python_version <= '3.12' and platform_machine == 'x86_64' and platform_system == 'Linux' + triton==2.0.0 ; python_version <= '3.12' and python_version >= '3.11' and platform_machine == 'x86_64' and platform_system == 'Linux' # via torch - typing-extensions==4.10.0 + typing-extensions==4.10.0 ; python_version < '3.11' or python_version > '3.12' or (python_version <= '3.12' and python_version >= '3.11') # via torch ----- stderr ----- - Resolved 13 packages in [TIME] + Resolved 14 packages in [TIME] "### );