@@ -55,6 +55,10 @@ function toArch(a: string | undefined): Architecture {
5555}
5656
5757function getLocation ( nativeEnv : NativeEnvInfo , executable : string ) : string {
58+ if ( nativeEnv . kind === NativePythonEnvironmentKind . Conda ) {
59+ return nativeEnv . prefix ?? path . dirname ( executable ) ;
60+ }
61+
5862 if ( nativeEnv . executable ) {
5963 return nativeEnv . executable ;
6064 }
@@ -350,11 +354,37 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
350354 return this . _envs ;
351355 }
352356
357+ private hasChanged ( old : PythonEnvInfo , newEnv : PythonEnvInfo ) : boolean {
358+ if ( old . executable . filename !== newEnv . executable . filename ) {
359+ return true ;
360+ }
361+ if ( old . version . major !== newEnv . version . major ) {
362+ return true ;
363+ }
364+ if ( old . version . minor !== newEnv . version . minor ) {
365+ return true ;
366+ }
367+ if ( old . version . micro !== newEnv . version . micro ) {
368+ return true ;
369+ }
370+ if ( old . location !== newEnv . location ) {
371+ return true ;
372+ }
373+ if ( old . kind !== newEnv . kind ) {
374+ return true ;
375+ }
376+ if ( old . arch !== newEnv . arch ) {
377+ return true ;
378+ }
379+
380+ return false ;
381+ }
382+
353383 private addEnv ( native : NativeEnvInfo , searchLocation ?: Uri ) : PythonEnvInfo | undefined {
354384 const info = toPythonEnvInfo ( native ) ;
355385 if ( info ) {
356386 const old = this . _envs . find ( ( item ) => item . executable . filename === info . executable . filename ) ;
357- if ( old ) {
387+ if ( old && this . hasChanged ( old , info ) ) {
358388 this . _envs = this . _envs . filter ( ( item ) => item . executable . filename !== info . executable . filename ) ;
359389 this . _envs . push ( info ) ;
360390 this . _onChanged . fire ( { type : FileChangeType . Changed , old, new : info , searchLocation } ) ;
0 commit comments