@@ -13,7 +13,7 @@ import { IFileSystem, IPlatformService } from '../../../../common/platform/types
1313import { IProcessServiceFactory } from '../../../../common/process/types' ;
1414import { IConfigurationService , IDisposableRegistry , IPersistentStateFactory } from '../../../../common/types' ;
1515import { cache } from '../../../../common/utils/decorators' ;
16- import { ICondaService , IInterpreterLocatorService , WINDOWS_REGISTRY_SERVICE } from '../../../../interpreter/contracts' ;
16+ import { IComponentAdapter , ICondaService , IInterpreterLocatorService , WINDOWS_REGISTRY_SERVICE } from '../../../../interpreter/contracts' ;
1717import { EnvironmentType , PythonEnvironment } from '../../../info' ;
1818import { CondaEnvironmentInfo , CondaInfo } from './conda' ;
1919import { parseCondaEnvFileContents } from './condaHelper' ;
@@ -49,6 +49,12 @@ export const CondaLocationsGlobWin = `{${condaGlobPathsForWindows.join(',')}}`;
4949
5050export const CondaGetEnvironmentPrefix = 'Outputting Environment Now...' ;
5151
52+ // The parts of IComponentAdapter used here.
53+ interface IComponent {
54+ isCondaEnvironment ( interpreterPath : string ) : Promise < boolean | undefined > ;
55+ getCondaEnvironment ( interpreterPath : string ) : Promise < CondaEnvironmentInfo | undefined > ;
56+ }
57+
5258/**
5359 * A wrapper around a conda installation.
5460 */
@@ -66,6 +72,7 @@ export class CondaService implements ICondaService {
6672 @inject ( IConfigurationService ) private configService : IConfigurationService ,
6773 @inject ( IDisposableRegistry ) private disposableRegistry : IDisposableRegistry ,
6874 @inject ( IWorkspaceService ) private readonly workspaceService : IWorkspaceService ,
75+ @inject ( IComponentAdapter ) private readonly pyenvs : IComponent ,
6976 @inject ( IInterpreterLocatorService )
7077 @named ( WINDOWS_REGISTRY_SERVICE )
7178 @optional ( )
@@ -183,6 +190,10 @@ export class CondaService implements ICondaService {
183190 * @memberof CondaService
184191 */
185192 public async isCondaEnvironment ( interpreterPath : string ) : Promise < boolean > {
193+ const result = await this . pyenvs . isCondaEnvironment ( interpreterPath ) ;
194+ if ( result !== undefined ) {
195+ return result ;
196+ }
186197 const dir = path . dirname ( interpreterPath ) ;
187198 const { isWindows } = this . platform ;
188199 const condaMetaDirectory = isWindows ? path . join ( dir , 'conda-meta' ) : path . join ( dir , '..' , 'conda-meta' ) ;
@@ -193,6 +204,10 @@ export class CondaService implements ICondaService {
193204 * Return (env name, interpreter filename) for the interpreter.
194205 */
195206 public async getCondaEnvironment ( interpreterPath : string ) : Promise < { name : string ; path : string } | undefined > {
207+ const found = await this . pyenvs . getCondaEnvironment ( interpreterPath ) ;
208+ if ( found !== undefined ) {
209+ return found ;
210+ }
196211 const isCondaEnv = await this . isCondaEnvironment ( interpreterPath ) ;
197212 if ( ! isCondaEnv ) {
198213 return ;
0 commit comments