2
0
mirror of https://github.com/frappe/bench.git synced 2024-06-26 19:23:30 +00:00

Merge pull request #1339 from alyf-de/python-venv

fix: use specified python for venv
This commit is contained in:
gavin 2022-07-28 21:54:20 +05:30 committed by GitHub
commit c71ba2b27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -354,7 +354,7 @@ class BenchSetup(Base):
if virtualenv:
self.run(f"{virtualenv} {quiet_flag} env -p {python}")
else:
venv = get_venv_path(verbose=verbose)
venv = get_venv_path(verbose=verbose, python=python)
self.run(f"{venv} env")
self.pip()

View File

@ -32,14 +32,13 @@ def get_virtualenv_path(verbose=False):
return virtualenv_path
def get_venv_path(verbose=False):
current_python = sys.executable
def get_venv_path(verbose=False, python="python3"):
with open(os.devnull, "wb") as devnull:
is_venv_installed = not subprocess.call(
[current_python, "-m", "venv", "--help"], stdout=devnull
[python, "-m", "venv", "--help"], stdout=devnull
)
if is_venv_installed:
return f"{current_python} -m venv"
return f"{python} -m venv"
else:
log("virtualenv cannot be found", level=2)