Skip to content

Ensure pip and setuptools are upgraded when creating the virtual environment #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2025
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
16 changes: 15 additions & 1 deletion client/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export async function installLanguageServer(
Constants.LS_VENV_NAME,
context.extensionPath
);

await ensureEnvUpgraded(venvPath);
}

const venvPython = getPythonFromVirtualEnvPath(venvPath);
Expand All @@ -122,7 +124,7 @@ export async function installLanguageServer(
);

if (!isInstalled) {
const errorMessage = "There was a problem trying to install the Galaxy language server.";
const errorMessage = "There was a problem trying to install the Galaxy language server. Check the logs under Help > Developer Tools > Console or try reloading VS Code.";
window.showErrorMessage(errorMessage);
removeDirectory(venvPath);
throw new Error(errorMessage);
Expand Down Expand Up @@ -233,6 +235,18 @@ async function isPythonPackageInstalled(python: string, packageName: string, ver
}
}

async function ensureEnvUpgraded(venvPath: string): Promise<boolean> {
const venvPython = getPythonFromVirtualEnvPath(venvPath);
const upgradePythonPackagesCmd = `"${venvPython}" -m pip install --upgrade pip setuptools`;
try {
await execAsync(upgradePythonPackagesCmd);
return true;
} catch (err: any) {
console.error(`[gls] err upgrading pip and setuptools: ${err}`);
return false;
}
}

async function installPythonPackage(python: string, packageName: string, version: string): Promise<boolean> {
const installPipPackageCmd = `"${python}" -m pip install ${packageName}==${version}`;
try {
Expand Down