mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-30 23:37:24 +00:00
Set base executable when returning virtual environment (#11209)
## Summary I'm not sure that this has much of an effect in practice, but currently, when we return a virtual environment, the `sys_base_executable ` of the parent ends up being retained as `sys_base_executable` of the created environment. But these can be, like, subtly different? If you have a symlink to a Python, then for the symlink, `sys_base_executable` will be equal to `sys_executable`. But when you create a virtual environment for that interpreter, we'll set `home` to the resolved symlink, and so `sys_base_executable` will be the resolved symlink too, in general. Anyway, this means that we should now have a consistent value between (1) returning `Virtualenv` from the creation routine and (2) querying the created interpreter.
This commit is contained in:
parent
34552e2d3d
commit
2fad82c735
3 changed files with 5 additions and 0 deletions
|
@ -94,6 +94,7 @@ impl Interpreter {
|
||||||
pub fn with_virtualenv(self, virtualenv: VirtualEnvironment) -> Self {
|
pub fn with_virtualenv(self, virtualenv: VirtualEnvironment) -> Self {
|
||||||
Self {
|
Self {
|
||||||
scheme: virtualenv.scheme,
|
scheme: virtualenv.scheme,
|
||||||
|
sys_base_executable: Some(virtualenv.base_executable),
|
||||||
sys_executable: virtualenv.executable,
|
sys_executable: virtualenv.executable,
|
||||||
sys_prefix: virtualenv.root,
|
sys_prefix: virtualenv.root,
|
||||||
target: None,
|
target: None,
|
||||||
|
|
|
@ -18,6 +18,9 @@ pub struct VirtualEnvironment {
|
||||||
/// (Unix, Python 3.11).
|
/// (Unix, Python 3.11).
|
||||||
pub executable: PathBuf,
|
pub executable: PathBuf,
|
||||||
|
|
||||||
|
/// The path to the base executable for the environment, within the `home` directory.
|
||||||
|
pub base_executable: PathBuf,
|
||||||
|
|
||||||
/// The [`Scheme`] paths for the virtualenv, as returned by (e.g.) `sysconfig.get_paths()`.
|
/// The [`Scheme`] paths for the virtualenv, as returned by (e.g.) `sysconfig.get_paths()`.
|
||||||
pub scheme: Scheme,
|
pub scheme: Scheme,
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,6 +400,7 @@ pub(crate) fn create(
|
||||||
},
|
},
|
||||||
root: location,
|
root: location,
|
||||||
executable,
|
executable,
|
||||||
|
base_executable: base_python,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue