Skip to content

Commit ef79f92

Browse files
author
Kartik Raj
authored
Cleanup environment discovery types (microsoft#19268)
1 parent b17b947 commit ef79f92

6 files changed

Lines changed: 4 additions & 55 deletions

File tree

src/client/pythonEnvironments/base/info/envKind.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ export function getKindDisplayName(kind: PythonEnvKind): string {
1212
for (const [candidate, value] of [
1313
// Note that Unknown is excluded here.
1414
[PythonEnvKind.System, 'system'],
15-
[PythonEnvKind.MacDefault, 'mac default'],
1615
[PythonEnvKind.WindowsStore, 'windows store'],
1716
[PythonEnvKind.Pyenv, 'pyenv'],
18-
[PythonEnvKind.CondaBase, 'conda'],
1917
[PythonEnvKind.Poetry, 'poetry'],
2018
[PythonEnvKind.Custom, 'custom'],
2119
// For now we treat OtherGlobal like Unknown.
@@ -58,7 +56,6 @@ export function getKindDisplayName(kind: PythonEnvKind): string {
5856
export function getPrioritizedEnvKinds(): PythonEnvKind[] {
5957
return [
6058
PythonEnvKind.Pyenv,
61-
PythonEnvKind.CondaBase,
6259
PythonEnvKind.Conda,
6360
PythonEnvKind.WindowsStore,
6461
PythonEnvKind.Pipenv,
@@ -68,7 +65,6 @@ export function getPrioritizedEnvKinds(): PythonEnvKind[] {
6865
PythonEnvKind.VirtualEnv,
6966
PythonEnvKind.OtherVirtual,
7067
PythonEnvKind.OtherGlobal,
71-
PythonEnvKind.MacDefault,
7268
PythonEnvKind.System,
7369
PythonEnvKind.Custom,
7470
PythonEnvKind.Unknown,

src/client/pythonEnvironments/base/info/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ export enum PythonEnvKind {
1212
Unknown = 'unknown',
1313
// "global"
1414
System = 'global-system',
15-
MacDefault = 'global-mac-default',
1615
WindowsStore = 'global-windows-store',
1716
Pyenv = 'global-pyenv',
18-
CondaBase = 'global-conda-base',
19-
Poetry = 'global-poetry',
17+
Poetry = 'poetry',
2018
Custom = 'global-custom',
2119
OtherGlobal = 'global-other',
2220
// "virtual"

src/client/pythonEnvironments/base/locators/composite/envsReducer.ts

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Event, EventEmitter } from 'vscode';
66
import { traceVerbose } from '../../../../logging';
77
import { PythonEnvKind } from '../../info';
88
import { areSameEnv } from '../../info/env';
9+
import { getPrioritizedEnvKinds } from '../../info/envKind';
910
import {
1011
BasicEnvInfo,
1112
ILocator,
@@ -144,50 +145,8 @@ function resolveEnvCollision(oldEnv: BasicEnvInfo, newEnv: BasicEnvInfo): BasicE
144145
function sortEnvInfoByPriority(...envs: BasicEnvInfo[]): BasicEnvInfo[] {
145146
// TODO: When we consolidate the PythonEnvKind and EnvironmentType we should have
146147
// one location where we define priority.
147-
const envKindByPriority: PythonEnvKind[] = getPrioritizedEnvironmentKind();
148+
const envKindByPriority: PythonEnvKind[] = getPrioritizedEnvKinds();
148149
return envs.sort(
149150
(a: BasicEnvInfo, b: BasicEnvInfo) => envKindByPriority.indexOf(a.kind) - envKindByPriority.indexOf(b.kind),
150151
);
151152
}
152-
153-
/**
154-
* Gets a prioritized list of environment types for identification.
155-
* @returns {PythonEnvKind[]} : List of environments ordered by identification priority
156-
*
157-
* Remarks: This is the order of detection based on how the various distributions and tools
158-
* configure the environment, and the fall back for identification.
159-
* Top level we have the following environment types, since they leave a unique signature
160-
* in the environment or * use a unique path for the environments they create.
161-
* 1. Pyenv (pyenv can also be a conda env or venv, but should be activated as a venv)
162-
* 2. Conda
163-
* 3. Windows Store
164-
* 4. PipEnv
165-
* 5. Poetry
166-
*
167-
* Next level we have the following virtual environment tools. The are here because they
168-
* are consumed by the tools above, and can also be used independently.
169-
* 1. venv
170-
* 2. virtualenvwrapper
171-
* 3. virtualenv
172-
*
173-
* Last category is globally installed python, or system python.
174-
*/
175-
function getPrioritizedEnvironmentKind(): PythonEnvKind[] {
176-
return [
177-
PythonEnvKind.Pyenv,
178-
PythonEnvKind.CondaBase,
179-
PythonEnvKind.Conda,
180-
PythonEnvKind.WindowsStore,
181-
PythonEnvKind.Pipenv,
182-
PythonEnvKind.Poetry,
183-
PythonEnvKind.Venv,
184-
PythonEnvKind.VirtualEnvWrapper,
185-
PythonEnvKind.VirtualEnv,
186-
PythonEnvKind.OtherVirtual,
187-
PythonEnvKind.OtherGlobal,
188-
PythonEnvKind.MacDefault,
189-
PythonEnvKind.System,
190-
PythonEnvKind.Custom,
191-
PythonEnvKind.Unknown,
192-
];
193-
}

src/client/pythonEnvironments/legacyIOC.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ const convertedKinds = new Map(
2727
Object.entries({
2828
[PythonEnvKind.OtherGlobal]: EnvironmentType.Global,
2929
[PythonEnvKind.System]: EnvironmentType.System,
30-
[PythonEnvKind.MacDefault]: EnvironmentType.System,
3130
[PythonEnvKind.WindowsStore]: EnvironmentType.WindowsStore,
3231
[PythonEnvKind.Pyenv]: EnvironmentType.Pyenv,
3332
[PythonEnvKind.Conda]: EnvironmentType.Conda,
34-
[PythonEnvKind.CondaBase]: EnvironmentType.Conda,
3533
[PythonEnvKind.VirtualEnv]: EnvironmentType.VirtualEnv,
3634
[PythonEnvKind.Pipenv]: EnvironmentType.Pipenv,
3735
[PythonEnvKind.Poetry]: EnvironmentType.Poetry,

src/test/pythonEnvironments/base/info/envKind.unit.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import { getKindDisplayName, getPrioritizedEnvKinds } from '../../../../client/p
1010
const KIND_NAMES: [PythonEnvKind, string][] = [
1111
// We handle PythonEnvKind.Unknown separately.
1212
[PythonEnvKind.System, 'system'],
13-
[PythonEnvKind.MacDefault, 'macDefault'],
1413
[PythonEnvKind.WindowsStore, 'winStore'],
1514
[PythonEnvKind.Pyenv, 'pyenv'],
16-
[PythonEnvKind.CondaBase, 'condaBase'],
1715
[PythonEnvKind.Poetry, 'poetry'],
1816
[PythonEnvKind.Custom, 'customGlobal'],
1917
[PythonEnvKind.OtherGlobal, 'otherGlobal'],

src/test/pythonEnvironments/base/locatorUtils.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ suite('Python envs locator utils - getQueryFilter', () => {
7979

8080
suite('kinds', () => {
8181
test('match none', () => {
82-
const query: PythonLocatorQuery = { kinds: [PythonEnvKind.MacDefault] };
82+
const query: PythonLocatorQuery = { kinds: [PythonEnvKind.Poetry] };
8383

8484
const filter = getQueryFilter(query);
8585
const filtered = envs.filter(filter);

0 commit comments

Comments
 (0)