From 8247c49a22f8d35bdac949948e25432800ff3d5b Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Tue, 29 Dec 2020 18:15:45 +0100 Subject: build_scripts: replace print by distutils.log Change-Id: I1106598719b48650847b08637e0caf6677cb26a0 Reviewed-by: Friedemann Kleint (cherry picked from commit a35afc89a911612b4de3c71a8717f1fb74a39455) Reviewed-by: Qt Cherry-pick Bot --- build_scripts/main.py | 11 +++++------ build_scripts/options.py | 14 +++++++------- build_scripts/utils.py | 22 +++++++++++----------- build_scripts/wheel_override.py | 6 +++--- 4 files changed, 26 insertions(+), 27 deletions(-) (limited to 'build_scripts') diff --git a/build_scripts/main.py b/build_scripts/main.py index ffe13aedd..773460de1 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -246,8 +246,7 @@ def check_allowed_python_version(): supported.append((major, minor)) this_py = sys.version_info[:2] if this_py not in supported: - print("Unsupported python version detected. Only these python versions are supported: {}" - .format(supported)) + log.error(f"Unsupported python version detected. Supported versions: {supported}") sys.exit(1) @@ -321,8 +320,8 @@ def prepare_build(): try: rmtree(d) except Exception as e: - print('***** problem removing "{}"'.format(d)) - print('ignored error: {}'.format(e)) + log.warn(f'***** problem removing "{d}"') + log.warn(f'ignored error: {e}') # locate Qt sources for the documentation if OPTION["QT_SRC"] is None: @@ -367,7 +366,7 @@ class PysideInstall(_install, DistUtilsCommandMixin): def run(self): _install.run(self) - print('--- Install completed ({}s)'.format(elapsed())) + log.info(f"--- Install completed ({elapsed()}s)") class PysideDevelop(_develop): @@ -604,7 +603,7 @@ class PysideBuild(_build, DistUtilsCommandMixin): _build.run(self) else: log.info("Skipped preparing and building packages.") - print('--- Build completed ({}s)'.format(elapsed())) + log.info(f"--- Build completed ({elapsed()}s)") def log_pre_build_info(self): if config.is_internal_shiboken_generator_build_and_part_of_top_level_all(): diff --git a/build_scripts/options.py b/build_scripts/options.py index b2dfd448e..ab45c915c 100644 --- a/build_scripts/options.py +++ b/build_scripts/options.py @@ -308,10 +308,10 @@ class DistUtilsCommandMixin(object): if not self.cmake: self.cmake = find_executable("cmake") if not self.cmake: - print("cmake could not be found.") + log.error("cmake could not be found.") return False if not os.path.exists(self.cmake): - print("'{}' does not exist.".format(self.cmake)) + log.error(f"'{self.cmake}' does not exist.") return False if not self.qmake: @@ -319,21 +319,21 @@ class DistUtilsCommandMixin(object): if not self.qmake: self.qmake = find_executable("qmake-qt5") if not self.qmake: - print("qmake could not be found.") + log.error("qmake could not be found.") return False if not os.path.exists(self.qmake): - print("'{}' does not exist.".format(self.qmake)) + log.error(f"'{self.qmake}' does not exist.") return False if not self.make_spec: self.make_spec = _AVAILABLE_MKSPECS[0] if self.make_spec not in _AVAILABLE_MKSPECS: - print('Invalid option --make-spec "{}". Available values are {}'.format(self.make_spec, - _AVAILABLE_MKSPECS)) + log.error(f'Invalid option --make-spec "{self.make_spec}". ' + f'Available values are {_AVAILABLE_MKSPECS}') return False if OPTION["JOBS"] and sys.platform == 'win32' and self.no_jom: - print("Option --jobs can only be used with jom on Windows.") + log.error("Option --jobs can only be used with jom on Windows.") return False return True diff --git a/build_scripts/utils.py b/build_scripts/utils.py index af126cca6..2555c7c7e 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -1075,28 +1075,28 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): env_pip = _env + "/bin/pip" if host == "Windows": - print("New virtualenv to build {} in {} host".format(targetArch, hostArch)) + log.info("New virtualenv to build {targetArch} in {hostArch} host") _pExe = "python.exe" # With windows we are creating building 32-bit target in 64-bit host if hostArch == "X86_64" and targetArch == "X86": if python_ver.startswith("3"): - var = "PYTHON" + python_ver + "-32_PATH" - print("Try to find python from {} env variable".format(var)) + var = f"PYTHON{python_ver}-32_PATH" + log.info(f"Try to find python from {var} env variable") _path = os.getenv(var, "") _pExe = os.path.join(_path, "python.exe") if not os.path.isfile(_pExe): - print("Can't find python.exe from {}, using default python3".format(_pExe)) + log.warn(f"Can't find python.exe from {_pExe}, using default python3") _pExe = os.path.join(os.getenv("PYTHON3_32_PATH"), "python.exe") else: _pExe = os.path.join(os.getenv("PYTHON2_32_PATH"), "python.exe") else: if python_ver.startswith("3"): - var = "PYTHON" + python_ver + "-64_PATH" - print("Try to find python from {} env variable".format(var)) + var = f"PYTHON{python_ver}-64_PATH" + log.info(f"Try to find python from {var} env variable") _path = os.getenv(var, "") _pExe = os.path.join(_path, "python.exe") if not os.path.isfile(_pExe): - print("Can't find python.exe from {}, using default python3".format(_pExe)) + log.warn(f"Can't find python.exe from {_pExe}, using default python3") _pExe = os.path.join(os.getenv("PYTHON3_PATH"), "python.exe") env_python = _env + "\\Scripts\\python.exe" env_pip = _env + "\\Scripts\\pip.exe" @@ -1109,10 +1109,10 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): def run_instruction(instruction, error, initial_env=None): if initial_env is None: initial_env = os.environ - print("Running Coin instruction: {}".format(' '.join(str(e) for e in instruction))) + log.info(f"Running Coin instruction: {' '.join(str(e) for e in instruction)}") result = subprocess.call(instruction, env=initial_env) if result != 0: - print("ERROR : {}".format(error)) + log.error(f"ERROR : {error}") exit(result) @@ -1121,14 +1121,14 @@ def acceptCITestConfiguration(hostOS, hostOSVer, targetArch, compiler): # NOTE: String must match with QT CI's storagestruct thrift if (hostOSVer in ["WinRT_10", "WebAssembly", "Ubuntu_18_04", "Android_ANY"] or hostOSVer.startswith("SLES_")): - print("Disabled {} from Coin configuration".format(hostOSVer)) + log.info("Disabled {hostOSVer} from Coin configuration") return False # With 5.11 CI will create two sets of release binaries, # one with msvc 2015 and one with msvc 2017 # we shouldn't release the 2015 version. # BUT, 32 bit build is done only on msvc 2015... if compiler in ["MSVC2015"] and targetArch in ["X86_64"]: - print("Disabled {} to {} from Coin configuration".format(compiler, targetArch)) + log.warn(f"Disabled {compiler} to {targetArch} from Coin configuration") return False return True diff --git a/build_scripts/wheel_override.py b/build_scripts/wheel_override.py index 7c7a1cd09..b5e59cfc2 100644 --- a/build_scripts/wheel_override.py +++ b/build_scripts/wheel_override.py @@ -57,9 +57,9 @@ try: wheel_module_exists = True except Exception as e: - _bdist_wheel, wheel_version = type, '' # dummy to make class statement happy - print('***** Exception while trying to prepare bdist_wheel override class: {}. ' - 'Skipping wheel overriding.'.format(e)) + _bdist_wheel, wheel_version = type, "" # dummy to make class statement happy + logger.warn(f"***** Exception while trying to prepare bdist_wheel override class: {e}. " + "Skipping wheel overriding.") def get_bdist_wheel_override(): -- cgit v1.2.3