forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More native tests for Native python finder (#23831)
- Loading branch information
1 parent
a60f228
commit d2646dc
Showing
10 changed files
with
227 additions
and
250 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
61 changes: 61 additions & 0 deletions
61
src/client/pythonEnvironments/base/locators/common/nativePythonUtils.ts
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,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { LogOutputChannel } from 'vscode'; | ||
import { PythonEnvKind } from '../../info'; | ||
import { traceError } from '../../../../logging'; | ||
|
||
export enum NativePythonEnvironmentKind { | ||
Conda = 'Conda', | ||
Homebrew = 'Homebrew', | ||
Pyenv = 'Pyenv', | ||
GlobalPaths = 'GlobalPaths', | ||
PyenvVirtualEnv = 'PyenvVirtualEnv', | ||
Pipenv = 'Pipenv', | ||
Poetry = 'Poetry', | ||
MacPythonOrg = 'MacPythonOrg', | ||
MacCommandLineTools = 'MacCommandLineTools', | ||
LinuxGlobal = 'LinuxGlobal', | ||
MacXCode = 'MacXCode', | ||
Venv = 'Venv', | ||
VirtualEnv = 'VirtualEnv', | ||
VirtualEnvWrapper = 'VirtualEnvWrapper', | ||
WindowsStore = 'WindowsStore', | ||
WindowsRegistry = 'WindowsRegistry', | ||
} | ||
|
||
const mapping = new Map<NativePythonEnvironmentKind, PythonEnvKind>([ | ||
[NativePythonEnvironmentKind.Conda, PythonEnvKind.Conda], | ||
[NativePythonEnvironmentKind.GlobalPaths, PythonEnvKind.OtherGlobal], | ||
[NativePythonEnvironmentKind.Pyenv, PythonEnvKind.Pyenv], | ||
[NativePythonEnvironmentKind.PyenvVirtualEnv, PythonEnvKind.Pyenv], | ||
[NativePythonEnvironmentKind.Pipenv, PythonEnvKind.Pipenv], | ||
[NativePythonEnvironmentKind.Poetry, PythonEnvKind.Poetry], | ||
[NativePythonEnvironmentKind.VirtualEnv, PythonEnvKind.VirtualEnv], | ||
[NativePythonEnvironmentKind.VirtualEnvWrapper, PythonEnvKind.VirtualEnvWrapper], | ||
[NativePythonEnvironmentKind.Venv, PythonEnvKind.Venv], | ||
[NativePythonEnvironmentKind.WindowsRegistry, PythonEnvKind.System], | ||
[NativePythonEnvironmentKind.WindowsStore, PythonEnvKind.MicrosoftStore], | ||
[NativePythonEnvironmentKind.Homebrew, PythonEnvKind.System], | ||
[NativePythonEnvironmentKind.LinuxGlobal, PythonEnvKind.System], | ||
[NativePythonEnvironmentKind.MacCommandLineTools, PythonEnvKind.System], | ||
[NativePythonEnvironmentKind.MacPythonOrg, PythonEnvKind.System], | ||
[NativePythonEnvironmentKind.MacXCode, PythonEnvKind.System], | ||
]); | ||
|
||
export function categoryToKind(category?: NativePythonEnvironmentKind, logger?: LogOutputChannel): PythonEnvKind { | ||
if (!category) { | ||
return PythonEnvKind.Unknown; | ||
} | ||
const kind = mapping.get(category); | ||
if (kind) { | ||
return kind; | ||
} | ||
|
||
if (logger) { | ||
logger.error(`Unknown Python Environment category '${category}' from Native Locator.`); | ||
} else { | ||
traceError(`Unknown Python Environment category '${category}' from Native Locator.`); | ||
} | ||
return PythonEnvKind.Unknown; | ||
} |
Oops, something went wrong.