mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-15 17:25:01 +00:00
Respect include-system-site-packages
in layered environments (#11873)
## Summary We use a similar strategy to the ephemeral overlay: set `include-system-site-packages` in the `pyvenv.cfg`, and clear it whenever we access a new environment. Closes https://github.com/astral-sh/uv/issues/11829. ## Test Plan Difficult to test because we don't really have support for system packages in our test infrastructure. But... ``` > uv venv --system-site-packages > ['', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python313.zip', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/lib-dynload', '/Users/crmarsh/.cache/uv/archive-v0/AhKcORkaCdbBl31VweRtG/lib/python3.13/site-packages', '/Users/crmarsh/workspace/uv/foo/.venv/lib/python3.13/site-packages', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/site-packages'] ``` ``` > uv venv > ['', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python313.zip', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13', '/Users/crmarsh/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/lib-dynload', '/Users/crmarsh/.cache/uv/archive-v0/AhKcORkaCdbBl31VweRtG/lib/python3.13/site-packages', '/Users/crmarsh/workspace/uv/foo/.venv/lib/python3.13/site-packages'] ```
This commit is contained in:
parent
3017b82ecc
commit
3398cb1902
5 changed files with 169 additions and 2 deletions
|
@ -270,6 +270,16 @@ impl PythonEnvironment {
|
|||
Ok(PyVenvConfiguration::parse(self.0.root.join("pyvenv.cfg"))?)
|
||||
}
|
||||
|
||||
/// Set a key-value pair in the `pyvenv.cfg` file.
|
||||
pub fn set_pyvenv_cfg(&self, key: &str, value: &str) -> Result<(), Error> {
|
||||
let content = fs_err::read_to_string(self.0.root.join("pyvenv.cfg"))?;
|
||||
fs_err::write(
|
||||
self.0.root.join("pyvenv.cfg"),
|
||||
PyVenvConfiguration::set(&content, key, value),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns `true` if the environment is "relocatable".
|
||||
pub fn relocatable(&self) -> bool {
|
||||
self.cfg().is_ok_and(|cfg| cfg.is_relocatable())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue