@@ -182,20 +182,30 @@ function isLocalPipenvEnvironment(interpreterPath: string): boolean {
182
182
* Returns true if interpreter path belongs to a global pipenv environment created for a particular project,
183
183
* false otherwise.
184
184
* @param interpreterPath Absolute path to any python interpreter.
185
- * @param cwd Absolute path to the project.
185
+ * @param project Absolute path to the project.
186
186
*/
187
- async function isGlobalPipenvEnvironmentRelatedToProject ( interpreterPath : string , cwd : string ) : Promise < boolean > {
187
+ async function isGlobalPipenvEnvironmentRelatedToProject ( interpreterPath : string , project : string ) : Promise < boolean > {
188
188
// PIPENV_NO_INHERIT is used to tell pipenv not to look for Pipfile in parent directories
189
189
// https://pipenv.pypa.io/en/latest/advanced/#pipenv.environments.PIPENV_NO_INHERIT
190
- if ( ! checkIfPipFileExists ( cwd , ! process . env . PIPENV_NO_INHERIT ) ) {
190
+ if ( ! checkIfPipFileExists ( project , ! process . env . PIPENV_NO_INHERIT ) ) {
191
191
return false ;
192
192
}
193
193
194
- // In PipEnv, for global environments the name of the cwd is used as a prefix in the virtual env.
195
- if ( interpreterPath . indexOf ( `${ path . sep } ${ path . basename ( cwd ) } -` ) === - 1 ) {
196
- return false ;
194
+ /**
195
+ * Global pipenv environments can be stored in 3 possible locations:
196
+ * * WORKON_HOME environment variable: https://pipenv-fork.readthedocs.io/en/latest/advanced.html#custom-virtual-environment-location
197
+ * * ~/.virtualenvs - for windows
198
+ * * ~/.local/share/virtualenvs
199
+ *
200
+ * The name of the project is used as a prefix in the virtual env. We're assuming it's unique enough
201
+ * detail so we don't have further ensure that the environment exists within these locations.
202
+ */
203
+ if ( interpreterPath . indexOf ( `${ path . sep } ${ path . basename ( project ) } -` ) !== - 1 ) {
204
+ // Note it's still possible that this virtual environment belongs to another project with the same name,
205
+ // and not this project. But the type of environment would still be pipenv, so we need not care.
206
+ return true ;
197
207
}
198
- return true ;
208
+ return false ;
199
209
}
200
210
201
211
/**
0 commit comments