Skip to content

Commit 1ee635a

Browse files
committed
Allow creating the virtual environments with venv
As a fallback if `virtualenv` is not available. Fixes #15 Signed-off-by: Pedro Algarvio <[email protected]>
1 parent d817d75 commit 1ee635a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

changelog/15.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow creating the virtual environments with `venv` as a fallback if `virtualenv` is not available.

src/ptscripts/virtualenv.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,17 @@ def _create_virtualenv(self):
151151
self.ctx.debug("Virtual environment path already exists")
152152
return
153153
virtualenv = shutil.which("virtualenv")
154-
if not virtualenv:
155-
raise FileNotFoundError("'virtualenv' binary not found")
156-
cmd = [
157-
virtualenv,
158-
f"--python={self.get_real_python()}",
159-
]
154+
if virtualenv:
155+
cmd = [
156+
virtualenv,
157+
f"--python={self.get_real_python()}",
158+
]
159+
else:
160+
cmd = [
161+
self.get_real_python(),
162+
"-m",
163+
"venv",
164+
]
160165
if self.system_site_packages:
161166
cmd.append("--system-site-packages")
162167
cmd.append(str(self.venv_dir))

0 commit comments

Comments
 (0)