From 2ff15ec1a118beee5f73575ef5123a98894bfad2 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Oct 2021 11:22:07 -0700 Subject: [PATCH 1/4] Use conda-forge when installing into conda envs --- news/2 Fixes/17628.md | 1 + src/client/common/installer/condaInstaller.ts | 8 +++----- src/test/common/installer/moduleInstaller.unit.test.ts | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 news/2 Fixes/17628.md diff --git a/news/2 Fixes/17628.md b/news/2 Fixes/17628.md new file mode 100644 index 000000000000..db34bdcc74e7 --- /dev/null +++ b/news/2 Fixes/17628.md @@ -0,0 +1 @@ +Use `conda-forge` channel when installing packages into conda environments. diff --git a/src/client/common/installer/condaInstaller.ts b/src/client/common/installer/condaInstaller.ts index 950bc896e879..336ec5a875e9 100644 --- a/src/client/common/installer/condaInstaller.ts +++ b/src/client/common/installer/condaInstaller.ts @@ -84,11 +84,9 @@ export class CondaInstaller extends ModuleInstaller { const info = await condaLocatorService.getCondaEnvironment(pythonPath); const args = [flags & ModuleInstallFlags.upgrade ? 'update' : 'install']; - // Temporarily ensure tensorboard is installed from the conda-forge - // channel since 2.4.1 is not yet available in the default index - if (moduleName === 'tensorboard') { - args.push('-c', 'conda-forge'); - } + // Found that using conda-forge is best as packages like tensorboard, ipykenrle seem to get updated first on conda-forge + // https://github.com/microsoft/vscode-jupyter/issues/7787 & https://github.com/microsoft/vscode-python/issues/17628 + args.push('-c', 'conda-forge'); if (info && info.name) { // If we have the name of the conda environment, then use that. args.push('--name'); diff --git a/src/test/common/installer/moduleInstaller.unit.test.ts b/src/test/common/installer/moduleInstaller.unit.test.ts index df0f734d32ed..6ed8f14680c4 100644 --- a/src/test/common/installer/moduleInstaller.unit.test.ts +++ b/src/test/common/installer/moduleInstaller.unit.test.ts @@ -621,9 +621,7 @@ suite('Module Installer', () => { test(`Test args (${product.name})`, async () => { setActiveInterpreter(); const expectedArgs = [isUpgrade ? 'update' : 'install']; - if (product.name === 'tensorboard') { - expectedArgs.push('-c', 'conda-forge'); - } + expectedArgs.push('-c', 'conda-forge'); if (condaEnvInfo && condaEnvInfo.name) { expectedArgs.push('--name'); expectedArgs.push(condaEnvInfo.name.toCommandArgument()); From 7f45589e6860312e6a6533aa4b2978afb8d944ec Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Oct 2021 11:58:46 -0700 Subject: [PATCH 2/4] Use conda-forge for all DS pacakges --- src/client/common/installer/condaInstaller.ts | 20 ++++++++++++++++--- .../installer/moduleInstaller.unit.test.ts | 15 ++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/client/common/installer/condaInstaller.ts b/src/client/common/installer/condaInstaller.ts index 336ec5a875e9..7c2b1809bce9 100644 --- a/src/client/common/installer/condaInstaller.ts +++ b/src/client/common/installer/condaInstaller.ts @@ -7,9 +7,9 @@ import { ICondaService, ICondaLocatorService, IComponentAdapter } from '../../in import { IServiceContainer } from '../../ioc/types'; import { ModuleInstallerType } from '../../pythonEnvironments/info'; import { inDiscoveryExperiment } from '../experiments/helpers'; -import { ExecutionInfo, IConfigurationService, IExperimentService } from '../types'; +import { ExecutionInfo, IConfigurationService, IExperimentService, Product } from '../types'; import { isResource } from '../utils/misc'; -import { ModuleInstaller } from './moduleInstaller'; +import { ModuleInstaller, translateProductToModule } from './moduleInstaller'; import { InterpreterUri, ModuleInstallFlags } from './types'; /** @@ -86,7 +86,21 @@ export class CondaInstaller extends ModuleInstaller { // Found that using conda-forge is best as packages like tensorboard, ipykenrle seem to get updated first on conda-forge // https://github.com/microsoft/vscode-jupyter/issues/7787 & https://github.com/microsoft/vscode-python/issues/17628 - args.push('-c', 'conda-forge'); + // Do this just for the datascience packages. + if ( + [ + Product.tensorboard, + Product.ipykernel, + Product.pandas, + Product.nbconvert, + Product.jupyter, + Product.notebook, + ] + .map(translateProductToModule) + .includes(moduleName) + ) { + args.push('-c', 'conda-forge'); + } if (info && info.name) { // If we have the name of the conda environment, then use that. args.push('--name'); diff --git a/src/test/common/installer/moduleInstaller.unit.test.ts b/src/test/common/installer/moduleInstaller.unit.test.ts index 6ed8f14680c4..8b1df9b2efaa 100644 --- a/src/test/common/installer/moduleInstaller.unit.test.ts +++ b/src/test/common/installer/moduleInstaller.unit.test.ts @@ -68,7 +68,7 @@ Combinations of: 6. Conda environments with names and without names. 7. All installers. */ -suite('Module Installer', () => { +suite.only('Module Installer', () => { class TestModuleInstaller extends ModuleInstaller { public get priority(): number { return 0; @@ -621,7 +621,18 @@ suite('Module Installer', () => { test(`Test args (${product.name})`, async () => { setActiveInterpreter(); const expectedArgs = [isUpgrade ? 'update' : 'install']; - expectedArgs.push('-c', 'conda-forge'); + if ( + [ + 'pandas', + 'tensorboard', + 'ipykernel', + 'jupyter', + 'notebook', + 'nbconvert', + ].includes(product.name) + ) { + expectedArgs.push('-c', 'conda-forge'); + } if (condaEnvInfo && condaEnvInfo.name) { expectedArgs.push('--name'); expectedArgs.push(condaEnvInfo.name.toCommandArgument()); From 1671a5188e193fceaf54a624875f4f61834f2f55 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Oct 2021 12:00:20 -0700 Subject: [PATCH 3/4] oops --- src/test/common/installer/moduleInstaller.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/common/installer/moduleInstaller.unit.test.ts b/src/test/common/installer/moduleInstaller.unit.test.ts index 8b1df9b2efaa..8d786b22b5a1 100644 --- a/src/test/common/installer/moduleInstaller.unit.test.ts +++ b/src/test/common/installer/moduleInstaller.unit.test.ts @@ -68,7 +68,7 @@ Combinations of: 6. Conda environments with names and without names. 7. All installers. */ -suite.only('Module Installer', () => { +suite('Module Installer', () => { class TestModuleInstaller extends ModuleInstaller { public get priority(): number { return 0; From 8bfa85bea0cbab18eb79c361053544ec070a4762 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Oct 2021 12:05:34 -0700 Subject: [PATCH 4/4] Update src/client/common/installer/condaInstaller.ts Co-authored-by: Brett Cannon --- src/client/common/installer/condaInstaller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/common/installer/condaInstaller.ts b/src/client/common/installer/condaInstaller.ts index 7c2b1809bce9..c74979541b11 100644 --- a/src/client/common/installer/condaInstaller.ts +++ b/src/client/common/installer/condaInstaller.ts @@ -84,7 +84,7 @@ export class CondaInstaller extends ModuleInstaller { const info = await condaLocatorService.getCondaEnvironment(pythonPath); const args = [flags & ModuleInstallFlags.upgrade ? 'update' : 'install']; - // Found that using conda-forge is best as packages like tensorboard, ipykenrle seem to get updated first on conda-forge + // Found that using conda-forge is best at packages like tensorboard & ipykernel which seem to get updated first on conda-forge // https://github.com/microsoft/vscode-jupyter/issues/7787 & https://github.com/microsoft/vscode-python/issues/17628 // Do this just for the datascience packages. if (