From 91f421cf970afccf0a206a11e54feb3ca295b2d1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 26 Jan 2024 12:18:15 -0600 Subject: [PATCH] Do not allow `pip compile` scenario tests to discover other Python versions (#1106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In https://github.com/astral-sh/puffin/pull/1040 we broke the pip compile scenarios designed to test failure when a required Python version is not available — resolution succeeded because all of the Python versions were available in CI. Following #1105 we have the ability to isolate tests from Python versions available in the system. Here, we limit the scenarios to only the Python version in the current environment, restoring our ability to test the error messages. With https://github.com/zanieb/packse/pull/95, we will be able to specify scenarios with access to additional system Python versions. This will allow us to include test coverage where resolution can succeed by using a version available elsewhere on the system. See #1111 for this follow-up. --- crates/puffin/tests/pip_compile_scenarios.rs | 53 +++++++++++++------- scripts/scenarios/templates/compile.mustache | 1 + 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/crates/puffin/tests/pip_compile_scenarios.rs b/crates/puffin/tests/pip_compile_scenarios.rs index 110868d04..be8e727a1 100644 --- a/crates/puffin/tests/pip_compile_scenarios.rs +++ b/crates/puffin/tests/pip_compile_scenarios.rs @@ -61,6 +61,7 @@ fn requires_incompatible_python_version_compatible_override() -> Result<()> { .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" success: true exit_code: 0 @@ -70,6 +71,7 @@ fn requires_incompatible_python_version_compatible_override() -> Result<()> { albatross==1.0.0 ----- stderr ----- + warning: The requested Python version 3.11 is not available; 3.9.18 will be used to build dependencies instead. Resolved 1 package in [TIME] "###); }); @@ -121,12 +123,14 @@ fn requires_compatible_python_version_incompatible_override() -> Result<()> { .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" success: false exit_code: 1 ----- stdout ----- ----- stderr ----- + warning: The requested Python version 3.9 is not available; 3.11.7 will be used to build dependencies instead. × No solution found when resolving dependencies: ╰─▶ Because the requested Python version (3.9) does not satisfy Python>=3.10 and albatross==1.0.0 depends on Python>=3.10, we can conclude that albatross==1.0.0 cannot be used. And because you require albatross==1.0.0, we can conclude that the requirements are unsatisfiable. @@ -184,16 +188,17 @@ fn requires_incompatible_python_version_compatible_override_no_wheels() -> Resul .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" - success: true - exit_code: 0 + success: false + exit_code: 1 ----- stdout ----- - # This file was autogenerated by Puffin v[VERSION] via the following command: - # puffin pip compile requirements.in --python-version=3.11 --extra-index-url https://test.pypi.org/simple --cache-dir [CACHE_DIR] - albatross==1.0.0 ----- stderr ----- - Resolved 1 package in [TIME] + warning: The requested Python version 3.11 is not available; 3.9.18 will be used to build dependencies instead. + × No solution found when resolving dependencies: + ╰─▶ Because the current Python version (3.9.18) does not satisfy Python>=3.10 and albatross==1.0.0 depends on Python>=3.10, we can conclude that albatross==1.0.0 cannot be used. + And because you require albatross==1.0.0, we can conclude that the requirements are unsatisfiable. "###); }); @@ -248,16 +253,17 @@ fn requires_incompatible_python_version_compatible_override_no_compatible_wheels .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" - success: true - exit_code: 0 + success: false + exit_code: 1 ----- stdout ----- - # This file was autogenerated by Puffin v[VERSION] via the following command: - # puffin pip compile requirements.in --python-version=3.11 --extra-index-url https://test.pypi.org/simple --cache-dir [CACHE_DIR] - albatross==1.0.0 ----- stderr ----- - Resolved 1 package in [TIME] + warning: The requested Python version 3.11 is not available; 3.9.18 will be used to build dependencies instead. + × No solution found when resolving dependencies: + ╰─▶ Because the current Python version (3.9.18) does not satisfy Python>=3.10 and albatross==1.0.0 depends on Python>=3.10, we can conclude that albatross==1.0.0 cannot be used. + And because you require albatross==1.0.0, we can conclude that the requirements are unsatisfiable. "###); }); @@ -317,16 +323,25 @@ fn requires_incompatible_python_version_compatible_override_other_wheel() -> Res .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" - success: true - exit_code: 0 + success: false + exit_code: 1 ----- stdout ----- - # This file was autogenerated by Puffin v[VERSION] via the following command: - # puffin pip compile requirements.in --python-version=3.11 --extra-index-url https://test.pypi.org/simple --cache-dir [CACHE_DIR] - albatross==1.0.0 ----- stderr ----- - Resolved 1 package in [TIME] + warning: The requested Python version 3.11 is not available; 3.9.18 will be used to build dependencies instead. + × No solution found when resolving dependencies: + ╰─▶ Because the current Python version (3.9.18) does not satisfy Python>=3.10 and albatross==1.0.0 depends on Python>=3.10, we can conclude that albatross==1.0.0 cannot be used. + And because there are no versions of albatross that satisfy any of: + albatross<1.0.0 + albatross>1.0.0,<2.0.0 + albatross>2.0.0 + we can conclude that albatross<2.0.0 cannot be used. (1) + + Because the requested Python version (3.11) does not satisfy Python>=3.12 and albatross==2.0.0 depends on Python>=3.12, we can conclude that albatross==2.0.0 cannot be used. + And because we know from (1) that albatross<2.0.0 cannot be used, we can conclude that all versions of albatross cannot be used. + And because you require albatross, we can conclude that the requirements are unsatisfiable. "###); }); @@ -379,6 +394,7 @@ fn requires_python_patch_version_override_no_patch() -> Result<()> { .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" success: false exit_code: 1 @@ -438,6 +454,7 @@ fn requires_python_patch_version_override_patch_compatible() -> Result<()> { .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" success: true exit_code: 0 diff --git a/scripts/scenarios/templates/compile.mustache b/scripts/scenarios/templates/compile.mustache index 44e004feb..45aab4b08 100644 --- a/scripts/scenarios/templates/compile.mustache +++ b/scripts/scenarios/templates/compile.mustache @@ -69,6 +69,7 @@ fn {{module_name}}() -> Result<()> { .arg(cache_dir.path()) .env("VIRTUAL_ENV", venv.as_os_str()) .env("PUFFIN_NO_WRAP", "1") + .env("PUFFIN_PYTHON_PATH", "") .current_dir(&temp_dir), @r###" "###); });