Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more comments
  • Loading branch information
karthiknadig committed Sep 28, 2020
commit 4cdfcb01a598f6f8f4afa5791de71d178ae6fa62
16 changes: 14 additions & 2 deletions src/client/pythonEnvironments/base/info/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ import { Architecture } from '../../../common/utils/platform';
import { arePathsSame } from '../../common/externalDependencies';
import { areEqualVersions, areEquivalentVersions } from './pythonVersion';

/**
* Checks if two environments are same.
* @param {string | PythonEnvInfo} left: environment to compare.
* @param {string | PythonEnvInfo} right: environment to compare.
* @param {boolean} allowPartialMatch: allow partial matches of properties when comparing.
*
* Remarks: The current comparison assumes that if the path to the executables are the same
* then it is the same environment. Additionally, if the paths are not same but executables
* are in the same directory and the version of python is the same than we can assume it
* to be same environment. This later case is needed for comparing windows store python,
* where multiple versions of python executables are all put in the same directory.
*/
export function areSameEnvironment(
left: string | PythonEnvInfo,
right: string | PythonEnvInfo,
allowPartialMatch?:boolean,
allowPartialMatch?: boolean,
): boolean {
const leftFilename = typeof left === 'string' ? left : left.executable.filename;
const rightFilename = typeof right === 'string' ? right : right.executable.filename;
Expand Down Expand Up @@ -88,7 +100,7 @@ function getFileInfoHeuristic(file:FileInfo): number {
infoLevel += 2; // W1
}

if (file.ctime || file.mtime) {
if (file.ctime) {
infoLevel += 1; // W0
}
Comment thread
karthiknadig marked this conversation as resolved.

Expand Down
8 changes: 1 addition & 7 deletions src/client/pythonEnvironments/base/info/pythonVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ export function parseVersion(versionStr: string): PythonVersion {
* @returns {boolean}
*/
export function areEqualVersions(left: PythonVersion, right:PythonVersion): boolean {
return (
left.major === right.major
&& left.minor === right.minor
&& left.micro === right.micro
&& left.release.level === right.release.level
&& left.release.serial === right.release.serial
);
return left === right;
}

/**
Expand Down