From 0a020e1c06b40943b7bea239ab32744f115710c4 Mon Sep 17 00:00:00 2001 From: Sergey Borisov Date: Thu, 6 Apr 2023 04:24:25 +0300 Subject: [PATCH 1/2] Change pip upgrade command --- installer/lib/installer.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/installer/lib/installer.py b/installer/lib/installer.py index 3de0d90abd..eca0963fbf 100644 --- a/installer/lib/installer.py +++ b/installer/lib/installer.py @@ -144,8 +144,8 @@ class Installer: from plumbum import FG, local - pip = local[get_pip_from_venv(venv_dir)] - pip[ "install", "--upgrade", "pip"] & FG + pip = local[get_python_from_venv(venv_dir)] + pip[ "-m", "pip", "install", "--upgrade", "pip"] & FG return venv_dir @@ -412,6 +412,22 @@ def get_pip_from_venv(venv_path: Path) -> str: return str(venv_path.expanduser().resolve() / pip) +def get_python_from_venv(venv_path: Path) -> str: + """ + Given a path to a virtual environment, get the absolute path to the `python` executable + in a cross-platform fashion. Does not validate that the python executable + actually exists in the virtualenv. + + :param venv_path: Path to the virtual environment + :type venv_path: Path + :return: Absolute path to the python executable + :rtype: str + """ + + python = "Scripts\python.exe" if OS == "Windows" else "bin/python" + return str(venv_path.expanduser().resolve() / python) + + def set_sys_path(venv_path: Path) -> None: """ Given a path to a virtual environment, set the sys.path, in a cross-platform fashion, From 4b74b51ffe6a41a81dedff24089084d89585c7c9 Mon Sep 17 00:00:00 2001 From: Sergey Borisov Date: Thu, 6 Apr 2023 04:55:10 +0300 Subject: [PATCH 2/2] Fix naming --- installer/lib/installer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/lib/installer.py b/installer/lib/installer.py index eca0963fbf..99fc393696 100644 --- a/installer/lib/installer.py +++ b/installer/lib/installer.py @@ -144,8 +144,8 @@ class Installer: from plumbum import FG, local - pip = local[get_python_from_venv(venv_dir)] - pip[ "-m", "pip", "install", "--upgrade", "pip"] & FG + python = local[get_python_from_venv(venv_dir)] + python[ "-m", "pip", "install", "--upgrade", "pip"] & FG return venv_dir