From b2bd042470d60e8079df73c801933bf916965e9f Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Oct 2021 13:13:36 -0700 Subject: [PATCH 1/2] Use conda-forge when installing into conda envs (#17629) Co-authored-by: Brett Cannon --- news/2 Fixes/17628.md | 1 + src/client/common/installer/condaInstaller.ts | 22 ++++++++++++++----- .../installer/moduleInstaller.unit.test.ts | 11 +++++++++- 3 files changed, 28 insertions(+), 6 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..c74979541b11 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'; /** @@ -84,9 +84,21 @@ 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') { + // 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 ( + [ + 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) { diff --git a/src/test/common/installer/moduleInstaller.unit.test.ts b/src/test/common/installer/moduleInstaller.unit.test.ts index df0f734d32ed..8d786b22b5a1 100644 --- a/src/test/common/installer/moduleInstaller.unit.test.ts +++ b/src/test/common/installer/moduleInstaller.unit.test.ts @@ -621,7 +621,16 @@ suite('Module Installer', () => { test(`Test args (${product.name})`, async () => { setActiveInterpreter(); const expectedArgs = [isUpgrade ? 'update' : 'install']; - if (product.name === 'tensorboard') { + if ( + [ + 'pandas', + 'tensorboard', + 'ipykernel', + 'jupyter', + 'notebook', + 'nbconvert', + ].includes(product.name) + ) { expectedArgs.push('-c', 'conda-forge'); } if (condaEnvInfo && condaEnvInfo.name) { From ad540368565a309bc9b405ca56b5079010eef79b Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 5 Oct 2021 13:17:36 -0700 Subject: [PATCH 2/2] Update change log --- CHANGELOG.md | 2 ++ news/2 Fixes/17628.md | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 news/2 Fixes/17628.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 28994a27f4d0..f548ab091f45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,8 @@ ([#17563](https://github.com/Microsoft/vscode-python/issues/17563)) 1. Add timeout when discovery runs `conda info --json` command. ([#17576](https://github.com/Microsoft/vscode-python/issues/17576)) +1. Use `conda-forge` channel when installing packages into conda environments. + ([#17628](https://github.com/Microsoft/vscode-python/issues/17628)) ### Code Health diff --git a/news/2 Fixes/17628.md b/news/2 Fixes/17628.md deleted file mode 100644 index db34bdcc74e7..000000000000 --- a/news/2 Fixes/17628.md +++ /dev/null @@ -1 +0,0 @@ -Use `conda-forge` channel when installing packages into conda environments.