diff options
author | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2022-04-07 11:26:59 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-01 14:32:34 +0000 |
commit | c1e7ec62d88fb0fe797a4da225ce485ae24801e5 (patch) | |
tree | e90a7e981dbefc07a29e2bf7d968ab46c8577256 | |
parent | 7b1c7315966b3263dc9a67f93b035a6f07bba262 (diff) |
build: remove directories in 'package_for_wheels/' on re-run
The 'package_for_wheels' directory remains populated
on a second build, so to make sure that there are no conflicts,
we remove the directories inside in case it exists.
This means that 'shiboken6', 'shiboken6_generator', and 'pyside6'
directories inside 'package_for_wheels' will be removed when found.
Change-Id: Idccbf1d2ab67e046e7d6288c8daa4e0a264ad08c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit cbc7d2a21b63f58144da0d5a42048b7b9dee1eb0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | build_scripts/main.py | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py index e25f22bd0..34c2826bd 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -45,7 +45,7 @@ import sys import time from packaging.version import parse as parse_version from pathlib import Path -from shutil import which, copytree +from shutil import which, copytree, rmtree from textwrap import dedent # PYSIDE-1760: Pre-load setuptools modules early to avoid racing conditions. @@ -460,18 +460,35 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): # a wheel. _path = Path(self.st_build_dir) _wheel_path = _path.parent / "package_for_wheels" - if not _wheel_path.exists(): - _wheel_path.mkdir() - _package_name = os.listdir(_path)[0] - _src = Path(_path / _package_name) - _dst = Path(_wheel_path / _package_name) - try: - # This should be copied because the package directory - # is used when using the 'install' setup.py instruction. - copytree(_src, _dst) - except Exception as e: - log.warn(f'***** problem renaming "{self.st_build_dir}"') - log.warn(f'ignored error: {type(e).__name__}: {e}') + + _project = None + + if config.is_internal_shiboken_module_build(): + _project = "shiboken6" + elif config.is_internal_shiboken_generator_build(): + _project = "shiboken6_generator" + elif config.is_internal_pyside_build(): + _project = "PySide6" + + if _project is not None: + if not _wheel_path.exists(): + _wheel_path.mkdir() + _src = Path(_path / _project) + _dst = Path(_wheel_path / _project) + # Remove the directory in case it exists. + # This applies to 'shiboken6', 'shiboken6_generator', + # and 'pyside6' inside the 'package_for_wheels' directory. + if _dst.exists(): + log.warn(f'***** Found directory "{_dst}", removing it first.') + rmtree(_dst) + + try: + # This should be copied because the package directory + # is used when using the 'install' setup.py instruction. + copytree(_src, _dst) + except Exception as e: + log.warn(f'***** problem renaming "{self.st_build_dir}"') + log.warn(f'ignored error: {type(e).__name__}: {e}') else: log.info("Skipped preparing and building packages.") log.info(f"--- Build completed ({elapsed()}s)") |