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

Respect markers on URL dependencies in editables #2176

Merged
merged 1 commit into from
Mar 4, 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
4 changes: 4 additions & 0 deletions crates/uv-resolver/src/resolver/urls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ impl Urls {
}

for requirement in &metadata.requires_dist {
if !requirement.evaluate_markers(markers, &[]) {
continue;
}

if let Some(pep508_rs::VersionOrUrl::Url(url)) = &requirement.version_or_url {
if let Some(previous) = urls.insert(requirement.name.clone(), url.clone()) {
if cache_key::CanonicalUrl::new(previous.raw())
Expand Down
47 changes: 47 additions & 0 deletions crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2200,3 +2200,50 @@ requires-python = ">=3.8"

Ok(())
}

/// Ignore a URL dependency with a non-matching marker.
#[test]
fn editable_url_with_marker() -> Result<()> {
let context = TestContext::new("3.12");

let editable_dir = assert_fs::TempDir::new()?;
let pyproject_toml = editable_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "example"
version = "0.1.0"
dependencies = [
"anyio==4.0.0; python_version >= '3.11'",
"anyio @ https://files.pythonhosted.org/packages/2d/b8/7333d87d5f03247215d86a86362fd3e324111788c6cdd8d2e6196a6ba833/anyio-4.2.0.tar.gz ; python_version < '3.11'"
]
requires-python = ">=3.11,<3.13"
"#,
)?;

let filters = [(r"\(from file://.*\)", "(from [WORKSPACE_DIR])")]
.into_iter()
.chain(INSTA_FILTERS.to_vec())
.collect::<Vec<_>>();

uv_snapshot!(filters, command(&context)
.arg("--editable")
.arg(editable_dir.path()), @r###"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Built 1 editable in [TIME]
Resolved 4 packages in [TIME]
Downloaded 3 packages in [TIME]
Installed 4 packages in [TIME]
+ anyio==4.0.0
+ example==0.1.0 (from [WORKSPACE_DIR])
+ idna==3.4
+ sniffio==1.3.0
"###
);

Ok(())
}