forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnativePythonUtils.ts
More file actions
65 lines (60 loc) · 2.6 KB
/
nativePythonUtils.ts
File metadata and controls
65 lines (60 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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',
Pixi = 'Pixi',
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',
VenvUv = 'VenvUv',
}
const mapping = new Map<NativePythonEnvironmentKind, PythonEnvKind>([
[NativePythonEnvironmentKind.Conda, PythonEnvKind.Conda],
[NativePythonEnvironmentKind.Pixi, PythonEnvKind.Pixi],
[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.VenvUv, 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;
}