@@ -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 }
@@ -206,6 +210,32 @@ function toPythonEnvInfo(nativeEnv: NativeEnvInfo): PythonEnvInfo | undefined {
206210 } ;
207211}
208212
213+ function hasChanged ( old : PythonEnvInfo , newEnv : PythonEnvInfo ) : boolean {
214+ if ( old . executable . filename !== newEnv . executable . filename ) {
215+ return true ;
216+ }
217+ if ( old . version . major !== newEnv . version . major ) {
218+ return true ;
219+ }
220+ if ( old . version . minor !== newEnv . version . minor ) {
221+ return true ;
222+ }
223+ if ( old . version . micro !== newEnv . version . micro ) {
224+ return true ;
225+ }
226+ if ( old . location !== newEnv . location ) {
227+ return true ;
228+ }
229+ if ( old . kind !== newEnv . kind ) {
230+ return true ;
231+ }
232+ if ( old . arch !== newEnv . arch ) {
233+ return true ;
234+ }
235+
236+ return false ;
237+ }
238+
209239class NativePythonEnvironments implements IDiscoveryAPI , Disposable {
210240 private _onProgress : EventEmitter < ProgressNotificationEvent > ;
211241
@@ -354,7 +384,7 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
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 && 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