aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/deploy_lib/python_helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside-tools/deploy_lib/python_helper.py')
-rw-r--r--sources/pyside-tools/deploy_lib/python_helper.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/sources/pyside-tools/deploy_lib/python_helper.py b/sources/pyside-tools/deploy_lib/python_helper.py
index 1a48b0e9a..32bf04f2c 100644
--- a/sources/pyside-tools/deploy_lib/python_helper.py
+++ b/sources/pyside-tools/deploy_lib/python_helper.py
@@ -148,7 +148,20 @@ class PythonExecutable:
venv = os.environ.get("VIRTUAL_ENV")
return True if venv else False
+ def is_pyenv_python(self):
+ pyenv_root = os.environ.get("PYENV_ROOT")
+
+ if pyenv_root:
+ resolved_exe = self.exe.resolve()
+ if str(resolved_exe).startswith(pyenv_root):
+ return True
+
+ return False
+
def install(self, packages: list = None):
+ _, installed_packages = run_command(command=[str(self.exe), "-m", "pip", "freeze"], dry_run=False
+ , fetch_output=True)
+ installed_packages = [p.decode().split('==')[0] for p in installed_packages.split()]
for package in packages:
package_info = package.split('==')
package_components_len = len(package_info)
@@ -160,7 +173,7 @@ class PythonExecutable:
package_version = package_info[1]
else:
raise ValueError(f"{package} should be of the format 'package_name'=='version'")
- if not self.is_installed(package=package_name):
+ if (package_name not in installed_packages) and (not self.is_installed(package_name)):
logging.info(f"[DEPLOY] Installing package: {package}")
run_command(
command=[self.exe, "-m", "pip", "install", package],
@@ -177,7 +190,7 @@ class PythonExecutable:
)
else:
logging.info(f"[DEPLOY] package: {package_name}=={package_version}"
- "already installed")
+ " already installed")
else:
logging.info(f"[DEPLOY] package: {package_name} already installed")