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_lib/deploy_util.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_lib/deploy_util.py')
| -rw-r--r-- | sources/pyside-tools/deploy_lib/deploy_util.py | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/sources/pyside-tools/deploy_lib/deploy_util.py b/sources/pyside-tools/deploy_lib/deploy_util.py index a73ccb0eb..368ad682e 100644 --- a/sources/pyside-tools/deploy_lib/deploy_util.py +++ b/sources/pyside-tools/deploy_lib/deploy_util.py @@ -19,12 +19,12 @@ def config_option_exists(): return False -def cleanup(generated_files_path: Path, config: Config, is_android: bool = False): +def cleanup(config: Config, is_android: bool = False): """ Cleanup the generated build folders/files """ - if generated_files_path.exists(): - shutil.rmtree(generated_files_path) + if config.generated_files_path.exists(): + shutil.rmtree(config.generated_files_path) logging.info("[DEPLOY] Deployment directory purged") if is_android: @@ -39,37 +39,27 @@ def cleanup(generated_files_path: Path, config: Config, is_android: bool = False logging.info(f"[DEPLOY] {str(buildozer_build)} removed") -def get_config(python_exe: Path, dry_run: bool = False, config_file: Path = None, main_file: - Path = None, android_data=None, is_android: bool = False): +def create_config_file(dry_run: bool = False, config_file: Path = None, main_file: Path = None): """ Sets up a new pysidedeploy.spec or use an existing config file """ - config_file_exists = config_file and Path(config_file).exists() - - if main_file and not config_file_exists: + if main_file: if main_file.parent != Path.cwd(): config_file = main_file.parent / "pysidedeploy.spec" else: config_file = Path.cwd() / "pysidedeploy.spec" - if config_file_exists: - logging.info(f"[DEPLOY] Using existing config file {config_file}") - else: - logging.info(f"[DEPLOY] Creating config file {config_file}") - if not dry_run: - shutil.copy(Path(__file__).parent / "default.spec", config_file) + logging.info(f"[DEPLOY] Creating config file {config_file}") + if not dry_run: + shutil.copy(Path(__file__).parent / "default.spec", config_file) # the config parser needs a reference to parse. So, in the case of --dry-run # use the default.spec file. - if dry_run and not config_file_exists: + if dry_run: config_file = Path(__file__).parent / "default.spec" - config = Config(config_file=config_file, source_file=main_file, python_exe=python_exe, - dry_run=dry_run, android_data=android_data, is_android=is_android, - existing_config_file=config_file_exists) - - return config + return config_file def setup_python(dry_run: bool, force: bool, init: bool): @@ -109,12 +99,12 @@ def install_python_dependencies(config: Config, python: PythonExecutable, init: python.install(packages=["patchelf"]) -def finalize(generated_files_path: Path, config: Config): +def finalize(config: Config): """ Copy the executable into the final location For Android deployment, this is done through buildozer """ - generated_exec_path = generated_files_path / (config.source_file.stem + EXE_FORMAT) + generated_exec_path = config.generated_files_path / (config.source_file.stem + EXE_FORMAT) if generated_exec_path.exists() and config.exe_dir: shutil.copy(generated_exec_path, config.exe_dir) print("[DEPLOY] Executed file created in " |
