Skip to content
Merged
Changes from all commits
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
46 changes: 18 additions & 28 deletions src/managers/builtin/venvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,22 @@ export async function quickCreateVenv(
if (additionalPackages) {
allPackages.push(...additionalPackages);
}
return await createWithProgress(
nativeFinder,
api,
log,
manager,
baseEnv,
venvRoot,
path.join(venvRoot.fsPath, '.venv'),
{ install: allPackages, uninstall: [] },
);

// Check if .venv already exists
let venvPath = path.join(venvRoot.fsPath, '.venv');
if (await fsapi.pathExists(venvPath)) {
// increment to create a unique name, e.g. .venv-1
let i = 1;
while (await fsapi.pathExists(`${venvPath}-${i}`)) {
i++;
}
venvPath = `${venvPath}-${i}`;
}

return await createWithProgress(nativeFinder, api, log, manager, baseEnv, venvRoot, venvPath, {
install: allPackages,
uninstall: [],
});
}

export async function createPythonVenv(
Expand All @@ -473,7 +479,6 @@ export async function createPythonVenv(
options: { showQuickAndCustomOptions: boolean; additionalPackages?: string[] },
): Promise<PythonEnvironment | undefined> {
const sortedEnvs = ensureGlobalEnv(basePythons, log);
const project = api.getPythonProject(venvRoot);

let customize: boolean | undefined = true;
if (options.showQuickAndCustomOptions) {
Expand All @@ -483,26 +488,11 @@ export async function createPythonVenv(
if (customize === undefined) {
return;
} else if (customize === false) {
sendTelemetryEvent(EventNames.VENV_CREATION, undefined, { creationType: 'quick' });
const installables = await getProjectInstallable(api, project ? [project] : undefined);
const allPackages = [];
allPackages.push(...(installables?.flatMap((i) => i.args ?? []) ?? []));
if (options.additionalPackages) {
allPackages.push(...options.additionalPackages);
}
return await createWithProgress(
nativeFinder,
api,
log,
manager,
sortedEnvs[0],
venvRoot,
path.join(venvRoot.fsPath, '.venv'),
{ install: allPackages, uninstall: [] },
);
return quickCreateVenv(nativeFinder, api, log, manager, sortedEnvs[0], venvRoot, options.additionalPackages);
Copy link
Member Author

@eleanorjboyd eleanorjboyd Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karthiknadig just want to confirm this is good here to call the other command- seems intuitive to me but wasn't sure if there was a reason these were left separate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as it is able to get the packages that it needs to install correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep confirmed that works

} else {
sendTelemetryEvent(EventNames.VENV_CREATION, undefined, { creationType: 'custom' });
}
const project = api.getPythonProject(venvRoot);

const basePython = await pickEnvironmentFrom(sortedEnvs);
if (!basePython || !basePython.execInfo) {
Expand Down