forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26834d7
commit a414a65
Showing
7 changed files
with
79 additions
and
118 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
83 changes: 51 additions & 32 deletions
83
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 |
---|---|---|
@@ -1,42 +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 function categoryToKind(category?: string): PythonEnvKind { | ||
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; | ||
} | ||
switch (category.toLowerCase()) { | ||
case 'conda': | ||
return PythonEnvKind.Conda; | ||
case 'system': | ||
case 'homebrew': | ||
case 'macpythonorg': | ||
case 'maccommandlinetools': | ||
case 'macxcode': | ||
case 'windowsregistry': | ||
case 'linuxglobal': | ||
return PythonEnvKind.System; | ||
case 'globalpaths': | ||
return PythonEnvKind.OtherGlobal; | ||
case 'pyenv': | ||
return PythonEnvKind.Pyenv; | ||
case 'poetry': | ||
return PythonEnvKind.Poetry; | ||
case 'pipenv': | ||
return PythonEnvKind.Pipenv; | ||
case 'pyenvvirtualenv': | ||
return PythonEnvKind.VirtualEnv; | ||
case 'venv': | ||
return PythonEnvKind.Venv; | ||
case 'virtualenv': | ||
return PythonEnvKind.VirtualEnv; | ||
case 'virtualenvwrapper': | ||
return PythonEnvKind.VirtualEnvWrapper; | ||
case 'windowsstore': | ||
return PythonEnvKind.MicrosoftStore; | ||
default: | ||
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; | ||
} |
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
Oops, something went wrong.