Use local package instead of `transitive_url_dependency.zip` (#2396)

This commit is contained in:
Charlie Marsh 2024-03-12 15:56:00 -07:00 committed by GitHub
parent 90a60bc4f2
commit 3bf20f95e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 26 deletions

View File

@ -1486,53 +1486,59 @@ fn incompatible_narrowed_url_dependency() -> Result<()> {
Ok(()) 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. /// Since this URL isn't declared upfront, we should reject it.
#[test] #[test]
#[cfg(feature = "git")] #[cfg(feature = "git")]
fn disallowed_transitive_url_dependency() -> Result<()> { fn disallowed_transitive_url_dependency() -> Result<()> {
let context = TestContext::new("3.12"); 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() uv_snapshot!(context.compile()
.arg("requirements.in"), @r###" .arg("requirements.in")
.env("HATCHLING", hatchling_path.as_os_str()), @r###"
success: false success: false
exit_code: 2 exit_code: 2
----- stdout ----- ----- stdout -----
----- stderr ----- ----- 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(()) 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. /// Since this URL is declared as a constraint, we should accept it.
#[test] #[test]
#[cfg(feature = "git")] #[cfg(feature = "git")]
fn allowed_transitive_url_dependency() -> Result<()> { fn allowed_transitive_url_dependency() -> Result<()> {
let context = TestContext::new("3.12"); let context = TestContext::new("3.12");
let requirements_in = context.temp_dir.child("requirements.in"); 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"); 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() uv_snapshot!(context.compile()
.arg("requirements.in") .arg("requirements.in")
.arg("--constraint") .arg("--constraint")
.arg("constraints.txt"), @r###" .arg("constraints.txt")
.env("HATCHLING", hatchling_path.as_os_str()), @r###"
success: true success: true
exit_code: 0 exit_code: 0
----- stdout ----- ----- stdout -----
# This file was autogenerated by uv via the following command: # 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 # 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 hatchling-editable @ ${HATCHLING}
werkzeug @ git+https://github.com/pallets/werkzeug@af160e0b6b7ddd81c22f1652c728ff5ac72d5c74 iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4
# via transitive-url-dependency # via hatchling-editable
----- stderr ----- ----- stderr -----
Resolved 2 packages in [TIME] Resolved 2 packages in [TIME]
@ -1542,31 +1548,34 @@ fn allowed_transitive_url_dependency() -> Result<()> {
Ok(()) Ok(())
} }
/// Request `transitive_url_dependency`, which depends on `git+https://github.com/pallets/werkzeug@2.0.0`. /// Request `transitive_url_dependency`, which depends on `iniconfig @ git+https://github.com/pytest-dev/iniconfig@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4`.
/// Since this `git+https://github.com/pallets/werkzeug@2.0.0.git` is declared as a constraint, and /// 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. /// those map to the same canonical URL, we should accept it.
#[test] #[test]
#[cfg(feature = "git")] #[cfg(feature = "git")]
fn allowed_transitive_canonical_url_dependency() -> Result<()> { fn allowed_transitive_canonical_url_dependency() -> Result<()> {
let context = TestContext::new("3.12"); let context = TestContext::new("3.12");
let requirements_in = context.temp_dir.child("requirements.in"); 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"); 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() uv_snapshot!(context.compile()
.arg("requirements.in") .arg("requirements.in")
.arg("--constraint") .arg("--constraint")
.arg("constraints.txt"), @r###" .arg("constraints.txt")
.env("HATCHLING", hatchling_path.as_os_str()), @r###"
success: true success: true
exit_code: 0 exit_code: 0
----- stdout ----- ----- stdout -----
# This file was autogenerated by uv via the following command: # 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 # 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 hatchling-editable @ ${HATCHLING}
werkzeug @ git+https://github.com/pallets/werkzeug.git@af160e0b6b7ddd81c22f1652c728ff5ac72d5c74 iniconfig @ git+https://github.com/pytest-dev/iniconfig.git@9cae43103df70bac6fde7b9f35ad11a9f1be0cb4
# via transitive-url-dependency # via hatchling-editable
----- stderr ----- ----- stderr -----
Resolved 2 packages in [TIME] 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: # 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 # uv pip compile --cache-dir [CACHE_DIR] --exclude-newer 2023-11-18T12:00:00Z requirements.in
-e ../../scripts/editable-installs/hatchling_editable -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 # via hatchling-editable
----- stderr ----- ----- stderr -----

View File

@ -14,7 +14,7 @@ authors = [
] ]
classifiers = [] classifiers = []
dependencies = [ 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" version = "0.1.0"