forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Ensure we correctly evaluate Unknown type before sending startup telemetry #17362
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| Ensure we correctly evaluate Unknown type before sending startup telemetry. |
This file contains hidden or 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 hidden or 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
46 changes: 46 additions & 0 deletions
46
src/client/pythonEnvironments/common/environmentManagers/globalInstalledEnvs.ts
This file contains hidden or 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,46 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import { getSearchPathEntries } from '../../../common/utils/exec'; | ||
| import { getOSType, OSType } from '../../../common/utils/platform'; | ||
| import { isParentPath } from '../externalDependencies'; | ||
| import { commonPosixBinPaths } from '../posixUtils'; | ||
| import { isPyenvShimDir } from './pyenv'; | ||
|
|
||
| /** | ||
| * Checks if the given interpreter belongs to known globally installed types. If an global | ||
| * executable is discoverable, we consider it as global type. | ||
| * @param {string} interpreterPath: Absolute path to the python interpreter. | ||
| * @returns {boolean} : Returns true if the interpreter belongs to a venv environment. | ||
| */ | ||
| export async function isGloballyInstalledEnv(executablePath: string): Promise<boolean> { | ||
| // Identifying this type is not important, as the extension treats `Global` and `Unknown` | ||
| // types the same way. This is only required for telemetry. As windows registry is known | ||
| // to be slow, we do not want to unnecessarily block on that by default, hence skip this | ||
| // step. | ||
| // if (getOSType() === OSType.Windows) { | ||
| // if (await isFoundInWindowsRegistry(executablePath)) { | ||
| // return true; | ||
| // } | ||
| // } | ||
| return isFoundInPathEnvVar(executablePath); | ||
| } | ||
|
|
||
| async function isFoundInPathEnvVar(executablePath: string): Promise<boolean> { | ||
| let searchPathEntries: string[] = []; | ||
| if (getOSType() === OSType.Windows) { | ||
| searchPathEntries = getSearchPathEntries(); | ||
| } else { | ||
| searchPathEntries = await commonPosixBinPaths(); | ||
| } | ||
| // Filter out pyenv shims. They are not actual python binaries, they are used to launch | ||
| // the binaries specified in .python-version file in the cwd. We should not be reporting | ||
| // those binaries as environments. | ||
| searchPathEntries = searchPathEntries.filter((dirname) => !isPyenvShimDir(dirname)); | ||
| for (const searchPath of searchPathEntries) { | ||
| if (isParentPath(executablePath, searchPath)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If user has selected an interpreter which is not discovery cache (maybe a new type of virtual env we do not support), this is useful.