Skip to content

Commit

Permalink
Fix for conda activation during testing
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Oct 12, 2024
1 parent 9be9308 commit 8b3b976
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/client/pythonEnvironments/nativeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ function toArch(a: string | undefined): Architecture {
}

function getLocation(nativeEnv: NativeEnvInfo, executable: string): string {
if (nativeEnv.kind === NativePythonEnvironmentKind.Conda) {
return nativeEnv.prefix ?? path.dirname(executable);
}

if (nativeEnv.executable) {
return nativeEnv.executable;
}
Expand Down Expand Up @@ -350,11 +354,37 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
return this._envs;
}

private hasChanged(old: PythonEnvInfo, newEnv: PythonEnvInfo): boolean {

Check failure on line 357 in src/client/pythonEnvironments/nativeAPI.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected 'this' to be used by class method 'hasChanged'
if (old.executable.filename !== newEnv.executable.filename) {
return true;
}
if (old.version.major !== newEnv.version.major) {
return true;
}
if (old.version.minor !== newEnv.version.minor) {
return true;
}
if (old.version.micro !== newEnv.version.micro) {
return true;
}
if (old.location !== newEnv.location) {
return true;
}
if (old.kind !== newEnv.kind) {
return true;
}
if (old.arch !== newEnv.arch) {
return true;
}

return false;
}

private addEnv(native: NativeEnvInfo, searchLocation?: Uri): PythonEnvInfo | undefined {
const info = toPythonEnvInfo(native);
if (info) {
const old = this._envs.find((item) => item.executable.filename === info.executable.filename);
if (old) {
if (old && this.hasChanged(old, info)) {
this._envs = this._envs.filter((item) => item.executable.filename !== info.executable.filename);
this._envs.push(info);
this._onChanged.fire({ type: FileChangeType.Changed, old, new: info, searchLocation });
Expand Down

0 comments on commit 8b3b976

Please sign in to comment.