mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Initialize all --prefix
subdirectories (#4895)
## Summary We need to initialize the same directories that we create in `bare.rs`, since the installer expects them to exist. Closes #4892.
This commit is contained in:
parent
2d651fe264
commit
b9d661012d
7 changed files with 26 additions and 36 deletions
|
@ -127,23 +127,21 @@ impl PythonEnvironment {
|
|||
}
|
||||
|
||||
/// Create a [`PythonEnvironment`] from an existing [`Interpreter`] and `--target` directory.
|
||||
#[must_use]
|
||||
pub fn with_target(self, target: Target) -> Self {
|
||||
pub fn with_target(self, target: Target) -> std::io::Result<Self> {
|
||||
let inner = Arc::unwrap_or_clone(self.0);
|
||||
Self(Arc::new(PythonEnvironmentShared {
|
||||
interpreter: inner.interpreter.with_target(target),
|
||||
Ok(Self(Arc::new(PythonEnvironmentShared {
|
||||
interpreter: inner.interpreter.with_target(target)?,
|
||||
..inner
|
||||
}))
|
||||
})))
|
||||
}
|
||||
|
||||
/// Create a [`PythonEnvironment`] from an existing [`Interpreter`] and `--prefix` directory.
|
||||
#[must_use]
|
||||
pub fn with_prefix(self, prefix: Prefix) -> Self {
|
||||
pub fn with_prefix(self, prefix: Prefix) -> std::io::Result<Self> {
|
||||
let inner = Arc::unwrap_or_clone(self.0);
|
||||
Self(Arc::new(PythonEnvironmentShared {
|
||||
interpreter: inner.interpreter.with_prefix(prefix),
|
||||
Ok(Self(Arc::new(PythonEnvironmentShared {
|
||||
interpreter: inner.interpreter.with_prefix(prefix)?,
|
||||
..inner
|
||||
}))
|
||||
})))
|
||||
}
|
||||
|
||||
/// Returns the root (i.e., `prefix`) of the Python interpreter.
|
||||
|
|
|
@ -124,21 +124,21 @@ impl Interpreter {
|
|||
}
|
||||
|
||||
/// Return a new [`Interpreter`] to install into the given `--target` directory.
|
||||
#[must_use]
|
||||
pub fn with_target(self, target: Target) -> Self {
|
||||
Self {
|
||||
pub fn with_target(self, target: Target) -> io::Result<Self> {
|
||||
target.init()?;
|
||||
Ok(Self {
|
||||
target: Some(target),
|
||||
..self
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Return a new [`Interpreter`] to install into the given `--prefix` directory.
|
||||
#[must_use]
|
||||
pub fn with_prefix(self, prefix: Prefix) -> Self {
|
||||
Self {
|
||||
pub fn with_prefix(self, prefix: Prefix) -> io::Result<Self> {
|
||||
prefix.init(self.virtualenv())?;
|
||||
Ok(Self {
|
||||
prefix: Some(prefix),
|
||||
..self
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the [`Interpreter`] for the base executable, if it's available.
|
||||
|
|
|
@ -25,8 +25,10 @@ impl Prefix {
|
|||
}
|
||||
|
||||
/// Initialize the `--prefix` directory.
|
||||
pub fn init(&self) -> std::io::Result<()> {
|
||||
fs_err::create_dir_all(&self.0)?;
|
||||
pub fn init(&self, virtualenv: &Scheme) -> std::io::Result<()> {
|
||||
for site_packages in self.site_packages(virtualenv) {
|
||||
fs_err::create_dir_all(site_packages)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue