Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/managers/conda/condaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Common, CondaStrings, PackageManagement, Pickers } from '../../common/l
import { traceInfo, traceVerbose } from '../../common/logging';
import { getWorkspacePersistentState } from '../../common/persistentState';
import { pickProject } from '../../common/pickers/projects';
import { StopWatch } from '../../common/stopWatch';
import { createDeferred } from '../../common/utils/deferred';
import { untildify } from '../../common/utils/pathUtils';
import { isWindows } from '../../common/utils/platformUtils';
Expand All @@ -56,7 +57,6 @@ import { Installable } from '../common/types';
import { shortVersion, sortEnvironments } from '../common/utils';
import { CondaEnvManager } from './condaEnvManager';
import { getCondaHookPs1Path, getLocalActivationScript } from './condaSourcingUtils';
import { StopWatch } from '../../common/stopWatch';

export const CONDA_PATH_KEY = `${ENVS_EXTENSION_ID}:conda:CONDA_PATH`;
export const CONDA_PREFIXES_KEY = `${ENVS_EXTENSION_ID}:conda:CONDA_PREFIXES`;
Expand Down Expand Up @@ -742,7 +742,6 @@ function trimVersionToMajorMinor(version: string): string {
const match = version.match(/^(\d+\.\d+\.\d+)/);
return match ? match[1] : version;
}

export async function pickPythonVersion(
api: PythonEnvironmentApi,
token?: CancellationToken,
Expand All @@ -755,11 +754,16 @@ export async function pickPythonVersion(
.filter(Boolean)
.map((v) => trimVersionToMajorMinor(v)), // cut to 3 digits
),
)
.sort()
.reverse();
if (!versions) {
versions = ['3.11', '3.10', '3.9', '3.12', '3.13'];
);

// Sort versions by major version (descending), ignoring minor/patch for simplicity
versions = versions.sort((a, b) => {
const getMajor = (v: string) => parseInt(v.split('.')[0], 10);
Comment thread
eleanorjboyd marked this conversation as resolved.
Outdated
return getMajor(b) - getMajor(a);
});
Comment thread
eleanorjboyd marked this conversation as resolved.

if (!versions || versions.length === 0) {
versions = ['3.13', '3.12', '3.11', '3.10', '3.9'];
}
const items: QuickPickItem[] = versions.map((v) => ({
label: v === RECOMMENDED_CONDA_PYTHON ? `$(star-full) Python` : 'Python',
Expand Down
Loading