diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-10-02 14:07:40 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-10-02 18:20:53 +0200 |
commit | 0f98cb69d4e8a2beec64102abef97b46aa7626ba (patch) | |
tree | fabe55d998e7190e0d3b8ccbf5f9b30693b00662 /sources/pyside-tools/deploy_lib | |
parent | 0a1710429333001fbf5a96cdc9043f9ec2f559ba (diff) |
Android Deployment: Identify Qt modules from generated Python files
- This patch adds an extra step to check the existence of Python files
generated from `pyside6-uic` and `pyside6-qrc` for identifying the
imported Qt modules in the application.
This only applies when the application has a .pyproject file. When
the project does not have a .pyproject file, all the Python files
in the application are checked for Qt module imports.
The .pyproject file does not consider the generated Python files and
hence the need of this patch.
- For pyside6-deploy, this patch is irrelevant because Nuitka identifies
all the required Python files of the project.
Task-number: PYSIDE-1612
Pick-to: 6.6
Change-Id: Ic9a2812c42226b6baebab1b23fac8e410910578e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy_lib')
-rw-r--r-- | sources/pyside-tools/deploy_lib/python_helper.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sources/pyside-tools/deploy_lib/python_helper.py b/sources/pyside-tools/deploy_lib/python_helper.py index af8753257..1a48b0e9a 100644 --- a/sources/pyside-tools/deploy_lib/python_helper.py +++ b/sources/pyside-tools/deploy_lib/python_helper.py @@ -6,6 +6,7 @@ import os import re import sys import logging +import warnings from typing import List from importlib import util if sys.version_info >= (3, 8): @@ -73,6 +74,31 @@ def find_pyside_modules(project_dir: Path, extra_ignore_dirs: List[Path] = None, if project_data: py_candidates = project_data.python_files + ui_candidates = project_data.ui_files + qrc_candidates = project_data.qrc_files + ui_py_candidates = None + qrc_ui_candidates = None + + if ui_candidates: + ui_py_candidates = [(file.parent / f"ui_{file.stem}.py") for file in ui_candidates + if (file.parent / f"ui_{file.stem}.py").exists()] + + if len(ui_py_candidates) != len(ui_candidates): + warnings.warn("[DEPLOY] The number of uic files and their corresponding Python" + " files don't match.", category=RuntimeWarning) + + py_candidates.extend(ui_py_candidates) + + if qrc_candidates: + qrc_ui_candidates = [(file.parent / f"rc_{file.stem}.py") for file in qrc_candidates + if (file.parent / f"rc_{file.stem}.py").exists()] + + if len(qrc_ui_candidates) != len(qrc_candidates): + warnings.warn("[DEPLOY] The number of qrc files and their corresponding Python" + " files don't match.", category=RuntimeWarning) + + py_candidates.extend(qrc_ui_candidates) + for py_candidate in py_candidates: all_modules = all_modules.union(pyside_imports(py_candidate)) return list(all_modules) |