aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-10-11 10:45:13 +0200
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-10-11 13:37:47 +0200
commit8ef13b6b75defbf0825db9e1ca27817f2b52647a (patch)
tree9e56a783103a01a31153aaa01d5eba76719450c4 /sources/pyside-tools
parent2199b95e00fbf0b06d23659274e080a7d75b5988 (diff)
Android Deployment: Install Python dependencies on first call
- `pyside6-android-deploy` has dependencies on Python packages `jinja2` and 'pkginfo'. Earlier they had to be manually installed by the user. - This patch automates the installation on the first invocation of the tool. - Windows and macOS desktop hosts now prints a not supported message and exits pyside6-android-deploy. - As an addition, ran `isort` on the file. Pick-to: 6.6 Task-number: PYSIDE-1612 Change-Id: I9ecba72afb396624809e98adf43236a2f15c15eb Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside-tools')
-rw-r--r--sources/pyside-tools/pyside_tool.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/sources/pyside-tools/pyside_tool.py b/sources/pyside-tools/pyside_tool.py
index 5f71dd126..1648b2943 100644
--- a/sources/pyside-tools/pyside_tool.py
+++ b/sources/pyside-tools/pyside_tool.py
@@ -2,16 +2,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-import sys
+import importlib
import os
-from pathlib import Path
import subprocess
+import sys
import sysconfig
+from pathlib import Path
+from subprocess import PIPE, Popen
-from subprocess import Popen, PIPE
import PySide6 as ref_mod
-
VIRTUAL_ENV = "VIRTUAL_ENV"
@@ -55,7 +55,6 @@ def qt_tool_wrapper(qt_tool, args, libexec=False):
sys.exit(proc.returncode)
-
def pyside_script_wrapper(script_name):
"""Launch a script shipped with PySide."""
script = Path(__file__).resolve().parent / script_name
@@ -195,7 +194,15 @@ def deploy():
def android_deploy():
- pyside_script_wrapper("android_deploy.py")
+ if not sys.platform == "linux":
+ print("pyside6-android-deploy only works from a Linux host")
+ else:
+ dependent_packages = ["jinja2", "pkginfo"]
+ for dependent_package in dependent_packages:
+ if not bool(importlib.util.find_spec(dependent_package)):
+ command = [sys.executable, "-m", "pip", "install", dependent_package]
+ subprocess.run(command)
+ pyside_script_wrapper("android_deploy.py")
if __name__ == "__main__":