-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
@@ -27,6 +27,6 @@ fn find_python_in_path_this() { | |||
common_python::find_and_report(&mut dispatcher, &known); | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets discuss these tomorrow.
@@ -115,7 +121,8 @@ export class NativeLocator implements ILocator<BasicEnvInfo>, IDisposable { | |||
connection.onNotification('pythonEnvironment', (data: NativeEnvInfo) => { | |||
envs.push({ | |||
kind: categoryToKind(data.category), | |||
executablePath: data.pythonExecutablePath[0], | |||
// TODO: What if executable is undefined? | |||
executablePath: data.pythonExecutablePath!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to discuss this as well.
No description provided.