Remove platform-tags dependency on puffin-interpreter (#725)

Cuts off a large internal dependency chain from what is otherwise a very
general crate.
This commit is contained in:
Charlie Marsh
2023-12-24 18:06:50 -05:00
committed by GitHub
parent ad34bb02a9
commit 5b2e381f87
11 changed files with 21 additions and 19 deletions
Generated
+1 -1
View File
@@ -2127,7 +2127,6 @@ version = "0.0.1"
dependencies = [
"anyhow",
"platform-host",
"puffin-interpreter",
"rustc-hash",
]
@@ -2599,6 +2598,7 @@ dependencies = [
"pep440_rs 0.3.12",
"pep508_rs",
"platform-host",
"platform-tags",
"puffin-cache",
"puffin-fs",
"rmp-serde",
-1
View File
@@ -14,7 +14,6 @@ workspace = true
[dependencies]
platform-host = { path = "../platform-host" }
puffin-interpreter = { path = "../puffin-interpreter" }
anyhow = { workspace = true }
rustc-hash = { workspace = true }
-5
View File
@@ -4,7 +4,6 @@ use anyhow::{Error, Result};
use rustc_hash::FxHashMap;
use platform_host::{Arch, Os, Platform, PlatformError};
use puffin_interpreter::Interpreter;
/// A set of compatible tags for a given Python version and platform.
///
@@ -34,10 +33,6 @@ impl Tags {
Self { map }
}
pub fn from_interpreter(interpreter: &Interpreter) -> Result<Self, PlatformError> {
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<Self, PlatformError> {
let platform_tags = compatible_tags(platform)?;
@@ -16,7 +16,7 @@ use tracing::debug;
use distribution_types::LocalEditable;
use pep508_rs::Requirement;
use platform_host::Platform;
use platform_tags::Tags;
use puffin_cache::Cache;
use puffin_client::RegistryClientBuilder;
use puffin_dispatch::BuildDispatch;
@@ -126,7 +126,7 @@ pub(crate) async fn pip_compile(
// Determine the tags, markers, and interpreter to use for resolution.
let interpreter = venv.interpreter().clone();
let tags = Tags::from_interpreter(venv.interpreter())?;
let tags = venv.interpreter().tags()?;
let markers = python_version.map_or_else(
|| Cow::Borrowed(venv.interpreter().markers()),
|python_version| Cow::Owned(python_version.markers(venv.interpreter().markers())),
@@ -123,7 +123,7 @@ pub(crate) async fn pip_install(
// Determine the tags, markers, and interpreter to use for resolution.
let interpreter = venv.interpreter().clone();
let tags = Tags::from_interpreter(venv.interpreter())?;
let tags = venv.interpreter().tags()?;
let markers = venv.interpreter().markers();
// Instantiate a client.
+1 -1
View File
@@ -54,7 +54,7 @@ pub(crate) async fn pip_sync(
let _lock = venv.lock()?;
// Determine the current environment markers.
let tags = Tags::from_interpreter(venv.interpreter())?;
let tags = venv.interpreter().tags()?;
// Prep the registry client.
let client = RegistryClientBuilder::new(cache.clone())
+1 -1
View File
@@ -58,7 +58,7 @@ pub(crate) async fn install_many(args: InstallManyArgs) -> Result<()> {
let venv = Virtualenv::from_env(platform, &cache)?;
let client = RegistryClientBuilder::new(cache.clone()).build();
let index_urls = IndexUrls::default();
let tags = Tags::from_interpreter(venv.interpreter())?;
let tags = venv.interpreter().tags()?;
let build_dispatch = BuildDispatch::new(
&client,
&cache,
+2 -2
View File
@@ -12,7 +12,7 @@ use petgraph::dot::{Config as DotConfig, Dot};
use pep508_rs::Requirement;
use platform_host::Platform;
use platform_tags::Tags;
use puffin_cache::{Cache, CacheArgs};
use puffin_client::RegistryClientBuilder;
use puffin_dispatch::BuildDispatch;
@@ -63,7 +63,7 @@ pub(crate) async fn resolve_cli(args: ResolveCliArgs) -> Result<()> {
);
// Copied from `BuildDispatch`
let tags = Tags::from_interpreter(venv.interpreter())?;
let tags = venv.interpreter().tags()?;
let resolver = Resolver::new(
Manifest::simple(args.requirements.clone()),
ResolutionOptions::default(),
+5 -4
View File
@@ -12,7 +12,7 @@ use tracing::{debug, instrument};
use distribution_types::{CachedDist, Name, Resolution};
use pep508_rs::Requirement;
use platform_tags::Tags;
use puffin_build::{SourceBuild, SourceBuildContext};
use puffin_cache::Cache;
use puffin_client::RegistryClient;
@@ -90,11 +90,12 @@ impl<'a> BuildContext for BuildDispatch<'a> {
requirements: &'data [Requirement],
) -> Pin<Box<dyn Future<Output = Result<Resolution>> + Send + 'data>> {
Box::pin(async {
let tags = Tags::from_interpreter(self.interpreter)?;
let markers = self.interpreter.markers();
let tags = self.interpreter.tags()?;
let resolver = Resolver::new(
Manifest::simple(requirements.to_vec()),
self.options,
self.interpreter.markers(),
markers,
&tags,
self.client,
self,
@@ -132,7 +133,7 @@ impl<'a> BuildContext for BuildDispatch<'a> {
);
// Determine the current environment markers.
let tags = Tags::from_interpreter(self.interpreter)?;
let tags = self.interpreter.tags()?;
// Determine the set of installed packages.
let site_packages =
+1
View File
@@ -16,6 +16,7 @@ workspace = true
pep440_rs = { path = "../pep440-rs" }
pep508_rs = { path = "../pep508-rs", features = ["serde"] }
platform-host = { path = "../platform-host" }
platform-tags = { path = "../platform-tags" }
puffin-cache = { path = "../puffin-cache" }
puffin-fs = { path = "../puffin-fs" }
+7 -1
View File
@@ -7,7 +7,8 @@ use tracing::{debug, warn};
use pep440_rs::Version;
use pep508_rs::MarkerEnvironment;
use platform_host::Platform;
use platform_host::{Platform, PlatformError};
use platform_tags::Tags;
use puffin_cache::CachedByTimestamp;
use puffin_cache::{digest, Cache, CacheBucket};
use puffin_fs::write_atomic_sync;
@@ -74,6 +75,11 @@ impl Interpreter {
&self.markers
}
/// Returns the [`Tags`] for this Python executable.
pub fn tags(&self) -> Result<Tags, PlatformError> {
Tags::from_env(self.platform(), self.simple_version())
}
/// Returns the Python version.
pub fn version(&self) -> &Version {
&self.markers.python_full_version.version