Do not allow `pip compile` scenario tests to discover other Python versions (#1106)

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.
This commit is contained in:
Zanie Blue 2024-01-26 12:18:15 -06:00 committed by GitHub
parent 21577ad002
commit 91f421cf97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 18 deletions

View File

@ -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

View File

@ -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###"<snapshot>
"###);
});