Centralize virtualenv path construction (#2102)

## Summary

Right now, we have virtualenv construction encoded in a few different
places. Namely, it happens in both `gourgeist` and
`virtualenv_layout.rs` -- _and_ `interpreter.rs` also encodes some
knowledge about how they work, by way of reconstructing the
`SysconfigPaths`.

Instead, `gourgeist` now returns the complete layout, enumerating all
the directories it created. So, rather than returning a root directory,
and re-creating all those paths in `uv-interpreter`, we pass the data
directly back to it.
This commit is contained in:
Charlie Marsh 2024-03-01 10:52:48 -05:00 committed by GitHub
parent c579e6f6bf
commit c9ffe976f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 159 additions and 207 deletions

View file

@ -9,20 +9,21 @@ pub use crate::interpreter::Interpreter;
pub use crate::python_environment::PythonEnvironment;
pub use crate::python_query::{find_default_python, find_requested_python};
pub use crate::python_version::PythonVersion;
pub use crate::sysconfig::SysconfigPaths;
pub use crate::virtualenv::Virtualenv;
mod cfg;
mod interpreter;
mod python_environment;
mod python_query;
mod python_version;
mod virtualenv_layout;
mod sysconfig;
mod virtualenv;
#[derive(Debug, Error)]
pub enum Error {
#[error("Expected `{0}` to be a virtualenv, but pyvenv.cfg is missing")]
#[error("Expected `{0}` to be a virtualenv, but `pyvenv.cfg` is missing")]
MissingPyVenvCfg(PathBuf),
#[error("Broken virtualenv `{0}`, it contains a pyvenv.cfg but no Python binary at `{1}`")]
BrokenVenv(PathBuf, PathBuf),
#[error("Both VIRTUAL_ENV and CONDA_PREFIX are set. Please unset one of them.")]
Conflict,
#[error("No versions of Python could be found. Is Python installed?")]