Skip to content

Commit 8b3b976

Browse files
committed
Fix for conda activation during testing
1 parent 9be9308 commit 8b3b976

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/client/pythonEnvironments/nativeAPI.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ function toArch(a: string | undefined): Architecture {
5555
}
5656

5757
function 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

Comments
 (0)