mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-01 00:07:29 +00:00
feat(venv): add relocatable flag (#5515)
## Summary Adds a `--relocatable` CLI arg to `uv venv`. This flag does two things: * ensures that the associated activation scripts do not rely on a hardcoded absolute path to the virtual environment (to the extent possible; `.csh` and `.nu` left as-is) * persists a `relocatable` flag in `pyvenv.cfg`. The flag in `pyvenv.cfg` in turn instructs the wheel `Installer` to create script entrypoints in a relocatable way (use `exec` trick + `dirname $0` on POSIX; use relative path to `python[w].exe` on Windows). Fixes: #3863 ## Test Plan * Relocatable console scripts covered as additional scenarios in existing test cases. * Integration testing of boilerplate generation in `venv`. * Manual testing of `uv venv` with and without `--relocatable`
This commit is contained in:
parent
3626d08cca
commit
cb47aed9de
20 changed files with 299 additions and 26 deletions
|
@ -162,6 +162,11 @@ impl PythonEnvironment {
|
|||
Ok(PyVenvConfiguration::parse(self.0.root.join("pyvenv.cfg"))?)
|
||||
}
|
||||
|
||||
/// Returns `true` if the environment is "relocatable".
|
||||
pub fn relocatable(&self) -> bool {
|
||||
self.cfg().is_ok_and(|cfg| cfg.is_relocatable())
|
||||
}
|
||||
|
||||
/// Returns the location of the Python executable.
|
||||
pub fn python_executable(&self) -> &Path {
|
||||
self.0.interpreter.sys_executable()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue