forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support virtualenvwrapper in nativelocator (microsoft#23388)
- Loading branch information
1 parent
742cbfd
commit c7410a4
Showing
12 changed files
with
223 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use std::path::PathBuf; | ||
|
||
use crate::utils::PythonEnv; | ||
|
||
pub fn is_virtualenv(env: &PythonEnv) -> bool { | ||
if let Some(file_path) = PathBuf::from(env.executable.clone()).parent() { | ||
// Check if there are any activate.* files in the same directory as the interpreter. | ||
// | ||
// env | ||
// |__ activate, activate.* <--- check if any of these files exist | ||
// |__ python <--- interpreterPath | ||
|
||
// if let Some(parent_path) = PathBuf::from(env.) | ||
// const directory = path.dirname(interpreterPath); | ||
// const files = await fsapi.readdir(directory); | ||
// const regex = /^activate(\.([A-z]|\d)+)?$/i; | ||
if file_path.join("activate").exists() || file_path.join("activate.bat").exists() { | ||
return true; | ||
} | ||
|
||
// Support for activate.ps, etc. | ||
match std::fs::read_dir(file_path) { | ||
Ok(files) => { | ||
for file in files { | ||
if let Ok(file) = file { | ||
if let Some(file_name) = file.file_name().to_str() { | ||
if file_name.starts_with("activate") { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
Err(_) => return false, | ||
}; | ||
} | ||
|
||
false | ||
} |
Oops, something went wrong.