Only include package versions in Manage Packages dialog if they're supported for the user's version of Python (#14584)

This commit is contained in:
Cory Rivera
2021-03-08 18:05:10 -08:00
committed by GitHub
parent bbdc324f17
commit e2a5859155
6 changed files with 245 additions and 16 deletions

View File

@@ -68,6 +68,7 @@ export interface IJupyterServerInstallation {
uninstallPipPackages(packages: PythonPkgDetails[]): Promise<void>;
pythonExecutable: string;
pythonInstallationPath: string;
installedPythonVersion: string;
}
export const requiredJupyterPkg: PythonPkgDetails = {
@@ -107,6 +108,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
private _pythonExecutable: string;
private _usingExistingPython: boolean;
private _usingConda: boolean;
private _installedPythonVersion: string;
private _installInProgress: boolean;
private _installCompletion: Deferred<void>;
@@ -356,6 +358,7 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
if (pythonUserDir) {
this.pythonEnvVarPath = pythonUserDir + delimiter + this.pythonEnvVarPath;
}
this._installedPythonVersion = await this.getInstalledPythonVersion(this._pythonExecutable);
}
// Store the executable options to run child processes with env var without interfering parent env var.
@@ -652,6 +655,10 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
return this._usingConda;
}
public get installedPythonVersion(): string {
return this._installedPythonVersion;
}
private isCondaInstalled(): boolean {
let condaExePath = this.getCondaExePath();
// eslint-disable-next-line no-sync
@@ -740,6 +747,12 @@ export class JupyterServerInstallation implements IJupyterServerInstallation {
return undefined;
}
private async getInstalledPythonVersion(pythonExecutable: string): Promise<string> {
let cmd = `"${pythonExecutable}" -c "import platform;print(platform.python_version())"`;
let version = await utils.executeBufferedCommand(cmd, {});
return version?.trim() ?? '';
}
public getRequiredPackagesForKernel(kernelName: string): PythonPkgDetails[] {
return this._requiredKernelPackages.get(kernelName) ?? [];
}