Skip to content

Commit 127ef2d

Browse files
Use conda-forge when installing into conda envs (#17629)
Co-authored-by: Brett Cannon <brcan@microsoft.com>
1 parent 3714120 commit 127ef2d

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

news/2 Fixes/17628.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `conda-forge` channel when installing packages into conda environments.

src/client/common/installer/condaInstaller.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { ICondaService, ICondaLocatorService, IComponentAdapter } from '../../in
77
import { IServiceContainer } from '../../ioc/types';
88
import { ModuleInstallerType } from '../../pythonEnvironments/info';
99
import { inDiscoveryExperiment } from '../experiments/helpers';
10-
import { ExecutionInfo, IConfigurationService, IExperimentService } from '../types';
10+
import { ExecutionInfo, IConfigurationService, IExperimentService, Product } from '../types';
1111
import { isResource } from '../utils/misc';
12-
import { ModuleInstaller } from './moduleInstaller';
12+
import { ModuleInstaller, translateProductToModule } from './moduleInstaller';
1313
import { InterpreterUri, ModuleInstallFlags } from './types';
1414

1515
/**
@@ -84,9 +84,21 @@ export class CondaInstaller extends ModuleInstaller {
8484
const info = await condaLocatorService.getCondaEnvironment(pythonPath);
8585
const args = [flags & ModuleInstallFlags.upgrade ? 'update' : 'install'];
8686

87-
// Temporarily ensure tensorboard is installed from the conda-forge
88-
// channel since 2.4.1 is not yet available in the default index
89-
if (moduleName === 'tensorboard') {
87+
// Found that using conda-forge is best at packages like tensorboard & ipykernel which seem to get updated first on conda-forge
88+
// https://github.com/microsoft/vscode-jupyter/issues/7787 & https://github.com/microsoft/vscode-python/issues/17628
89+
// Do this just for the datascience packages.
90+
if (
91+
[
92+
Product.tensorboard,
93+
Product.ipykernel,
94+
Product.pandas,
95+
Product.nbconvert,
96+
Product.jupyter,
97+
Product.notebook,
98+
]
99+
.map(translateProductToModule)
100+
.includes(moduleName)
101+
) {
90102
args.push('-c', 'conda-forge');
91103
}
92104
if (info && info.name) {

src/test/common/installer/moduleInstaller.unit.test.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,16 @@ suite('Module Installer', () => {
621621
test(`Test args (${product.name})`, async () => {
622622
setActiveInterpreter();
623623
const expectedArgs = [isUpgrade ? 'update' : 'install'];
624-
if (product.name === 'tensorboard') {
624+
if (
625+
[
626+
'pandas',
627+
'tensorboard',
628+
'ipykernel',
629+
'jupyter',
630+
'notebook',
631+
'nbconvert',
632+
].includes(product.name)
633+
) {
625634
expectedArgs.push('-c', 'conda-forge');
626635
}
627636
if (condaEnvInfo && condaEnvInfo.name) {

0 commit comments

Comments
 (0)