From 3bf20f95e481227f08e41cd90487c35e5de5e9cd Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 12 Mar 2024 15:56:00 -0700 Subject: [PATCH] Use local package instead of `transitive_url_dependency.zip` (#2396) --- crates/uv/tests/pip_compile.rs | 59 +++++++++++-------- .../hatchling_editable/pyproject.toml | 2 +- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 50bee6658..c48718ebd 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -1486,53 +1486,59 @@ fn incompatible_narrowed_url_dependency() -> Result<()> { Ok(()) } -/// Request `transitive_url_dependency`, which depends on `git+https://github.com/pallets/werkzeug@2.0.0`. +/// Request `transitive_url_dependency`, which depends on `https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl`. /// Since this URL isn't declared upfront, we should reject it. #[test] #[cfg(feature = "git")] fn disallowed_transitive_url_dependency() -> Result<()> { let context = TestContext::new("3.12"); - let requirements_in = context.temp_dir.child("requirements.in"); - requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/14078476/transitive_url_dependency.zip")?; + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("hatchling_editable @ ${HATCHLING}")?; + + let hatchling_path = current_dir()?.join("../../scripts/editable-installs/hatchling_editable"); uv_snapshot!(context.compile() - .arg("requirements.in"), @r###" + .arg("requirements.in") + .env("HATCHLING", hatchling_path.as_os_str()), @r###" success: false exit_code: 2 ----- stdout ----- ----- stderr ----- - error: Package `werkzeug` attempted to resolve via URL: git+https://github.com/pallets/werkzeug@2.0.0. URL dependencies must be expressed as direct requirements or constraints. Consider adding `werkzeug @ git+https://github.com/pallets/werkzeug@2.0.0` to your dependencies or constraints file. + error: Package `iniconfig` attempted to resolve via URL: git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4. URL dependencies must be expressed as direct requirements or constraints. Consider adding `iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4` to your dependencies or constraints file. "### ); Ok(()) } -/// Request `transitive_url_dependency`, which depends on `git+https://github.com/pallets/werkzeug@2.0.0`. +/// Request `transitive_url_dependency`, which depends on `https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl`. /// Since this URL is declared as a constraint, we should accept it. #[test] #[cfg(feature = "git")] fn allowed_transitive_url_dependency() -> Result<()> { let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); - requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/14078476/transitive_url_dependency.zip")?; + requirements_in.write_str("hatchling_editable @ ${HATCHLING}")?; let constraints_txt = context.temp_dir.child("constraints.txt"); - constraints_txt.write_str("werkzeug @ git+https://github.com/pallets/werkzeug@2.0.0")?; + constraints_txt.write_str("iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4")?; + let hatchling_path = current_dir()?.join("../../scripts/editable-installs/hatchling_editable"); uv_snapshot!(context.compile() - .arg("requirements.in") - .arg("--constraint") - .arg("constraints.txt"), @r###" + .arg("requirements.in") + .arg("--constraint") + .arg("constraints.txt") + .env("HATCHLING", hatchling_path.as_os_str()), @r###" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --constraint constraints.txt - transitive-url-dependency @ https://github.com/astral-sh/ruff/files/14078476/transitive_url_dependency.zip - werkzeug @ git+https://github.com/pallets/werkzeug@af160e0b6b7ddd81c22f1652c728ff5ac72d5c74 - # via transitive-url-dependency + hatchling-editable @ ${HATCHLING} + iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4 + # via hatchling-editable ----- stderr ----- Resolved 2 packages in [TIME] @@ -1542,31 +1548,34 @@ fn allowed_transitive_url_dependency() -> Result<()> { Ok(()) } -/// Request `transitive_url_dependency`, which depends on `git+https://github.com/pallets/werkzeug@2.0.0`. -/// Since this `git+https://github.com/pallets/werkzeug@2.0.0.git` is declared as a constraint, and +/// Request `transitive_url_dependency`, which depends on `iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4`. +/// Since this `iniconfig @ git+https://github.com/pytest-dev/iniconfig.git@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4.git` is declared as a constraint, and /// those map to the same canonical URL, we should accept it. #[test] #[cfg(feature = "git")] fn allowed_transitive_canonical_url_dependency() -> Result<()> { let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); - requirements_in.write_str("transitive_url_dependency @ https://github.com/astral-sh/ruff/files/14078476/transitive_url_dependency.zip")?; + requirements_in.write_str("hatchling_editable @ ${HATCHLING}")?; let constraints_txt = context.temp_dir.child("constraints.txt"); - constraints_txt.write_str("werkzeug @ git+https://github.com/pallets/werkzeug.git@2.0.0")?; + constraints_txt.write_str("iniconfig @ git+https://github.com/pytest-dev/iniconfig.git@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4")?; + let hatchling_path = current_dir()?.join("../../scripts/editable-installs/hatchling_editable"); uv_snapshot!(context.compile() - .arg("requirements.in") - .arg("--constraint") - .arg("constraints.txt"), @r###" + .arg("requirements.in") + .arg("--constraint") + .arg("constraints.txt") + .env("HATCHLING", hatchling_path.as_os_str()), @r###" success: true exit_code: 0 ----- stdout ----- # This file was autogenerated by uv via the following command: # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in --constraint constraints.txt - transitive-url-dependency @ https://github.com/astral-sh/ruff/files/14078476/transitive_url_dependency.zip - werkzeug @ git+https://github.com/pallets/werkzeug.git@af160e0b6b7ddd81c22f1652c728ff5ac72d5c74 - # via transitive-url-dependency + hatchling-editable @ ${HATCHLING} + iniconfig @ git+https://github.com/pytest-dev/iniconfig.git@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4 + # via hatchling-editable ----- stderr ----- Resolved 2 packages in [TIME] @@ -2578,7 +2587,7 @@ fn compile_editable_url_requirement() -> Result<()> { # This file was autogenerated by uv via the following command: # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in -e ../../scripts/editable-installs/hatchling_editable - iniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl + iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4 # via hatchling-editable ----- stderr ----- diff --git a/scripts/editable-installs/hatchling_editable/pyproject.toml b/scripts/editable-installs/hatchling_editable/pyproject.toml index 92c4d20c7..7996755f2 100644 --- a/scripts/editable-installs/hatchling_editable/pyproject.toml +++ b/scripts/editable-installs/hatchling_editable/pyproject.toml @@ -14,7 +14,7 @@ authors = [ ] classifiers = [] dependencies = [ - "iniconfig @ https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" + "iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4" ] version = "0.1.0"