diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 596a0e5e7c87..3eaa5161c6de 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -180,12 +180,17 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { None } }) - .chain( - manifest - .editables - .iter() - .map(|(editable, _)| editable.raw()), - ) + .chain(manifest.editables.iter().flat_map(|(editable, metadata)| { + std::iter::once(editable.raw()).chain(metadata.requires_dist.iter().filter_map( + |req| { + if let Some(pep508_rs::VersionOrUrl::Url(url)) = &req.version_or_url { + Some(url.raw()) + } else { + None + } + }, + )) + })) .collect(); // Determine the allowed yanked package versions diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index f9bad50a1f2c..958da9082df1 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -2167,6 +2167,45 @@ fn compile_editable() -> Result<()> { Ok(()) } +/// Compile an editable package with a direct URL requirement. +#[test] +fn compile_editable_url_requirement() -> Result<()> { + let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("-e ../../scripts/editable-installs/hatchling_editable")?; + + let filter_path = regex::escape(&requirements_in.normalized_display().to_string()); + let filters: Vec<_> = [(filter_path.as_str(), "requirements.in")] + .into_iter() + .chain(INSTA_FILTERS.to_vec()) + .collect(); + + uv_snapshot!(filters, Command::new(get_bin()) + .arg("pip") + .arg("compile") + .arg(requirements_in.path()) + .arg("--cache-dir") + .arg(context.cache_dir.path()) + .arg("--exclude-newer") + .arg(EXCLUDE_NEWER) + .env("VIRTUAL_ENV", context.venv.as_os_str()), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv v[VERSION] via the following command: + # uv pip compile requirements.in --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z + -e ../../scripts/editable-installs/hatchling_editable + iniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl + # via hatchling-editable + + ----- stderr ----- + Built 1 editable in [TIME] + Resolved 2 packages in [TIME] + "###); + + Ok(()) +} + #[test] #[ignore] fn cache_errors_are_non_fatal() -> Result<()> { diff --git a/scripts/editable-installs/hatchling_editable/README.md b/scripts/editable-installs/hatchling_editable/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/scripts/editable-installs/hatchling_editable/hatchling_editable/__init__.py b/scripts/editable-installs/hatchling_editable/hatchling_editable/__init__.py new file mode 100644 index 000000000000..b9bfa6f12339 --- /dev/null +++ b/scripts/editable-installs/hatchling_editable/hatchling_editable/__init__.py @@ -0,0 +1,2 @@ +def func(): + pass diff --git a/scripts/editable-installs/hatchling_editable/pyproject.toml b/scripts/editable-installs/hatchling_editable/pyproject.toml new file mode 100644 index 000000000000..92c4d20c79ea --- /dev/null +++ b/scripts/editable-installs/hatchling_editable/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "hatchling-editable" +description = 'A simple editable package with a URL dependency.' +readme = "README.md" +requires-python = ">=3.7" +license = "MIT" +keywords = [] +authors = [ + { name = "Astral Software Inc.", email = "hey@astral.sh" }, +] +classifiers = [] +dependencies = [ + "iniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" +] +version = "0.1.0" + +[tool.hatch.metadata] +allow-direct-references = true diff --git a/scripts/editable-installs/poetry_editable/pyproject.toml b/scripts/editable-installs/poetry_editable/pyproject.toml index de9b0b94fe5c..4b78852f93a1 100644 --- a/scripts/editable-installs/poetry_editable/pyproject.toml +++ b/scripts/editable-installs/poetry_editable/pyproject.toml @@ -2,7 +2,7 @@ name = "poetry-editable" version = "0.1.0" description = "" -authors = ["konstin "] +authors = ["Astral Software Inc. "] [tool.poetry.dependencies] python = "^3.10"