@@ -34,6 +34,8 @@ pub struct VirtualEnvironment {
|
||||
/// A parsed `pyvenv.cfg`
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PyVenvConfiguration {
|
||||
/// The `PYTHONHOME` directory containing the base Python executable.
|
||||
pub(crate) home: Option<PathBuf>,
|
||||
/// Was the virtual environment created with the `virtualenv` package?
|
||||
pub(crate) virtualenv: bool,
|
||||
/// Was the virtual environment created with the `uv` package?
|
||||
@@ -231,6 +233,7 @@ pub(crate) fn virtualenv_python_executable(venv: impl AsRef<Path>) -> PathBuf {
|
||||
impl PyVenvConfiguration {
|
||||
/// Parse a `pyvenv.cfg` file into a [`PyVenvConfiguration`].
|
||||
pub fn parse(cfg: impl AsRef<Path>) -> Result<Self, Error> {
|
||||
let mut home = None;
|
||||
let mut virtualenv = false;
|
||||
let mut uv = false;
|
||||
let mut relocatable = false;
|
||||
@@ -248,6 +251,9 @@ impl PyVenvConfiguration {
|
||||
continue;
|
||||
};
|
||||
match key.trim() {
|
||||
"home" => {
|
||||
home = Some(PathBuf::from(value.trim()));
|
||||
}
|
||||
"virtualenv" => {
|
||||
virtualenv = true;
|
||||
}
|
||||
@@ -274,6 +280,7 @@ impl PyVenvConfiguration {
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
home,
|
||||
virtualenv,
|
||||
uv,
|
||||
relocatable,
|
||||
|
||||
Reference in New Issue
Block a user