Skip to content

Commit 2e68c0e

Browse files
author
Kartik Raj
committed
Commit .venv folder
1 parent 4cf3644 commit 2e68c0e

File tree

2 files changed

+22
-25
lines changed
  • src
    • client/pythonEnvironments/discovery/locators/services
    • test/pythonEnvironments/common/envlayouts/pipenv/project1/.venv/Scripts

2 files changed

+22
-25
lines changed

src/client/pythonEnvironments/discovery/locators/services/pipEnvHelper.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { pathExists } from 'fs-extra';
54
import * as path from 'path';
65
import { getEnvironmentVariable } from '../../../../common/utils/platform';
7-
import { readFile } from '../../../common/externalDependencies';
6+
import { pathExists, readFile } from '../../../common/externalDependencies';
87

98
/**
109
* Returns the path to Pipfile associated with the provided directory.
@@ -39,29 +38,6 @@ async function getAssociatedPipfile(
3938
return undefined;
4039
}
4140

42-
/**
43-
* Returns true if interpreter path belongs to a global pipenv environment which is associated with a particular folder,
44-
* false otherwise.
45-
* @param interpreterPath Absolute path to any python interpreter.
46-
*/
47-
export async function isPipenvEnvironmentRelatedToFolder(interpreterPath: string, folder: string): Promise<boolean> {
48-
const pipFileCorrespondingToEnvironment = await getPipfileIfGlobalPipenvEnvironment(interpreterPath);
49-
if (!pipFileCorrespondingToEnvironment) {
50-
return false;
51-
}
52-
const projectCorrespondingToEnvironment = path.dirname(pipFileCorrespondingToEnvironment);
53-
54-
// PIPENV_NO_INHERIT is used to tell pipenv not to look for Pipfile in parent directories
55-
// https://pipenv.pypa.io/en/latest/advanced/#pipenv.environments.PIPENV_NO_INHERIT
56-
const pipFile = await getAssociatedPipfile(folder, !getEnvironmentVariable('PIPENV_NO_INHERIT'));
57-
if (!pipFile) {
58-
return false;
59-
}
60-
const projectCorrespondingToFolder = path.dirname(pipFile);
61-
62-
return projectCorrespondingToEnvironment === projectCorrespondingToFolder;
63-
}
64-
6541
/**
6642
* If interpreter path belongs to a pipenv environment which is located inside a project, return associated Pipfile,
6743
* otherwise return `undefined`.
@@ -129,3 +105,23 @@ export async function isPipenvEnvironment(interpreterPath: string): Promise<bool
129105
}
130106
return false;
131107
}
108+
109+
/**
110+
* Returns true if interpreter path belongs to a global pipenv environment which is associated with a particular folder,
111+
* false otherwise.
112+
* @param interpreterPath Absolute path to any python interpreter.
113+
*/
114+
export async function isPipenvEnvironmentRelatedToFolder(interpreterPath: string, folder: string): Promise<boolean> {
115+
const pipFileAssociatedWithEnvironment = await getPipfileIfGlobalPipenvEnvironment(interpreterPath);
116+
if (!pipFileAssociatedWithEnvironment) {
117+
return false;
118+
}
119+
120+
// PIPENV_NO_INHERIT is used to tell pipenv not to look for Pipfile in parent directories
121+
// https://pipenv.pypa.io/en/latest/advanced/#pipenv.environments.PIPENV_NO_INHERIT
122+
const pipFileAssociatedWithFolder = await getAssociatedPipfile(folder, !getEnvironmentVariable('PIPENV_NO_INHERIT'));
123+
if (!pipFileAssociatedWithFolder) {
124+
return false;
125+
}
126+
return pipFileAssociatedWithEnvironment === pipFileAssociatedWithFolder;
127+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Not real python exe

0 commit comments

Comments
 (0)