Add support for pipenv environments - #23379
Conversation
| PathBuf::from(".direnv"), | ||
| PathBuf::from(".venvs"), | ||
| PathBuf::from(".virtualenvs"), | ||
| PathBuf::from(".local").join("share").join("virtualenvs"), |
There was a problem hiding this comment.
Karthik Nadig (@karthiknadig) lets discuss tomorrow
Right now I'm only looking for pipenv envs, but all other envs even if global will be ignored.
I think we should just list them as well,
| /** | ||
| * The project path for the Pipenv environment. | ||
| */ | ||
| pub project_path: Option<String>, |
There was a problem hiding this comment.
Karthik Nadig (@karthiknadig) Lets discuss tomorrow.
| } | ||
|
|
||
| pub fn get_version(path: &str) -> Option<String> { | ||
| if let Some(parent_folder) = PathBuf::from(path).parent() { |
There was a problem hiding this comment.
Karthik Nadig (@karthiknadig) i think this is correct.
E.g. virtual envs and pipenvs have their version numbers in the pyvenv.cfg file, thus we can try to avoid the spawn here.
|
|
||
| assert_eq!(dispatcher.messages.len(), 1); | ||
| let expected_json = json!({"envManager":null,"name":null,"pythonExecutablePath":unix_python_exe.clone(),"category":"system","version":null,"pythonRunCommand":[unix_python_exe.clone()],"envPath":unix_python.clone(),"sysPrefixPath":unix_python.clone()}); | ||
| let expected_json = json!({"envManager":null,"projectPath": null, "name":null,"pythonExecutablePath":unix_python_exe.clone(),"category":"system","version":null,"pythonRunCommand":[unix_python_exe.clone()],"envPath":unix_python.clone(),"sysPrefixPath":unix_python.clone()}); |
There was a problem hiding this comment.
I'll update the tests to remove the JSON and just build the structs by hand, then convert to JSOn and compare
handcrafting JSON is messy, structs will provide better language features.
Karthik Nadig (@karthiknadig) FYI only, will clean this in a separate PR
| /** | ||
| * Path to the project directory when dealing with pipenv virtual environments. | ||
| */ | ||
| projectPath?: string; |
There was a problem hiding this comment.
Lets discuss these tomorrow.
| kind: categoryToKind(data.category), | ||
| executablePath: data.pythonExecutablePath[0], | ||
| // TODO: What if executable is undefined? | ||
| executablePath: data.pythonExecutablePath!, |
There was a problem hiding this comment.
Need to discuss this as well.
No description provided.