Skip to content

Commit

Permalink
Fixes to comparing of Python environments (#23417)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Jun 24, 2024
1 parent 268c2eb commit 50fd008
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 50fd008

Please sign in to comment.