Skip to content

Commit a8bf65a

Browse files
authored
Merge pull request #4284 from pypa/bugfix/4276
Fix incorrect environment when inside venv
2 parents 800155f + 08ec79d commit a8bf65a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

news/4276.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that system-wide packages will be considered when inside a venv.

pipenv/project.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ def pipfile_package_names(self):
330330

331331
def get_environment(self, allow_global=False):
332332
# type: (bool) -> Environment
333-
if allow_global:
333+
is_venv = is_in_virtualenv()
334+
if allow_global and not is_venv:
334335
prefix = sys.prefix
335336
else:
336337
prefix = self.virtualenv_location
337-
is_venv = is_in_virtualenv()
338338
sources = self.sources if self.sources else [DEFAULT_SOURCE]
339339
environment = Environment(
340340
prefix=prefix, is_venv=is_venv, sources=sources, pipfile=self.parsed_pipfile,

0 commit comments

Comments
 (0)