diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-10-23 13:50:08 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-11-28 15:58:37 +0100 |
commit | 120a14487c86c96cf4818e04b9e919be6495151d (patch) | |
tree | 00f1515dac19c32d5e50134d924e3980eb090e8f /sources/pyside-tools/deploy.py | |
parent | 782c0757f43651e25f17cd28cda07f8293c3c107 (diff) |
Deployment: Code Refactoring
- Move android related configurations into a new class AndroidConfig.
This class inherits from the class Config.
- Move configuration related code sections from `android_deploy.py`
to `android_config.py`
- get_config() renamed to create_config_file().
This simplifies a lot of code and makes Android deployment independent
of Desktop deployment.
- Move `generated_files_path` to `config.py`. As a result,
`generated_files_path` does not need to be passed as parameter to
to functions like `cleanup()`, `finalize()`, `Buildozer.initialize()`
as config is already passed.
- generated_files_path expression changed.
This is because we assume the project_dir is always the parent of the
source_file (i.e. main.py)
- `Buildozer` import removed from `android/__init__.py` to prevent
circular import issues.
- Change buildozer commands to use "python -m" as prefix.
Pick-to: 6.6
Task-number: PYSIDE-1612
Change-Id: Ie460dc459908dab44de82c3e269b806aff2c27c5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy.py')
-rw-r--r-- | sources/pyside-tools/deploy.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/sources/pyside-tools/deploy.py b/sources/pyside-tools/deploy.py index b19fbb0d1..f5197b6cf 100644 --- a/sources/pyside-tools/deploy.py +++ b/sources/pyside-tools/deploy.py @@ -35,7 +35,7 @@ from pathlib import Path from textwrap import dedent from deploy_lib import (MAJOR_VERSION, Config, cleanup, config_option_exists, - finalize, get_config, install_python_dependencies, + finalize, create_config_file, install_python_dependencies, setup_python) @@ -54,22 +54,26 @@ def main(main_file: Path = None, name: str = None, config_file: Path = None, ini # Nuitka command to run command_str = None - generated_files_path = None config = None logging.info("[DEPLOY] Start") python = setup_python(dry_run=dry_run, force=force, init=init) - config = get_config(python_exe=python.exe, dry_run=dry_run, config_file=config_file, - main_file=main_file) + config_file_exists = config_file and Path(config_file).exists() + + if config_file_exists: + logging.info(f"[DEPLOY] Using existing config file {config_file}") + else: + config_file = create_config_file(dry_run=dry_run, config_file=config_file, + main_file=main_file) + + config = Config(config_file=config_file, source_file=main_file, python_exe=python.exe, + dry_run=dry_run, existing_config_file=config_file_exists) # set application name if name: config.title = name - source_file = config.project_dir / config.source_file - - generated_files_path = source_file.parent / "deployment" - cleanup(generated_files_path=generated_files_path, config=config) + cleanup(config=config) install_python_dependencies(config=config, python=python, init=init, packages="packages") @@ -96,17 +100,17 @@ def main(main_file: Path = None, name: str = None, config_file: Path = None, ini logging.info("[DEPLOY] Deploying application") command_str = python.create_executable( - source_file=source_file, + source_file=config.source_file, extra_args=config.extra_args, config=config, ) except Exception: print(f"[DEPLOY] Exception occurred: {traceback.format_exc()}") finally: - if generated_files_path and config: - finalize(generated_files_path=generated_files_path, config=config) + if config.generated_files_path and config: + finalize(config=config) if not keep_deployment_files: - cleanup(generated_files_path=generated_files_path, config=Config) + cleanup(config=config) logging.info("[DEPLOY] End") return command_str |