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/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) {