From fa3107b173e65e4e81ad7ad3f8bc781bbf0a8efa Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 3 Dec 2023 20:02:24 -0500 Subject: [PATCH] Use full Python version when determining compatibility (#528) ## Summary When resolving with Python 3.7.13, I was failing to find a matching distribution that required Python 3.7.9 or later. --- crates/puffin-cli/tests/snapshots/venv__create_venv.snap | 4 ++-- .../tests/snapshots/venv__create_venv_defaults_to_cwd.snap | 2 +- crates/puffin-cli/tests/venv.rs | 4 ++-- crates/puffin-interpreter/src/interpreter.rs | 2 +- crates/puffin-resolver/src/finder.rs | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/puffin-cli/tests/snapshots/venv__create_venv.snap b/crates/puffin-cli/tests/snapshots/venv__create_venv.snap index b466acb64..7fc8f07b7 100644 --- a/crates/puffin-cli/tests/snapshots/venv__create_venv.snap +++ b/crates/puffin-cli/tests/snapshots/venv__create_venv.snap @@ -4,7 +4,7 @@ info: program: puffin args: - venv - - /var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmprOsp0M/.venv + - /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpINXhJh/.venv - "--python" - python3.12 --- @@ -13,6 +13,6 @@ exit_code: 0 ----- stdout ----- ----- stderr ----- -Using Python 3.11 at [PATH] +Using Python [VERSION] at [PATH] Creating virtual environment at: /home/ferris/project/.venv diff --git a/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap b/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap index 0d15f43be..b18963c19 100644 --- a/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap +++ b/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap @@ -12,6 +12,6 @@ exit_code: 0 ----- stdout ----- ----- stderr ----- -Using Python 3.11 at [PATH] +Using Python [VERSION] at [PATH] Creating virtual environment at: .venv diff --git a/crates/puffin-cli/tests/venv.rs b/crates/puffin-cli/tests/venv.rs index d8ec55842..9ee709d0a 100644 --- a/crates/puffin-cli/tests/venv.rs +++ b/crates/puffin-cli/tests/venv.rs @@ -18,7 +18,7 @@ fn create_venv() -> Result<()> { insta::with_settings!({ filters => vec![ - (r"Using Python 3.12 at .+", "Using Python 3.11 at [PATH]"), + (r"Using Python 3\.\d+\.\d+ at .+", "Using Python [VERSION] at [PATH]"), (temp_dir.to_str().unwrap(), "/home/ferris/project"), ] }, { @@ -42,7 +42,7 @@ fn create_venv_defaults_to_cwd() -> Result<()> { insta::with_settings!({ filters => vec![ - (r"Using Python 3.12 at .+", "Using Python 3.11 at [PATH]"), + (r"Using Python 3\.\d+\.\d+ at .+", "Using Python [VERSION] at [PATH]"), (temp_dir.to_str().unwrap(), "/home/ferris/project"), ] }, { diff --git a/crates/puffin-interpreter/src/interpreter.rs b/crates/puffin-interpreter/src/interpreter.rs index 017316331..0a34839ef 100644 --- a/crates/puffin-interpreter/src/interpreter.rs +++ b/crates/puffin-interpreter/src/interpreter.rs @@ -75,7 +75,7 @@ impl Interpreter { /// Returns the Python version. pub fn version(&self) -> &Version { - &self.markers.python_version.version + &self.markers.python_full_version.version } /// Returns the Python version as a simple tuple. diff --git a/crates/puffin-resolver/src/finder.rs b/crates/puffin-resolver/src/finder.rs index a918efea7..b8659f400 100644 --- a/crates/puffin-resolver/src/finder.rs +++ b/crates/puffin-resolver/src/finder.rs @@ -149,11 +149,11 @@ impl<'a> DistFinder<'a> { // compatibility and wheels which may be tagged `py3-none-any` but // have `requires-python: ">=3.9"` // TODO(konstin): https://github.com/astral-sh/puffin/issues/406 - if !file + if file .requires_python .as_ref() - .map_or(true, |requires_python| { - requires_python.contains(self.interpreter.version()) + .is_some_and(|requires_python| { + !requires_python.contains(self.interpreter.version()) }) { continue;