Skip to content

Commit f922e06

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/vscode-python-environments into fix/conditional-activity-bar-icon-v2
2 parents 96e0494 + 57f4248 commit f922e06

55 files changed

Lines changed: 2821 additions & 379 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@
723723
"@types/which": "^3.0.4",
724724
"@typescript-eslint/eslint-plugin": "^8.16.0",
725725
"@typescript-eslint/parser": "^8.16.0",
726-
"@vscode/test-electron": "^2.5.2",
726+
"@vscode/test-electron": "^3.1.0",
727727
"@vscode/vsce": "^3.9.2",
728728
"eslint": "^9.15.0",
729729
"glob": "^8.1.0",

src/common/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import * as path from 'path';
22

33
export const ENVS_EXTENSION_ID = 'ms-python.vscode-python-envs';
44
export const PYTHON_EXTENSION_ID = 'ms-python.python';
5+
export const CONDA_MANAGER_ID = `${PYTHON_EXTENSION_ID}:conda`;
6+
export const INLINE_SCRIPT_MANAGER_ID = `${PYTHON_EXTENSION_ID}:inline-script`;
7+
export const PYENV_MANAGER_ID = `${PYTHON_EXTENSION_ID}:pyenv`;
58
export const JUPYTER_EXTENSION_ID = 'ms-toolsai.jupyter';
69
export const EXTENSION_ROOT_DIR = path.dirname(__dirname);
710
export const ISSUES_URL = 'https://github.com/microsoft/vscode-python-environments/issues';

src/common/errors/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { commands, LogOutputChannel } from 'vscode';
33
import { Common } from '../localize';
44
import { showErrorMessage, showWarningMessage } from '../window.apis';
55

6+
export function getErrorMessage(error: unknown): string {
7+
return error instanceof Error ? error.message : String(error);
8+
}
9+
610
export function parseStack(ex: Error) {
711
if (ex.stack && Array.isArray(ex.stack)) {
812
const concatenated = { ...ex, stack: ex.stack.join('\n') };
Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Licensed under the MIT License.
33

44
import { createHash } from 'crypto';
5-
import { normalizePackageName } from '../managers/builtin/utils';
6-
import { normalizePath } from './utils/pathUtils';
5+
import { normalizePackageName } from '../../managers/builtin/utils';
6+
import { normalizePath } from '../utils/pathUtils';
77

88
/** Length, in hex chars, of the cache key returned by {@link computeCacheKey}. 16 = 64 bits of SHA-256; fixed-length and filesystem-safe. */
99
export const CACHE_KEY_HEX_LENGTH = 16;
@@ -31,6 +31,41 @@ function normalizeExtras(inner: string): string {
3131
return deduped.length > 0 ? `[${deduped.join(',')}]` : '';
3232
}
3333

34+
/** ` >= 2 ; python_version < "3.13"` becomes `>=2 ; python_version<"3.13"`. */
35+
function normalizeRequirementTail(value: string): string {
36+
let result = '';
37+
let unquoted = '';
38+
let quote: "'" | '"' | undefined;
39+
let escaped = false;
40+
41+
const flushUnquoted = () => {
42+
result += unquoted.replace(/\s+/g, ' ').replace(/\s*([<>=!~]=?)\s*/g, '$1');
43+
unquoted = '';
44+
};
45+
46+
// Preserve PEP 508 marker literals verbatim; a backslash escapes the next character.
47+
for (const character of value) {
48+
if (quote) {
49+
result += character;
50+
if (character === quote && !escaped) {
51+
quote = undefined;
52+
}
53+
escaped = character === '\\' && !escaped;
54+
if (character !== '\\') {
55+
escaped = false;
56+
}
57+
} else if (character === "'" || character === '"') {
58+
flushUnquoted();
59+
quote = character;
60+
result += character;
61+
} else {
62+
unquoted += character;
63+
}
64+
}
65+
flushUnquoted();
66+
return result.trim();
67+
}
68+
3469
/**
3570
* Canonicalize a PEP 723 dependency entry so common variants of the same
3671
* requirement produce identical strings. Not a full PEP 508 parser — only
@@ -70,10 +105,12 @@ export function normalizeDependency(dep: string): string {
70105
rest = rest.slice(extrasMatch[0].length);
71106
}
72107

73-
const compactedRest = rest
74-
.replace(/\s+/g, ' ')
75-
.replace(/\s*([<>=!~]=?)\s*/g, '$1')
76-
.trim();
108+
const directReference = rest.trim();
109+
if (directReference.startsWith('@')) {
110+
return `${name}${extras} ${directReference}`;
111+
}
112+
113+
const compactedRest = normalizeRequirementTail(rest);
77114

78115
return `${name}${extras}${compactedRest}`;
79116
}

0 commit comments

Comments
 (0)