mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-19 03:21:36 -04:00
Allow user to select source package type in Manage Packages dialog. (#6092)
This commit is contained in:
@@ -12,7 +12,7 @@ const localize = nls.loadMessageBundle();
|
||||
|
||||
import * as constants from '../common/constants';
|
||||
import * as localizedConstants from '../common/localizedConstants';
|
||||
import JupyterServerInstallation from './jupyterServerInstallation';
|
||||
import { JupyterServerInstallation } from './jupyterServerInstallation';
|
||||
import { IServerInstance } from './common';
|
||||
import * as utils from '../common/utils';
|
||||
import { IPrompter, QuestionTypes, IQuestion } from '../prompts/question';
|
||||
@@ -210,20 +210,6 @@ export class JupyterController implements vscode.Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
public getTextToSendToTerminal(shellType: any): string {
|
||||
if (utils.getOSPlatform() === utils.Platform.Windows && typeof shellType === 'string') {
|
||||
if (shellType.endsWith('powershell.exe')) {
|
||||
return localizedConstants.msgManagePackagesPowershell;
|
||||
} else if (shellType.endsWith('cmd.exe')) {
|
||||
return localizedConstants.msgManagePackagesCmd;
|
||||
} else {
|
||||
return localizedConstants.msgManagePackagesBash;
|
||||
}
|
||||
} else {
|
||||
return localizedConstants.msgManagePackagesBash;
|
||||
}
|
||||
}
|
||||
|
||||
public get jupyterInstallation() {
|
||||
return this._jupyterInstallation;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ const msgSkipPythonInstall = localize('msgSkipPythonInstall', "Python already ex
|
||||
function msgDependenciesInstallationFailed(errorMessage: string): string { return localize('msgDependenciesInstallationFailed', "Installing Notebook dependencies failed with error: {0}", errorMessage); }
|
||||
function msgDownloadPython(platform: string, pythonDownloadUrl: string): string { return localize('msgDownloadPython', "Downloading local python for platform: {0} to {1}", platform, pythonDownloadUrl); }
|
||||
|
||||
export default class JupyterServerInstallation {
|
||||
export class JupyterServerInstallation {
|
||||
public apiWrapper: ApiWrapper;
|
||||
public extensionPath: string;
|
||||
public pythonBinPath: string;
|
||||
@@ -86,11 +86,11 @@ export default class JupyterServerInstallation {
|
||||
backgroundOperation.updateStatus(azdata.TaskStatus.InProgress, msgPythonDownloadComplete);
|
||||
|
||||
if (this._usingConda) {
|
||||
await this.installCondaPackages();
|
||||
await this.installCondaDependencies();
|
||||
} else if (this._usingExistingPython) {
|
||||
await this.installPipPackages();
|
||||
await this.installPipDependencies();
|
||||
} else {
|
||||
await this.installOfflinePipPackages();
|
||||
await this.installOfflinePipDependencies();
|
||||
}
|
||||
let doOnlineInstall = this._usingExistingPython;
|
||||
await this.installSparkMagic(doOnlineInstall);
|
||||
@@ -369,7 +369,36 @@ export default class JupyterServerInstallation {
|
||||
return this.executeStreamedCommand(cmd);
|
||||
}
|
||||
|
||||
private async installOfflinePipPackages(): Promise<void> {
|
||||
public async getInstalledCondaPackages(): Promise<PythonPkgDetails[]> {
|
||||
let condaExe = this.getCondaExePath();
|
||||
let cmd = `"${condaExe}" list --json`;
|
||||
let packagesInfo = await this.executeBufferedCommand(cmd);
|
||||
|
||||
if (packagesInfo) {
|
||||
let packagesResult = JSON.parse(packagesInfo);
|
||||
if (Array.isArray(packagesResult)) {
|
||||
return packagesResult
|
||||
.filter(pkg => pkg && pkg.channel && pkg.channel !== 'pypi')
|
||||
.map(pkg => <PythonPkgDetails>{ name: pkg.name, version: pkg.version });
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public installCondaPackage(packageName: string, version: string): Promise<void> {
|
||||
let condaExe = this.getCondaExePath();
|
||||
let cmd = `"${condaExe}" install -y ${packageName}==${version}`;
|
||||
return this.executeStreamedCommand(cmd);
|
||||
}
|
||||
|
||||
public uninstallCondaPackages(packages: PythonPkgDetails[]): Promise<void> {
|
||||
let condaExe = this.getCondaExePath();
|
||||
let packagesStr = packages.map(pkg => `${pkg.name}==${pkg.version}`).join(' ');
|
||||
let cmd = `"${condaExe}" uninstall -y ${packagesStr}`;
|
||||
return this.executeStreamedCommand(cmd);
|
||||
}
|
||||
|
||||
private async installOfflinePipDependencies(): Promise<void> {
|
||||
let installJupyterCommand: string;
|
||||
if (process.platform === constants.winPlatform) {
|
||||
let requirements = path.join(this._pythonPackageDir, 'requirements.txt');
|
||||
@@ -404,7 +433,7 @@ export default class JupyterServerInstallation {
|
||||
}
|
||||
}
|
||||
|
||||
private async installPipPackages(): Promise<void> {
|
||||
private async installPipDependencies(): Promise<void> {
|
||||
this.outputChannel.show(true);
|
||||
this.outputChannel.appendLine(localize('msgInstallStart', "Installing required packages to run Notebooks..."));
|
||||
|
||||
@@ -417,7 +446,7 @@ export default class JupyterServerInstallation {
|
||||
this.outputChannel.appendLine(localize('msgJupyterInstallDone', "... Jupyter installation complete."));
|
||||
}
|
||||
|
||||
private async installCondaPackages(): Promise<void> {
|
||||
private async installCondaDependencies(): Promise<void> {
|
||||
this.outputChannel.show(true);
|
||||
this.outputChannel.appendLine(localize('msgInstallStart', "Installing required packages to run Notebooks..."));
|
||||
|
||||
@@ -437,7 +466,7 @@ export default class JupyterServerInstallation {
|
||||
await utils.executeStreamedCommand(command, { env: this.execOptions.env }, this.outputChannel);
|
||||
}
|
||||
|
||||
private async executeBufferedCommand(command: string): Promise<string> {
|
||||
public async executeBufferedCommand(command: string): Promise<string> {
|
||||
return await utils.executeBufferedCommand(command, { env: this.execOptions.env });
|
||||
}
|
||||
|
||||
@@ -445,11 +474,15 @@ export default class JupyterServerInstallation {
|
||||
return this._pythonExecutable;
|
||||
}
|
||||
|
||||
private getCondaExePath(): string {
|
||||
public getCondaExePath(): string {
|
||||
return path.join(this._pythonInstallationPath,
|
||||
process.platform === constants.winPlatform ? 'Scripts\\conda.exe' : 'bin/conda');
|
||||
}
|
||||
|
||||
public get usingConda(): boolean {
|
||||
return this._usingConda;
|
||||
}
|
||||
|
||||
private checkCondaExists(): boolean {
|
||||
if (!this._usingExistingPython) {
|
||||
return false;
|
||||
@@ -526,11 +559,6 @@ export default class JupyterServerInstallation {
|
||||
pythonBinPathSuffix);
|
||||
}
|
||||
|
||||
public async getPythonPackagesPath(): Promise<string> {
|
||||
let cmd = `"${this.pythonExecutable}" -c "import site; print(site.getsitepackages()[0])"`;
|
||||
return await this.executeBufferedCommand(cmd);
|
||||
}
|
||||
|
||||
public static getPythonExePath(pythonInstallPath: string, useExistingInstall: boolean): string {
|
||||
return path.join(
|
||||
pythonInstallPath,
|
||||
@@ -542,4 +570,10 @@ export default class JupyterServerInstallation {
|
||||
export interface PythonPkgDetails {
|
||||
name: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface PipPackageOverview {
|
||||
name: string;
|
||||
versions: string[];
|
||||
summary: string;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
import JupyterServerInstallation from './jupyterServerInstallation';
|
||||
import { JupyterServerInstallation } from './jupyterServerInstallation';
|
||||
import * as utils from '../common/utils';
|
||||
import { IServerInstance } from './common';
|
||||
import { PerNotebookServerInstance, IInstanceOptions } from './serverInstance';
|
||||
|
||||
@@ -13,7 +13,7 @@ import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { IServerInstance } from './common';
|
||||
import JupyterServerInstallation from './jupyterServerInstallation';
|
||||
import { JupyterServerInstallation } from './jupyterServerInstallation';
|
||||
import * as utils from '../common/utils';
|
||||
import * as constants from '../common/constants';
|
||||
import * as notebookUtils from '../common/notebookUtils';
|
||||
|
||||
Reference in New Issue
Block a user