Skip to content

Commit

Permalink
Fixes to comparing of Python environments (microsoft#23417)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored and anthonykim1 committed May 16, 2024
1 parent 61c55c8 commit 43581b9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/client/pythonEnvironments/base/info/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,20 @@ export function areSameEnv(
if (leftInfo === undefined || rightInfo === undefined) {
return undefined;
}
const leftFilename = leftInfo.executable!.filename;
const rightFilename = rightInfo.executable!.filename;

if (
(leftInfo.executable?.filename && !rightInfo.executable?.filename) ||
(!leftInfo.executable?.filename && rightInfo.executable?.filename)
) {
return false;
}
if (leftInfo.id && leftInfo.id === rightInfo.id) {
// In case IDs are available, use it.
return true;
}

const leftFilename = leftInfo.executable!.filename;
const rightFilename = rightInfo.executable!.filename;

if (getEnvID(leftFilename, leftInfo.location) === getEnvID(rightFilename, rightInfo.location)) {
// Otherwise use ID function to get the ID. Note ID returned by function may itself change if executable of
// an environment changes, for eg. when conda installs python into the env. So only use it as a fallback if
Expand Down

0 comments on commit 43581b9

Please sign in to comment.