Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions crates/uv-virtualenv/src/virtualenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,13 @@ pub(crate) fn create(

// Add all the activate scripts for different shells
for (name, template) in ACTIVATE_TEMPLATES {
// csh has no way to determine its own script location, so a relocatable
// activate.csh is not possible. Skip it entirely instead of generating a
// non-functional script.
if relocatable && *name == "activate.csh" {
continue;
}

let path_sep = if cfg!(windows) { ";" } else { ":" };

let relative_site_packages = [
Expand Down Expand Up @@ -477,9 +484,7 @@ pub(crate) fn create(
escape_posix_for_single_quotes(location.simplified().to_str().unwrap())
)
}
// Note:
// * relocatable activate scripts appear not to be possible in csh.
// * `activate.ps1` is already relocatable by default.
// Note: `activate.ps1` is already relocatable by default.
_ => escape_posix_for_single_quotes(location.simplified().to_str().unwrap()),
};

Expand Down
5 changes: 5 additions & 0 deletions crates/uv/tests/it/venv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,11 @@ fn verify_pyvenv_cfg_relocatable() {
activate_nu.assert(predicates::str::contains(
r"let virtual_env = (path self | path dirname | path dirname)",
));

// csh cannot determine its own script location, so activate.csh should not
// be generated when --relocatable is used.
let activate_csh = scripts.child("activate.csh");
activate_csh.assert(predicates::path::missing());
}

/// Ensure that a nested virtual environment uses the same `home` directory as the parent.
Expand Down
Loading