diff options
| author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2022-10-17 11:27:13 +0200 |
|---|---|---|
| committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2022-12-29 10:04:41 +0000 |
| commit | e37f082c958b7a5349e245af0586b7e5e9c358ae (patch) | |
| tree | f8c1d1d33258504208805085a935a23f5b913022 /sources/pyside-tools/deploy_lib/config.py | |
| parent | 134adfc99bf57acf84df8bfa74c545d0e43879a5 (diff) | |
Deploy tool: Reduce QML executable size + tests
- Added more Nuitka options to reduce the size of QML executable.
Some binaries which cause the QML executable to become heavy eg:
QtWebEngine are removed, if they are not used
- Add new log messages for --verbose option
- Add deploy.pyproject file
- Modifies pyside6-deploy tests to consider the QML options, by
mocking pyside6-qmlimportscanner
Task-number: PYSIDE-1612
Change-Id: Id2e94217e99eedbf41ecfc8de1a37e94c7edaa52
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy_lib/config.py')
| -rw-r--r-- | sources/pyside-tools/deploy_lib/config.py | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/sources/pyside-tools/deploy_lib/config.py b/sources/pyside-tools/deploy_lib/config.py index d02558cca..ba165d20b 100644 --- a/sources/pyside-tools/deploy_lib/config.py +++ b/sources/pyside-tools/deploy_lib/config.py @@ -8,6 +8,11 @@ import shutil import logging from project import ProjectData +from .commands import run_qmlimportscanner + +# Some QML plugins like QtCore are excluded from this list as they don't contribute much to +# executable size. Excluding them saves the extra processing of checking for them in files +EXCLUDED_QML_PLUGINS = {"QtQuick", "QtQuick3D", "QtCharts", "QtWebEngine", "QtTest", "QtSensors"} class Config: @@ -60,8 +65,14 @@ class Config: else: self._find_and_set_qml_files() + self.excluded_qml_plugins = [] + if self.get_value("qt", "excluded_qml_plugins"): + self.excluded_qml_plugins = self.get_value("qt", "excluded_qml_plugins").split(",") + else: + self._find_and_set_excluded_qml_plugins() + def update_config(self): - logging.info("[DEPLOY] Creating {config_file}") + logging.info(f"[DEPLOY] Creating {self.config_file}") with open(self.config_file, "w+") as config_file: self.parser.write(config_file, space_around_delimiters=True) @@ -97,7 +108,7 @@ class Config: return self.get_value(config_property_group, config_property_key) else: logging.exception( - f"[DEPLOY]: No {config_property_key} specified in config file or as cli option" + f"[DEPLOY] No {config_property_key} specified in config file or as cli option" ) raise @@ -133,6 +144,14 @@ class Config: def python_path(self, python_path): self._python_path = python_path + @property + def excluded_qml_plugins(self): + return self._excluded_qml_plugins + + @excluded_qml_plugins.setter + def excluded_qml_plugins(self, excluded_qml_plugins): + self._excluded_qml_plugins = excluded_qml_plugins + def _find_and_set_qml_files(self): """Fetches all the qml_files in the folder and sets them if the field qml_files is empty in the config_dir""" @@ -224,3 +243,14 @@ class Config: self.set_value("app", "project_file", str(files[0].relative_to(self.project_dir))) logging.info(f"[DEPLOY] Project file {files[0]} found and set in config file") + def _find_and_set_excluded_qml_plugins(self): + if self.qml_files: + included_qml_modules = set(run_qmlimportscanner(qml_files=self.qml_files, + dry_run=self.dry_run)) + self.excluded_qml_plugins = EXCLUDED_QML_PLUGINS.difference(included_qml_modules) + + # needed for dry_run testing + self.excluded_qml_plugins = sorted(self.excluded_qml_plugins) + + if self.excluded_qml_plugins: + self.set_value("qt", "excluded_qml_plugins", ",".join(self.excluded_qml_plugins)) |
