mirror of https://github.com/astral-sh/uv
Fix venv PATH on windows (#1095)
Windows uses `;` instead of `:` to separate `PATH` entries. This pull request switches from manually using `:` to the `std::env` functions. This fixes ``` puffin pip install -e scripts/editable-installs/maturin_editable ``` on windows.
This commit is contained in:
parent
272555e915
commit
035cd81ac8
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! <https://packaging.python.org/en/latest/specifications/source-distribution-format/>
|
//! <https://packaging.python.org/en/latest/specifications/source-distribution-format/>
|
||||||
|
|
||||||
use std::env;
|
use std::ffi::OsString;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::BufRead;
|
use std::io::BufRead;
|
||||||
|
|
@ -10,6 +10,7 @@ use std::path::{Path, PathBuf};
|
||||||
use std::process::Output;
|
use std::process::Output;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{env, iter};
|
||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
use indoc::formatdoc;
|
use indoc::formatdoc;
|
||||||
|
|
@ -90,6 +91,8 @@ pub enum Error {
|
||||||
#[source]
|
#[source]
|
||||||
missing_header_cause: MissingHeaderCause,
|
missing_header_cause: MissingHeaderCause,
|
||||||
},
|
},
|
||||||
|
#[error("Failed to build PATH for build script")]
|
||||||
|
BuildScriptPath(#[source] env::JoinPathsError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -729,12 +732,13 @@ async fn run_python_script(
|
||||||
script: &str,
|
script: &str,
|
||||||
source_tree: &Path,
|
source_tree: &Path,
|
||||||
) -> Result<Output, Error> {
|
) -> Result<Output, Error> {
|
||||||
// `OsString` doesn't impl `Add`
|
// Prepend the venv bin dir to PATH
|
||||||
let mut new_path = venv.bin_dir().into_os_string();
|
let new_path = if let Some(old_path) = env::var_os("PATH") {
|
||||||
if let Some(path) = env::var_os("PATH") {
|
let new_path = iter::once(venv.bin_dir()).chain(env::split_paths(&old_path));
|
||||||
new_path.push(":");
|
env::join_paths(new_path).map_err(Error::BuildScriptPath)?
|
||||||
new_path.push(path);
|
} else {
|
||||||
}
|
OsString::from("")
|
||||||
|
};
|
||||||
Command::new(venv.python_executable())
|
Command::new(venv.python_executable())
|
||||||
.args(["-c", script])
|
.args(["-c", script])
|
||||||
.current_dir(source_tree)
|
.current_dir(source_tree)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue