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
145 lines (132 loc) · 3.96 KB
/
Copy pathindex.ts
File metadata and controls
145 lines (132 loc) · 3.96 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { Uri } from 'vscode';
import { Architecture } from '../../../common/utils/platform';
import { BasicVersionInfo, VersionInfo } from '../../../common/utils/version';
/**
* IDs for the various supported Python environments.
*/
export enum PythonEnvKind {
Unknown = 'unknown',
// "global"
System = 'global-system',
MacDefault = 'global-mac-default',
WindowsStore = 'global-windows-store',
Pyenv = 'global-pyenv',
CondaBase = 'global-conda-base',
Custom = 'global-custom',
OtherGlobal = 'global-other',
// "virtual"
Venv = 'virt-venv',
VirtualEnv = 'virt-virtualenv',
Pipenv = 'virt-pipenv',
Conda = 'virt-conda',
OtherVirtual = 'virt-other'
}
/**
* Information about a Python binary/executable.
*/
export type PythonExecutableInfo = {
filename: string;
sysPrefix: string;
ctime: number;
mtime: number;
};
/**
* A (system-global) unique ID for a single Python environment.
*/
export type PythonEnvID = string;
/**
* The most fundamental information about a Python environment.
*
* You should expect these objects to be complete (no empty props).
* Note that either `name` or `location` must be non-empty, though
* the other *can* be empty.
*
* @prop id - the env's unique ID
* @prop kind - the env's kind
* @prop executable - info about the env's Python binary
* @prop name - the env's distro-specific name, if any
* @prop location - the env's location (on disk), if relevant
*/
export type PythonEnvBaseInfo = {
id: PythonEnvID;
kind: PythonEnvKind;
executable: PythonExecutableInfo;
// One of (name, location) must be non-empty.
name: string;
location: string;
// Other possible fields:
// * managed: boolean (if the env is "managed")
// * parent: PythonEnvBaseInfo (the env from which this one was created)
// * binDir: string (where env-installed executables are found)
};
/**
* The possible Python release levels.
*/
export enum PythonReleaseLevel {
Alpha = 'alpha',
Beta = 'beta',
Candidate = 'candidate',
Final = 'final'
}
/**
* Release information for a Python version.
*/
export type PythonVersionRelease = {
level: PythonReleaseLevel;
serial: number;
};
/**
* Version information for a Python build/installation.
*
* @prop sysVersion - the raw text from `sys.version`
*/
export type PythonVersion = BasicVersionInfo & {
release: PythonVersionRelease;
sysVersion?: string;
};
/**
* Information for a Python build/installation.
*/
export type PythonBuildInfo = {
version: PythonVersion; // incl. raw, AKA sys.version
arch: Architecture;
};
/**
* Meta information about a Python distribution.
*
* @prop org - the name of the distro's creator/publisher
* @prop defaultDisplayName - the text to use when showing the distro to users
*/
export type PythonDistroMetaInfo = {
org: string;
defaultDisplayName?: string;
};
/**
* Information about an installed Python distribution.
*
* @prop version - the installed *distro* version (not the Python version)
* @prop binDir - where to look for the distro's executables (i.e. tools)
*/
export type PythonDistroInfo = PythonDistroMetaInfo & {
version?: VersionInfo;
binDir?: string;
};
type _PythonEnvInfo = PythonEnvBaseInfo & PythonBuildInfo;
/**
* All the available information about a Python environment.
*
* Note that not all the information will necessarily be filled in.
* Locators are only required to fill in the "base" info, though
* they will usually be able to provide the version as well.
*
* @prop distro - the installed Python distro that this env is using or belongs to
* @prop defaultDisplayName - the text to use when showing the env to users
* @prop searchLocation - the root under which a locator found this env, if any
*/
export type PythonEnvInfo = _PythonEnvInfo & {
distro: PythonDistroInfo;
defaultDisplayName?: string;
searchLocation?: Uri;
};