forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Updates to use new Python locator Api #23832
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,9 +2,9 @@ | |
| // Licensed under the MIT License. | ||
|
|
||
| import * as fsPath from 'path'; | ||
| import { Event, EventEmitter, workspace } from 'vscode'; | ||
| import { Event, EventEmitter, Uri, workspace } from 'vscode'; | ||
| import '../../../../common/extensions'; | ||
| import { createDeferred, Deferred } from '../../../../common/utils/async'; | ||
| import { createDeferred, Deferred, flattenIterable } from '../../../../common/utils/async'; | ||
| import { StopWatch } from '../../../../common/utils/stopWatch'; | ||
| import { traceError, traceInfo, traceVerbose } from '../../../../logging'; | ||
| import { sendTelemetryEvent } from '../../../../telemetry'; | ||
|
|
@@ -25,7 +25,12 @@ import { | |
| import { getQueryFilter } from '../../locatorUtils'; | ||
| import { PythonEnvCollectionChangedEvent, PythonEnvsWatcher } from '../../watcher'; | ||
| import { IEnvsCollectionCache } from './envsCollectionCache'; | ||
| import { getNativePythonFinder, NativeEnvInfo, NativePythonFinder } from '../common/nativePythonFinder'; | ||
| import { | ||
| getNativePythonFinder, | ||
| isNativeInfoEnvironment, | ||
| NativeEnvInfo, | ||
| NativePythonFinder, | ||
| } from '../common/nativePythonFinder'; | ||
| import { pathExists } from '../../../../common/platform/fs-paths'; | ||
| import { noop } from '../../../../common/utils/misc'; | ||
| import { parseVersion } from '../../info/pythonVersion'; | ||
|
|
@@ -294,16 +299,18 @@ export class EnvsCollectionService extends PythonEnvsWatcher<PythonEnvCollection | |
| const executablesFoundByNativeLocator = new Set<string>(); | ||
| const nativeStopWatch = new StopWatch(); | ||
| for await (const data of this.nativeFinder.refresh()) { | ||
| nativeEnvs.push(data); | ||
| if (data.executable) { | ||
| // Lowercase for purposes of comparison (safe). | ||
| executablesFoundByNativeLocator.add(data.executable.toLowerCase()); | ||
| } else if (data.prefix) { | ||
| if (isNativeInfoEnvironment(data)) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Karthik Nadig (@karthiknadig) none of this code gets executed in the main branch anymore, |
||
| nativeEnvs.push(data); | ||
| if (data.executable) { | ||
| // Lowercase for purposes of comparison (safe). | ||
| executablesFoundByNativeLocator.add(data.executable.toLowerCase()); | ||
| } else if (data.prefix) { | ||
| // Lowercase for purposes of comparison (safe). | ||
| executablesFoundByNativeLocator.add(data.prefix.toLowerCase()); | ||
| } | ||
| // Lowercase for purposes of comparison (safe). | ||
| executablesFoundByNativeLocator.add(data.prefix.toLowerCase()); | ||
| (data.symlinks || []).forEach((exe) => executablesFoundByNativeLocator.add(exe.toLowerCase())); | ||
| } | ||
| // Lowercase for purposes of comparison (safe). | ||
| (data.symlinks || []).forEach((exe) => executablesFoundByNativeLocator.add(exe.toLowerCase())); | ||
| } | ||
| const nativeDuration = nativeStopWatch.elapsedTime; | ||
| void this.sendNativeLocatorTelemetry(nativeEnvs); | ||
|
|
@@ -980,11 +987,11 @@ async function getCondaTelemetry( | |
|
|
||
| if (condaTelemetry.condaRootPrefixFoundInInfoNotInNative) { | ||
| // Verify we are able to discover this environment as a conda env using native finder. | ||
| const rootPrefixEnvs = await nativeFinder.find(rootPrefix); | ||
| const rootPrefixEnvs = await flattenIterable(nativeFinder.refresh([Uri.file(rootPrefix)])); | ||
| // Did we find an env with the same prefix? | ||
| const rootPrefixEnv = rootPrefixEnvs.find( | ||
| (e) => fsPath.normalize(e.prefix || '').toLowerCase() === rootPrefix.toLowerCase(), | ||
| ); | ||
| const rootPrefixEnv = rootPrefixEnvs | ||
| .filter(isNativeInfoEnvironment) | ||
| .find((e) => fsPath.normalize(e.prefix || '').toLowerCase() === rootPrefix.toLowerCase()); | ||
| condaTelemetry.condaRootPrefixEnvsAfterFind = rootPrefixEnvs.length; | ||
| condaTelemetry.condaRootPrefixFoundInInfoAfterFind = !!rootPrefixEnv; | ||
| condaTelemetry.condaRootPrefixFoundInInfoAfterFindKind = rootPrefixEnv?.kind; | ||
|
|
@@ -1019,11 +1026,11 @@ async function getCondaTelemetry( | |
|
|
||
| if (condaTelemetry.condaDefaultPrefixFoundInInfoNotInNative) { | ||
| // Verify we are able to discover this environment as a conda env using native finder. | ||
| const defaultPrefixEnvs = await nativeFinder.find(defaultPrefix); | ||
| const defaultPrefixEnvs = await flattenIterable(nativeFinder.refresh([Uri.file(defaultPrefix)])); | ||
| // Did we find an env with the same prefix? | ||
| const defaultPrefixEnv = defaultPrefixEnvs.find( | ||
| (e) => fsPath.normalize(e.prefix || '').toLowerCase() === defaultPrefix.toLowerCase(), | ||
| ); | ||
| const defaultPrefixEnv = defaultPrefixEnvs | ||
| .filter(isNativeInfoEnvironment) | ||
| .find((e) => fsPath.normalize(e.prefix || '').toLowerCase() === defaultPrefix.toLowerCase()); | ||
| condaTelemetry.condaDefaultPrefixEnvsAfterFind = defaultPrefixEnvs.length; | ||
| condaTelemetry.condaDefaultPrefixFoundInInfoAfterFind = !!defaultPrefixEnv; | ||
| condaTelemetry.condaDefaultPrefixFoundInInfoAfterFindKind = defaultPrefixEnv?.kind; | ||
|
|
||
Oops, something went wrong.
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.
Will review the API tomorrow/later (after finishing other work), but leaving this as is for now
Karthik Nadig (@karthiknadig) /cc