mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-13 14:06:22 +00:00
Allow apostrophe in venv name (#8984)
Escape an apostrophe in the venv path name. Fixes #8947
This commit is contained in:
parent
0abb2a4595
commit
997ff9d57a
4 changed files with 62 additions and 9 deletions
|
@ -13,6 +13,7 @@ use tracing::debug;
|
|||
use uv_fs::{cachedir, Simplified, CWD};
|
||||
use uv_pypi_types::Scheme;
|
||||
use uv_python::{Interpreter, VirtualEnvironment};
|
||||
use uv_shell::escape_posix_for_single_quotes;
|
||||
use uv_version::version;
|
||||
|
||||
use crate::{Error, Prompt};
|
||||
|
@ -287,23 +288,20 @@ pub(crate) fn create(
|
|||
|
||||
let virtual_env_dir = match (relocatable, name.to_owned()) {
|
||||
(true, "activate") => {
|
||||
r#"'"$(dirname -- "$(dirname -- "$(realpath -- "$SCRIPT_PATH")")")"'"#
|
||||
r#"'"$(dirname -- "$(dirname -- "$(realpath -- "$SCRIPT_PATH")")")"'"#.to_string()
|
||||
}
|
||||
(true, "activate.bat") => r"%~dp0..",
|
||||
(true, "activate.bat") => r"%~dp0..".to_string(),
|
||||
(true, "activate.fish") => {
|
||||
r#"'"$(dirname -- "$(cd "$(dirname -- "$(status -f)")"; and pwd)")"'"#
|
||||
r#"'"$(dirname -- "$(cd "$(dirname -- "$(status -f)")"; and pwd)")"'"#.to_string()
|
||||
}
|
||||
// Note:
|
||||
// * relocatable activate scripts appear not to be possible in csh and nu shell
|
||||
// * `activate.ps1` is already relocatable by default.
|
||||
_ => {
|
||||
// SAFETY: `unwrap` is guaranteed to succeed because `location` is an `Utf8PathBuf`.
|
||||
location.simplified().to_str().unwrap()
|
||||
}
|
||||
_ => escape_posix_for_single_quotes(location.simplified().to_str().unwrap()),
|
||||
};
|
||||
|
||||
let activator = template
|
||||
.replace("{{ VIRTUAL_ENV_DIR }}", virtual_env_dir)
|
||||
.replace("{{ VIRTUAL_ENV_DIR }}", &virtual_env_dir)
|
||||
.replace("{{ BIN_NAME }}", bin_name)
|
||||
.replace(
|
||||
"{{ VIRTUAL_PROMPT }}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue