aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/deploy_lib
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-10-10 12:19:10 +0200
committerShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-10-11 12:12:32 +0200
commita7f7ab6ef12005f4ca86c5a4934c33d2539a23e5 (patch)
treeb6bba2aa958c26c8f9c1cea95f5a7a4ec081ae9f /sources/pyside-tools/deploy_lib
parentbcfd0a1ad2f1c333b53db071fe40b2ee3569bd6b (diff)
Deployment: More code fixes
- Formatting and text updates. - extract_and_copy_jar() returns the extracted path to the jar directory - Buildozer class is now initialized when `pyside6-android-deploy` is run with --init. This is because it updates the recipes folder. - Buildozer defaults for Android NDK cannot be used anymore because `pyside6-android-deploy` uses llvm-readelf from the NDK to find the binary dependencies. - Change print statement to RuntimeError incase `main.py` does not exist - Change logging.exception to RuntimeError for the function `find_pyside_modules` Pick-to: 6.6 Task-number: PYSIDE-1612 Change-Id: I6ef5d5dfe9acae5f0029553ca2c6f07d91b6e462 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy_lib')
-rw-r--r--sources/pyside-tools/deploy_lib/android/android_helper.py11
-rw-r--r--sources/pyside-tools/deploy_lib/android/buildozer.py2
-rw-r--r--sources/pyside-tools/deploy_lib/config.py19
-rw-r--r--sources/pyside-tools/deploy_lib/python_helper.py5
4 files changed, 20 insertions, 17 deletions
diff --git a/sources/pyside-tools/deploy_lib/android/android_helper.py b/sources/pyside-tools/deploy_lib/android/android_helper.py
index 58efa0943..4489909d5 100644
--- a/sources/pyside-tools/deploy_lib/android/android_helper.py
+++ b/sources/pyside-tools/deploy_lib/android/android_helper.py
@@ -30,9 +30,9 @@ def create_recipe(version: str, component: str, wheel_path: str, generated_files
'''
Create python_for_android recipe for PySide6 and shiboken6
'''
- qt_plugins = []
+ qt_plugins = []
if plugins:
- #split plugins based on category
+ # split plugins based on category
for plugin in plugins:
plugin_category, plugin_name = plugin.split('_', 1)
qt_plugins.append((plugin_category, plugin_name))
@@ -70,7 +70,7 @@ def extract_and_copy_jar(wheel_path: Path, generated_files_path: Path) -> str:
jar_files = [file for file in archive.namelist() if file.startswith("PySide6/jar")]
for file in jar_files:
archive.extract(file, jar_path)
- return jar_path
+ return (jar_path / "PySide6" / "jar").resolve() if jar_files else None
def get_wheel_android_arch(wheel: Path):
@@ -89,11 +89,6 @@ def get_llvm_readobj(ndk_path: Path) -> Path:
'''
Return the path to llvm_readobj from the Android Ndk
'''
- if not ndk_path:
- # fetch ndk path from buildozer
- raise FileNotFoundError("[DEPLOY] Unable to find Ndk path. Please pass the Ndk path either"
- " from the CLI or from pysidedeploy.spec")
-
# TODO: Requires change if Windows platform supports Android Deployment or if we
# support host other than linux-x86_64
return (ndk_path / "toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readobj")
diff --git a/sources/pyside-tools/deploy_lib/android/buildozer.py b/sources/pyside-tools/deploy_lib/android/buildozer.py
index 647951a09..3d187fa60 100644
--- a/sources/pyside-tools/deploy_lib/android/buildozer.py
+++ b/sources/pyside-tools/deploy_lib/android/buildozer.py
@@ -111,7 +111,7 @@ class BuildozerConfig(BaseConfig):
self.set_value("app", "android.add_jars", ",".join(jars))
init_classes = ",".join(init_classes)
- #extra arguments specific to Qt
+ # extra arguments specific to Qt
extra_args = (f"--qt-libs={modules} --load-local-libs={local_libs}"
f" --init-classes={init_classes}")
self.set_value("app", "p4a.extra_args", extra_args)
diff --git a/sources/pyside-tools/deploy_lib/config.py b/sources/pyside-tools/deploy_lib/config.py
index b2b074a70..6859b1f76 100644
--- a/sources/pyside-tools/deploy_lib/config.py
+++ b/sources/pyside-tools/deploy_lib/config.py
@@ -132,21 +132,28 @@ class Config(BaseConfig):
raise RuntimeError("[DEPLOY] Unable to find shiboken6 Android wheel")
self.wheel_shiboken = Path(wheel_shiboken_temp).resolve()
+ self.ndk_path = None
if android_data.ndk_path:
+ # from cli
self.ndk_path = android_data.ndk_path
else:
+ # from config
ndk_path_temp = self.get_value("buildozer", "ndk_path")
if ndk_path_temp:
self.ndk_path = Path(ndk_path_temp)
else:
- self.ndk_path = (ANDROID_DEPLOY_CACHE / "android-ndk"
+ ndk_path_temp = (ANDROID_DEPLOY_CACHE / "android-ndk"
/ f"android-ndk-r{ANDROID_NDK_VERSION}")
- if not self.ndk_path.exists():
- logging.info("[DEPLOY] Use default NDK from buildoer")
+ if ndk_path_temp.exists():
+ self.ndk_path = ndk_path_temp
if self.ndk_path:
print(f"Using Android NDK: {str(self.ndk_path)}")
+ else:
+ raise FileNotFoundError("[DEPLOY] Unable to find Android NDK. Please pass the NDK "
+ "path either from the CLI or from pysidedeploy.spec")
+ self.sdk_path = None
if android_data.sdk_path:
self.sdk_path = android_data.sdk_path
else:
@@ -154,8 +161,10 @@ class Config(BaseConfig):
if sdk_path_temp:
self.sdk_path = Path(sdk_path_temp)
else:
- self.sdk_path = ANDROID_DEPLOY_CACHE / "android-sdk"
- if not self.sdk_path.exists():
+ sdk_path_temp = ANDROID_DEPLOY_CACHE / "android-sdk"
+ if sdk_path_temp.exists():
+ self.sdk_path = sdk_path_temp
+ else:
logging.info("[DEPLOY] Use default SDK from buildozer")
if self.sdk_path:
diff --git a/sources/pyside-tools/deploy_lib/python_helper.py b/sources/pyside-tools/deploy_lib/python_helper.py
index 32bf04f2c..7a91ddfa1 100644
--- a/sources/pyside-tools/deploy_lib/python_helper.py
+++ b/sources/pyside-tools/deploy_lib/python_helper.py
@@ -62,10 +62,9 @@ def find_pyside_modules(project_dir: Path, extra_ignore_dirs: List[Path] = None,
full_mod_name = imported_module.name
if full_mod_name == "PySide6":
logging.warning(IMPORT_WARNING_PYSIDE.format(str(py_file)))
-
except Exception as e:
- logging.error(f"[DEPLOY] Finding module import failed on file {str(py_file)}")
- raise e
+ raise RuntimeError(f"[DEPLOY] Finding module import failed on file {str(py_file)} with "
+ f"error {e}")
return set(modules)