diff --git a/Cargo.lock b/Cargo.lock index 938d6eb90..afe55b367 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2208,6 +2208,7 @@ dependencies = [ "anyhow", "fxhash", "platform-host", + "puffin-interpreter", ] [[package]] diff --git a/crates/platform-tags/Cargo.toml b/crates/platform-tags/Cargo.toml index 28cfd899d..365a78458 100644 --- a/crates/platform-tags/Cargo.toml +++ b/crates/platform-tags/Cargo.toml @@ -14,6 +14,7 @@ workspace = true [dependencies] platform-host = { path = "../platform-host" } +puffin-interpreter = { path = "../puffin-interpreter" } anyhow = { workspace = true } fxhash = { workspace = true } diff --git a/crates/platform-tags/src/lib.rs b/crates/platform-tags/src/lib.rs index f72356f9c..9e945a4ba 100644 --- a/crates/platform-tags/src/lib.rs +++ b/crates/platform-tags/src/lib.rs @@ -4,6 +4,7 @@ use anyhow::{Error, Result}; use fxhash::FxHashMap; use platform_host::{Arch, Os, Platform, PlatformError}; +use puffin_interpreter::Interpreter; /// A set of compatible tags for a given Python version and platform. /// @@ -33,6 +34,10 @@ impl Tags { Self { map } } + pub fn from_interpreter(interpreter: &Interpreter) -> Result { + Self::from_env(interpreter.platform(), interpreter.simple_version()) + } + /// Returns the compatible tags for the given Python version and platform. pub fn from_env(platform: &Platform, python_version: (u8, u8)) -> Result { let platform_tags = compatible_tags(platform)?; diff --git a/crates/puffin-cli/src/commands/pip_compile.rs b/crates/puffin-cli/src/commands/pip_compile.rs index 49b7aa0d2..8bcbea899 100644 --- a/crates/puffin-cli/src/commands/pip_compile.rs +++ b/crates/puffin-cli/src/commands/pip_compile.rs @@ -121,10 +121,7 @@ pub(crate) async fn pip_compile( ); // Determine the compatible platform tags. - let tags = Tags::from_env( - venv.interpreter().platform(), - venv.interpreter().simple_version(), - )?; + let tags = Tags::from_interpreter(venv.interpreter())?; // Determine the markers to use for resolution. let markers = python_version.map_or_else( diff --git a/crates/puffin-cli/src/commands/pip_sync.rs b/crates/puffin-cli/src/commands/pip_sync.rs index 20edee451..d7e144c4a 100644 --- a/crates/puffin-cli/src/commands/pip_sync.rs +++ b/crates/puffin-cli/src/commands/pip_sync.rs @@ -104,10 +104,7 @@ pub(crate) async fn sync_requirements( } // Determine the current environment markers. - let tags = Tags::from_env( - venv.interpreter().platform(), - venv.interpreter().simple_version(), - )?; + let tags = Tags::from_interpreter(venv.interpreter())?; // Instantiate a client. let client = { diff --git a/crates/puffin-dev/src/resolve_cli.rs b/crates/puffin-dev/src/resolve_cli.rs index 407ec04de..b4f8e14e0 100644 --- a/crates/puffin-dev/src/resolve_cli.rs +++ b/crates/puffin-dev/src/resolve_cli.rs @@ -56,10 +56,7 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> { ); // Copied from `BuildDispatch` - let tags = Tags::from_env( - venv.interpreter().platform(), - venv.interpreter().simple_version(), - )?; + let tags = Tags::from_interpreter(venv.interpreter())?; let resolver = Resolver::new( Manifest::new( args.requirements.clone(), diff --git a/crates/puffin-dispatch/src/lib.rs b/crates/puffin-dispatch/src/lib.rs index 342f4c796..baabfc07a 100644 --- a/crates/puffin-dispatch/src/lib.rs +++ b/crates/puffin-dispatch/src/lib.rs @@ -82,10 +82,7 @@ impl BuildContext for BuildDispatch { requirements: &'a [Requirement], ) -> Pin>> + Send + 'a>> { Box::pin(async { - let tags = Tags::from_env( - self.interpreter.platform(), - self.interpreter.simple_version(), - )?; + let tags = Tags::from_interpreter(&self.interpreter)?; let resolver = Resolver::new( Manifest::new(requirements.to_vec(), Vec::default(), Vec::default(), None), self.options, @@ -123,10 +120,7 @@ impl BuildContext for BuildDispatch { extraneous, } = InstallPlan::try_from_requirements(requirements, &self.cache, venv)?; - let tags = Tags::from_env( - self.interpreter.platform(), - self.interpreter.simple_version(), - )?; + let tags = Tags::from_interpreter(&self.interpreter)?; // Resolve the dependencies. let remote = if remote.is_empty() {