Skip to content

Commit

Permalink
Merge pull request #5518 from pypa/issue-5101
Browse files Browse the repository at this point in the history
Fix issue with venv module not being available on some systems.
  • Loading branch information
oz123 authored Dec 3, 2022
2 parents c153b77 + 35cd3f1 commit 02df412
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions news/5477.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check if ``venv`` module is available and fallback to prior logic when it is not.
30 changes: 21 additions & 9 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,15 +989,27 @@ def do_create_virtualenv(project, python=None, site_packages=None, pypi_mirror=N
err=True,
)

cmd = [
Path(sys.executable).absolute().as_posix(),
"-m",
"virtualenv",
"--creator=venv",
f"--prompt={project.name}",
f"--python={python}",
project.get_location_for_virtualenv(),
]
try:
import venv # noqa

cmd = [
Path(sys.executable).absolute().as_posix(),
"-m",
"virtualenv",
"--creator=venv",
f"--prompt={project.name}",
f"--python={python}",
project.get_location_for_virtualenv(),
]
except ImportError:
cmd = [
Path(sys.executable).absolute().as_posix(),
"-m",
"virtualenv",
f"--prompt={project.name}",
f"--python={python}",
project.get_location_for_virtualenv(),
]

# Pass site-packages flag to virtualenv, if desired...
if site_packages:
Expand Down

0 comments on commit 02df412

Please sign in to comment.