Skip to content

Commit b31be7b

Browse files
authored
Fix pipenv environment detection with centralized directory support (#324)
Fixes #319 Enhance environment variable detection for pipenv by adding support for centralized directories, including user home and XDG data home paths.
1 parent 2df70d1 commit b31be7b

File tree

2 files changed

+322
-19
lines changed

2 files changed

+322
-19
lines changed

crates/pet-pipenv/src/env_variables.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
use pet_core::os_environment::Environment;
5+
use std::path::PathBuf;
56

67
#[derive(Debug, Clone)]
78
// NOTE: Do not implement Default trait, as we do not want to ever forget to set the values.
@@ -10,6 +11,9 @@ pub struct EnvVariables {
1011
#[allow(dead_code)]
1112
pub pipenv_max_depth: u16,
1213
pub pipenv_pipfile: String,
14+
pub home: Option<PathBuf>,
15+
pub xdg_data_home: Option<String>,
16+
pub workon_home: Option<PathBuf>,
1317
}
1418

1519
impl EnvVariables {
@@ -22,6 +26,11 @@ impl EnvVariables {
2226
pipenv_pipfile: env
2327
.get_env_var("PIPENV_PIPFILE".to_string())
2428
.unwrap_or("Pipfile".to_string()),
29+
home: env.get_user_home(),
30+
xdg_data_home: env.get_env_var("XDG_DATA_HOME".to_string()),
31+
workon_home: env
32+
.get_env_var("WORKON_HOME".to_string())
33+
.map(PathBuf::from),
2534
}
2635
}
2736
}

0 commit comments

Comments
 (0)