@@ -39,29 +39,6 @@ async function getAssociatedPipfile(
39
39
return undefined ;
40
40
}
41
41
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
-
65
42
/**
66
43
* If interpreter path belongs to a pipenv environment which is located inside a project, return associated Pipfile,
67
44
* otherwise return `undefined`.
@@ -129,3 +106,23 @@ export async function isPipenvEnvironment(interpreterPath: string): Promise<bool
129
106
}
130
107
return false ;
131
108
}
109
+
110
+ /**
111
+ * Returns true if interpreter path belongs to a global pipenv environment which is associated with a particular folder,
112
+ * false otherwise.
113
+ * @param interpreterPath Absolute path to any python interpreter.
114
+ */
115
+ export async function isPipenvEnvironmentRelatedToFolder ( interpreterPath : string , folder : string ) : Promise < boolean > {
116
+ const pipFileAssociatedWithEnvironment = await getPipfileIfGlobalPipenvEnvironment ( interpreterPath ) ;
117
+ if ( ! pipFileAssociatedWithEnvironment ) {
118
+ return false ;
119
+ }
120
+
121
+ // PIPENV_NO_INHERIT is used to tell pipenv not to look for Pipfile in parent directories
122
+ // https://pipenv.pypa.io/en/latest/advanced/#pipenv.environments.PIPENV_NO_INHERIT
123
+ const pipFileAssociatedWithFolder = await getAssociatedPipfile ( folder , ! getEnvironmentVariable ( 'PIPENV_NO_INHERIT' ) ) ;
124
+ if ( ! pipFileAssociatedWithFolder ) {
125
+ return false ;
126
+ }
127
+ return pipFileAssociatedWithEnvironment === pipFileAssociatedWithFolder ;
128
+ }
0 commit comments