forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
99 lines (93 loc) · 2.79 KB
/
index.ts
File metadata and controls
99 lines (93 loc) · 2.79 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { Architecture } from '../../common/utils/platform';
import { PythonVersion } from './pythonVersion';
/**
* The supported Python environment types.
*/
export enum EnvironmentType {
Unknown = 'Unknown',
Conda = 'Conda',
VirtualEnv = 'VirtualEnv',
Pipenv = 'PipEnv',
Pyenv = 'Pyenv',
Venv = 'Venv',
WindowsStore = 'WindowsStore',
Poetry = 'Poetry',
VirtualEnvWrapper = 'VirtualEnvWrapper',
Global = 'Global',
System = 'System',
}
/**
* Details about a Python runtime.
*
* @prop path - the location of the executable file
* @prop version - the runtime version
* @prop sysVersion - the raw value of `sys.version`
* @prop architecture - of the host CPU (e.g. `x86`)
* @prop sysPrefix - the environment's install root (`sys.prefix`)
* @prop pipEnvWorkspaceFolder - the pipenv root, if applicable
*/
export type InterpreterInformation = {
path: string;
version?: PythonVersion;
sysVersion?: string;
architecture: Architecture;
sysPrefix: string;
pipEnvWorkspaceFolder?: string;
};
/**
* Details about a Python environment.
*
* @prop companyDisplayName - the user-facing name of the distro publisher
* @prop displayName - the user-facing name for the environment
* @prop type - the kind of Python environment
* @prop envName - the environment's name, if applicable (else `envPath` is set)
* @prop envPath - the environment's root dir, if applicable (else `envName`)
* @prop cachedEntry - whether or not the info came from a cache
*/
// Note that "cachedEntry" is specific to the caching machinery
// and doesn't really belong here.
export type PythonEnvironment = InterpreterInformation & {
companyDisplayName?: string;
displayName?: string;
envType: EnvironmentType;
envName?: string;
envPath?: string;
cachedEntry?: boolean;
};
/**
* Convert the Python environment type to a user-facing name.
*/
export function getEnvironmentTypeName(environmentType: EnvironmentType): string {
switch (environmentType) {
case EnvironmentType.Conda: {
return 'conda';
}
case EnvironmentType.Pipenv: {
return 'pipenv';
}
case EnvironmentType.Pyenv: {
return 'pyenv';
}
case EnvironmentType.Venv: {
return 'venv';
}
case EnvironmentType.VirtualEnv: {
return 'virtualenv';
}
case EnvironmentType.WindowsStore: {
return 'windows store';
}
case EnvironmentType.Poetry: {
return 'poetry';
}
case EnvironmentType.VirtualEnvWrapper: {
return 'virtualenvwrapper';
}
default: {
return '';
}
}
}