forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvKind.ts
More file actions
74 lines (71 loc) · 2.49 KB
/
envKind.ts
File metadata and controls
74 lines (71 loc) · 2.49 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
66
67
68
69
70
71
72
73
74
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { PythonEnvKind } from '.';
/**
* Get the given kind's user-facing representation.
*
* If it doesn't have one then the empty string is returned.
*/
export function getKindDisplayName(kind: PythonEnvKind): string {
for (const [candidate, value] of [
// Note that Unknown is excluded here.
[PythonEnvKind.System, 'system'],
[PythonEnvKind.MicrosoftStore, 'microsoft store'],
[PythonEnvKind.Pyenv, 'pyenv'],
[PythonEnvKind.Poetry, 'poetry'],
[PythonEnvKind.Custom, 'custom'],
// For now we treat OtherGlobal like Unknown.
[PythonEnvKind.Venv, 'venv'],
[PythonEnvKind.VirtualEnv, 'virtualenv'],
[PythonEnvKind.VirtualEnvWrapper, 'virtualenv'],
[PythonEnvKind.Pipenv, 'pipenv'],
[PythonEnvKind.Conda, 'conda'],
[PythonEnvKind.ActiveState, 'ActiveState'],
// For now we treat OtherVirtual like Unknown.
] as [PythonEnvKind, string][]) {
if (kind === candidate) {
return value;
}
}
return '';
}
/**
* Gets a prioritized list of environment types for identification.
* @returns {PythonEnvKind[]} : List of environments ordered by identification priority
*
* Remarks: This is the order of detection based on how the various distributions and tools
* configure the environment, and the fall back for identification.
* Top level we have the following environment types, since they leave a unique signature
* in the environment or * use a unique path for the environments they create.
* 1. Conda
* 2. Microsoft Store
* 3. PipEnv
* 4. Pyenv
* 5. Poetry
*
* Next level we have the following virtual environment tools. The are here because they
* are consumed by the tools above, and can also be used independently.
* 1. venv
* 2. virtualenvwrapper
* 3. virtualenv
*
* Last category is globally installed python, or system python.
*/
export function getPrioritizedEnvKinds(): PythonEnvKind[] {
return [
PythonEnvKind.Pyenv,
PythonEnvKind.Conda,
PythonEnvKind.MicrosoftStore,
PythonEnvKind.Pipenv,
PythonEnvKind.Poetry,
PythonEnvKind.Venv,
PythonEnvKind.VirtualEnvWrapper,
PythonEnvKind.VirtualEnv,
PythonEnvKind.ActiveState,
PythonEnvKind.OtherVirtual,
PythonEnvKind.OtherGlobal,
PythonEnvKind.System,
PythonEnvKind.Custom,
PythonEnvKind.Unknown,
];
}