mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Unify python interpreter abstractions (#178)
Previously, we had two python interpreter metadata structs, one in gourgeist and one in puffin. Both would spawn a subprocess to query overlapping metadata and both would appear in the cli crate, if you weren't careful you could even have to different base interpreters at once. This change unifies this to one set of metadata, queried and cached once. Another effect of this crate is proper separation of python interpreter and venv. A base interpreter (such as `/usr/bin/python/`, but also pyenv and conda installed python) has a set of metadata. A venv has a root and inherits the base python metadata except for `sys.prefix`, which unlike `sys.base_prefix`, gets set to the venv root. From the root and the interpreter info we can compute the paths inside the venv. We can reuse the interpreter info of the base interpreter when creating a venv without having to query the newly created `python`.
This commit is contained in:
parent
1fbe328257
commit
889f6173cc
37 changed files with 515 additions and 584 deletions
|
@ -10,7 +10,6 @@ authors = { workspace = true }
|
|||
license = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
gourgeist = { path = "../gourgeist" }
|
||||
install-wheel-rs = { path = "../install-wheel-rs" }
|
||||
pep440_rs = { path = "../pep440-rs" }
|
||||
pep508_rs = { path = "../pep508-rs" }
|
||||
|
@ -39,10 +38,10 @@ tokio-util = { workspace = true, features = ["compat"] }
|
|||
tracing = { workspace = true }
|
||||
url = { workspace = true }
|
||||
waitmap = { workspace = true }
|
||||
which = { workspace = true }
|
||||
zip = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
gourgeist = { path = "../gourgeist" }
|
||||
puffin-interpreter = { path = "../puffin-interpreter" }
|
||||
|
||||
once_cell = { version = "1.18.0" }
|
||||
|
|
|
@ -9,14 +9,13 @@ use std::pin::Pin;
|
|||
use std::str::FromStr;
|
||||
|
||||
use anyhow::Result;
|
||||
use gourgeist::Venv;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use pep508_rs::{MarkerEnvironment, Requirement, StringVersion};
|
||||
use platform_host::{Arch, Os, Platform};
|
||||
use platform_tags::Tags;
|
||||
use puffin_client::RegistryClientBuilder;
|
||||
use puffin_interpreter::PythonExecutable;
|
||||
use puffin_interpreter::{InterpreterInfo, Virtualenv};
|
||||
use puffin_resolver::{ResolutionMode, Resolver};
|
||||
use puffin_traits::BuildContext;
|
||||
|
||||
|
@ -27,7 +26,11 @@ impl BuildContext for DummyContext {
|
|||
panic!("The test should not need to build source distributions")
|
||||
}
|
||||
|
||||
fn python(&self) -> &PythonExecutable {
|
||||
fn interpreter_info(&self) -> &InterpreterInfo {
|
||||
panic!("The test should not need to build source distributions")
|
||||
}
|
||||
|
||||
fn base_python(&self) -> &Path {
|
||||
panic!("The test should not need to build source distributions")
|
||||
}
|
||||
|
||||
|
@ -41,7 +44,7 @@ impl BuildContext for DummyContext {
|
|||
fn install<'a>(
|
||||
&'a self,
|
||||
_requirements: &'a [Requirement],
|
||||
_venv: &'a Venv,
|
||||
_venv: &'a Virtualenv,
|
||||
) -> Pin<Box<dyn Future<Output = Result<()>> + 'a>> {
|
||||
panic!("The test should not need to build source distributions")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue