mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-15 09:15:00 +00:00
Change "toolchain" to "python" (#4735)
Whew this is a lot. The user-facing changes are: - `uv toolchain` to `uv python` e.g. `uv python find`, `uv python install`, ... - `UV_TOOLCHAIN_DIR` to` UV_PYTHON_INSTALL_DIR` - `<UV_STATE_DIR>/toolchains` to `<UV_STATE_DIR>/python` (with [automatic migration](https://github.com/astral-sh/uv/pull/4735/files#r1663029330)) - User-facing messages no longer refer to toolchains, instead using "Python", "Python versions" or "Python installations" The internal changes are: - `uv-toolchain` crate to `uv-python` - `Toolchain` no longer referenced in type names - Dropped unused `SystemPython` type (previously replaced) - Clarified the type names for "managed Python installations" - (more little things)
This commit is contained in:
parent
60fd98a5e4
commit
dd7da6af5f
105 changed files with 2629 additions and 2603 deletions
43
crates/uv-python/src/prefix.rs
Normal file
43
crates/uv-python/src/prefix.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use pypi_types::Scheme;
|
||||
|
||||
/// A `--prefix` directory into which packages can be installed, separate from a virtual environment
|
||||
/// or system Python interpreter.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Prefix(PathBuf);
|
||||
|
||||
impl Prefix {
|
||||
/// Return the [`Scheme`] for the `--prefix` directory.
|
||||
pub fn scheme(&self, virtualenv: &Scheme) -> Scheme {
|
||||
Scheme {
|
||||
purelib: self.0.join(&virtualenv.purelib),
|
||||
platlib: self.0.join(&virtualenv.platlib),
|
||||
scripts: self.0.join(&virtualenv.scripts),
|
||||
data: self.0.join(&virtualenv.data),
|
||||
include: self.0.join(&virtualenv.include),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return an iterator over the `site-packages` directories inside the environment.
|
||||
pub fn site_packages(&self, virtualenv: &Scheme) -> impl Iterator<Item = PathBuf> {
|
||||
std::iter::once(self.0.join(&virtualenv.purelib))
|
||||
}
|
||||
|
||||
/// Initialize the `--prefix` directory.
|
||||
pub fn init(&self) -> std::io::Result<()> {
|
||||
fs_err::create_dir_all(&self.0)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Return the path to the `--prefix` directory.
|
||||
pub fn root(&self) -> &Path {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PathBuf> for Prefix {
|
||||
fn from(path: PathBuf) -> Self {
|
||||
Self(path)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue