diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-04-05 11:11:23 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-04-05 15:13:51 +0000 |
commit | ea221501ca9aa66424024ba05a15dfcebfa2bfce (patch) | |
tree | 47d6a0bfdab8c8b6ce415e6ec22b97cdbfac9701 | |
parent | d621c6df50ceb0a811221e3ccc1d81ea1aa37e18 (diff) |
Deployment: Adapt checking for plugin dependencies
- Check if package e.g. PySide6_AddOns is installed before checking for
the .json file
- If a package is missing, add log warning for the missing package.
If the .json file is missing inspite of the package being installed,
then raise a proper warning.
Task-number: PYSIDE-1612
Change-Id: Ia65b06df15df7b334438f439762b135d9f61981d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 1396950daccded4b442c8a9d08aa10912a7641cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c9b95832f9136b8bc8d6a929890360fd2a4c410f)
-rw-r--r-- | sources/pyside-tools/deploy_lib/config.py | 3 | ||||
-rw-r--r-- | sources/pyside-tools/deploy_lib/dependency_util.py | 15 |
2 files changed, 14 insertions, 4 deletions
diff --git a/sources/pyside-tools/deploy_lib/config.py b/sources/pyside-tools/deploy_lib/config.py index 2ca6ff895..d59dd92ad 100644 --- a/sources/pyside-tools/deploy_lib/config.py +++ b/sources/pyside-tools/deploy_lib/config.py @@ -391,7 +391,8 @@ class DesktopConfig(Config): if self.get_value("qt", "plugins"): self._qt_plugins = self.get_value("qt", "plugins").split(",") else: - self.qt_plugins = self.dependency_reader.find_plugin_dependencies(self.modules) + self.qt_plugins = self.dependency_reader.find_plugin_dependencies(self.modules, + python_exe) self._permissions = [] if sys.platform == "darwin": diff --git a/sources/pyside-tools/deploy_lib/dependency_util.py b/sources/pyside-tools/deploy_lib/dependency_util.py index d71640ed0..2d5b188d3 100644 --- a/sources/pyside-tools/deploy_lib/dependency_util.py +++ b/sources/pyside-tools/deploy_lib/dependency_util.py @@ -285,13 +285,22 @@ class QtDependencyReader: else: logging.info(f"[DEPLOY] No Qt dependencies found for {module}") - def find_plugin_dependencies(self, used_modules: List[str]) -> List[str]: + def find_plugin_dependencies(self, used_modules: List[str], python_exe: Path) -> List[str]: """ Given the modules used by the application, returns all the required plugins """ plugins = set() - pyside_mod_plugin_jsons = ["PySide6_Essentials.json", "PySide6_Addons.json"] - for pyside_mod_plugin_json_name in pyside_mod_plugin_jsons: + pyside_wheels = ["PySide6_Essentials", "PySide6_Addons"] + # TODO from 3.12 use list(dist.name for dist in importlib.metadata.distributions()) + _, installed_packages = run_command(command=[str(python_exe), "-m", "pip", "freeze"], + dry_run=False, fetch_output=True) + installed_packages = [p.decode().split('==')[0] for p in installed_packages.split()] + for pyside_wheel in pyside_wheels: + if pyside_wheel not in installed_packages: + # the wheel is not installed and hence no plugins are checked for its modules + logging.warning((f"[DEPLOY] The package {pyside_wheel} is not installed. ")) + continue + pyside_mod_plugin_json_name = f"{pyside_wheel}.json" pyside_mod_plugin_json_file = self.pyside_install_dir / pyside_mod_plugin_json_name if not pyside_mod_plugin_json_file.exists(): warnings.warn(f"[DEPLOY] Unable to find {pyside_mod_plugin_json_file}.", |