aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2022-10-11 19:06:42 +0200
committerCristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2022-10-13 21:04:40 +0200
commit7e44e3daf13f07c4a70cfded896c389ffc3b7bc2 (patch)
treefa291aa0b69b2a55bc237596483b109c737ce58a
parent4d1c05cb04ec731893ca855d5ba08a1d3c669ca4 (diff)
build: replace distutils.log by simple logger
Adding simple logger based on the logging module to replace the distutils.log one. Task-number: PYSIDE-2079 Change-Id: I2a4996a57be701552005b57d2b1a251b9fc44c41 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--build_scripts/build_info_collector.py2
-rw-r--r--build_scripts/config.py3
-rw-r--r--build_scripts/log.py7
-rw-r--r--build_scripts/main.py18
-rw-r--r--build_scripts/options.py6
-rw-r--r--build_scripts/setup_runner.py12
-rw-r--r--build_scripts/utils.py11
-rw-r--r--build_scripts/wheel_override.py7
-rw-r--r--coin_build_instructions.py6
-rw-r--r--coin_test_instructions.py4
-rw-r--r--testing/runner.py4
-rw-r--r--testing/wheel_tester.py6
12 files changed, 45 insertions, 41 deletions
diff --git a/build_scripts/build_info_collector.py b/build_scripts/build_info_collector.py
index 8dca5c203..c6720a843 100644
--- a/build_scripts/build_info_collector.py
+++ b/build_scripts/build_info_collector.py
@@ -6,10 +6,10 @@ import platform
import sys
from sysconfig import get_config_var
-from setuptools._distutils import log
from setuptools._distutils import sysconfig as sconfig
from setuptools.errors import SetupError
+from .log import log
from .options import OPTION
from .qtinfo import QtInfo
from .utils import configure_cmake_project, parse_cmake_project_message_info
diff --git a/build_scripts/config.py b/build_scripts/config.py
index 654a97f9d..854d5eb8c 100644
--- a/build_scripts/config.py
+++ b/build_scripts/config.py
@@ -3,8 +3,7 @@
import os
-from setuptools._distutils import log
-
+from .log import log
from .versions import PYSIDE, PYSIDE_MODULE, SHIBOKEN
diff --git a/build_scripts/log.py b/build_scripts/log.py
new file mode 100644
index 000000000..d7e6645eb
--- /dev/null
+++ b/build_scripts/log.py
@@ -0,0 +1,7 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import logging
+
+logging.basicConfig(format="[%(levelname)s]: %(message)s", level=logging.INFO)
+log = logging.getLogger("qtforpython")
diff --git a/build_scripts/main.py b/build_scripts/main.py
index ed31c3384..88893b72a 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -27,7 +27,7 @@ from setuptools.command.install_lib import install_lib as _install_lib
from setuptools.command.install_scripts import install_scripts # noqa: preload only
# Use the distutils implementation within setuptools (but not before)
-from setuptools._distutils import log
+from .log import log
from setuptools._distutils import sysconfig as sconfig
from setuptools._distutils.command.build import build as _build
from setuptools.errors import SetupError
@@ -444,7 +444,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
# 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.')
+ log.warning(f'Found directory "{_dst}", removing it first.')
remove_tree(_dst)
try:
@@ -452,8 +452,8 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
# 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}')
+ log.warning(f'problem renaming "{self.st_build_dir}"')
+ log.warning(f'ignored error: {type(e).__name__}: {e}')
else:
log.info("Skipped preparing and building packages.")
log.info(f"--- Build completed ({elapsed()}s)")
@@ -666,7 +666,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
if numpy:
cmake_cmd.append(f"-DNUMPY_INCLUDE_DIR={numpy}")
else:
- log.warn('***** numpy include directory was not found.')
+ log.warning('numpy include directory was not found.')
if self.build_type.lower() == 'debug':
if not self.is_cross_compile:
@@ -928,8 +928,8 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
try:
remove_tree(self.st_build_dir)
except Exception as e:
- log.warn(f'***** problem removing "{self.st_build_dir}"')
- log.warn(f'ignored error: {e}')
+ log.warning(f'problem removing "{self.st_build_dir}"')
+ log.warning(f'ignored error: {e}')
if sys.platform == "win32":
_vars['dbg_postfix'] = OPTION["DEBUG"] and "_d" or ""
@@ -1048,8 +1048,8 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
elif 'linux' in self.plat_name:
filters = unix_filters
else:
- log.warn(f"No shared library filters found for platform {self.plat_name}. "
- f"The package might miss Qt libraries and plugins.")
+ log.warning(f"No shared library filters found for platform {self.plat_name}. "
+ f"The package might miss Qt libraries and plugins.")
else:
if sys.platform == 'darwin':
filters = darwin_filters
diff --git a/build_scripts/options.py b/build_scripts/options.py
index 92e77aabc..ab3a15f2e 100644
--- a/build_scripts/options.py
+++ b/build_scripts/options.py
@@ -3,20 +3,20 @@
try:
from setuptools import Command
- from setuptools._distutils import log
except ModuleNotFoundError:
# This is motivated by our CI using an old version of setuptools
# so then the coin_build_instructions.py script is executed, and
# import from this file, it was failing.
- from distutils import log
from distutils.cmd import Command
import os
import sys
import warnings
+import logging
from pathlib import Path
from shutil import which
+from .log import log
from .qtinfo import QtInfo
from .utils import memoize
@@ -356,7 +356,7 @@ class DistUtilsCommandMixin(object):
OPTION['SKIP_PACKAGING'] = self.skip_packaging
OPTION['VERBOSE_BUILD'] = self.verbose_build
if self.verbose_build:
- log.set_verbosity(1)
+ log.setLevel(logging.DEBUG)
OPTION['SANITIZE_ADDRESS'] = self.sanitize_address
OPTION['SHORTER_PATHS'] = self.shorter_paths
OPTION['DOC_BUILD_ONLINE'] = self.doc_build_online
diff --git a/build_scripts/setup_runner.py b/build_scripts/setup_runner.py
index 3be0fd407..371c20989 100644
--- a/build_scripts/setup_runner.py
+++ b/build_scripts/setup_runner.py
@@ -5,15 +5,16 @@ import os
import sys
import tempfile
import textwrap
+import logging
from setuptools import setup # Import setuptools before distutils
-from setuptools._distutils import log
from build_scripts.config import config
from build_scripts.main import (cmd_class_dict, get_package_version,
get_setuptools_extension_modules)
from build_scripts.options import ADDITIONAL_OPTIONS, OPTION
from build_scripts.utils import run_process
+from build_scripts.log import log
class SetupRunner(object):
@@ -185,15 +186,8 @@ class SetupRunner(object):
# Enable logging for both the top-level invocation of setup.py
# as well as for child invocations. We we now use
- # setuptools._distutils.log instead of distutils.log, and this
- # new log object does not have its verbosity set by default
- # when setuptools instantiates a distutils Distribution object,
- # which calls
- # dist.parse_command_line() -> log.set_verbosity(self.verbose)
- # on the old distutils log object.
- # So we do it explicitly here.
if not OPTION["QUIET"]:
- log.set_verbosity(log.INFO)
+ log.setLevel(logging.ERROR)
# This is an internal invocation of setup.py, so start actual
# build.
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 86df71316..9422afccd 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -17,9 +17,10 @@ from collections import defaultdict
from pathlib import Path
from textwrap import dedent, indent
+from .log import log
+
try:
# Using the distutils implementation within setuptools
- from setuptools._distutils import log
from setuptools.errors import SetupError
except ModuleNotFoundError:
# This is motivated by our CI using an old version of setuptools
@@ -886,7 +887,7 @@ def ldd(executable_path):
result = _ldd_ldd(executable_path)
except RuntimeError as e:
message = f"ldd: Falling back to ld.so ({str(e)})"
- log.warn(message)
+ log.warning(message)
if not result:
result = _ldd_ldso(executable_path)
return result
@@ -1148,7 +1149,7 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch):
_path = os.getenv(var, "")
_pExe = os.path.join(_path, "python.exe")
if not os.path.isfile(_pExe):
- log.warn(f"Can't find python.exe from {_pExe}, using default python3")
+ log.warning(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")
@@ -1159,7 +1160,7 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch):
_path = os.getenv(var, "")
_pExe = os.path.join(_path, "python.exe")
if not os.path.isfile(_pExe):
- log.warn(f"Can't find python.exe from {_pExe}, using default python3")
+ log.warning(f"Can't find python.exe from {_pExe}, using default python3")
_pExe = os.path.join(os.getenv("PYTHON3_PATH"), "python.exe")
env_python = f"{_env}\\Scripts\\python.exe"
env_pip = f"{_env}\\Scripts\\pip.exe"
@@ -1195,7 +1196,7 @@ def acceptCITestConfiguration(hostOS, hostOSVer, targetArch, compiler):
# 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"]:
- log.warn(f"Disabled {compiler} to {targetArch} from Coin configuration")
+ log.warning(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 a1620bca9..c77598e30 100644
--- a/build_scripts/wheel_override.py
+++ b/build_scripts/wheel_override.py
@@ -7,8 +7,7 @@ import platform
import sys
from email.generator import Generator
-from setuptools._distutils import log as logger
-
+from .log import log
from .options import OPTION, DistUtilsCommandMixin
from .utils import is_64bit
from .wheel_utils import get_package_version, get_qt_version, macos_plat_name
@@ -27,7 +26,7 @@ try:
wheel_module_exists = True
except Exception as 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}. "
+ log.warning(f"***** Exception while trying to prepare bdist_wheel override class: {e}. "
"Skipping wheel overriding.")
@@ -255,7 +254,7 @@ class PysideBuildWheel(_bdist_wheel, DistUtilsCommandMixin):
writeTag(impl)
wheelfile_path = os.path.join(wheelfile_base, 'WHEEL')
- logger.info(f'creating {wheelfile_path}')
+ log.info(f'creating {wheelfile_path}')
with open(wheelfile_path, 'w') as f:
Generator(f, maxheaderlen=0).flatten(msg)
diff --git a/coin_build_instructions.py b/coin_build_instructions.py
index 553bfa895..f81e8455c 100644
--- a/coin_build_instructions.py
+++ b/coin_build_instructions.py
@@ -2,18 +2,20 @@
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import calendar
import datetime
+import logging
import os
import os.path
import site
import sys
-from build_scripts.options import has_option, log, option_value
+from build_scripts.log import log
+from build_scripts.options import has_option, option_value
from build_scripts.utils import (expand_clang_variables, get_ci_qtpaths_path,
get_qtci_virtualEnv,
parse_cmake_conf_assignments_by_key, remove_tree,
run_instruction)
-log.set_verbosity(log.INFO)
+log.setLevel(logging.INFO)
# Values must match COIN thrift
CI_HOST_OS = option_value("os")
diff --git a/coin_test_instructions.py b/coin_test_instructions.py
index 461805043..cd521f044 100644
--- a/coin_test_instructions.py
+++ b/coin_test_instructions.py
@@ -1,14 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import os
+import logging
import site
import sys
+from build_scripts.log import log
from build_scripts.options import has_option, log, option_value
from build_scripts.utils import (expand_clang_variables, get_ci_qmake_path,
get_qtci_virtualEnv, remove_tree, run_instruction)
-log.set_verbosity(log.INFO)
+log.setLevel(logging.INFO)
# Values must match COIN thrift
CI_HOST_OS = option_value("os")
diff --git a/testing/runner.py b/testing/runner.py
index 20333ef3f..0d3b4c892 100644
--- a/testing/runner.py
+++ b/testing/runner.py
@@ -16,10 +16,10 @@ except NameError:
this_file = sys.argv[0]
this_file = os.path.abspath(this_file)
this_dir = os.path.dirname(this_file)
-build_scripts_dir = os.path.abspath(os.path.join(this_dir, "../build_scripts"))
+build_scripts_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.append(build_scripts_dir)
-from utils import detect_clang
+from build_scripts.utils import detect_clang
class TestRunner(object):
diff --git a/testing/wheel_tester.py b/testing/wheel_tester.py
index 81ea45e28..7c99fba90 100644
--- a/testing/wheel_tester.py
+++ b/testing/wheel_tester.py
@@ -20,6 +20,7 @@ import os
import platform
import sys
import tempfile
+import logging
from argparse import ArgumentParser, RawTextHelpFormatter
from pathlib import Path
@@ -32,12 +33,11 @@ this_dir = os.path.dirname(this_file)
setup_script_dir = os.path.abspath(os.path.join(this_dir, ".."))
sys.path.append(setup_script_dir)
-from setuptools._distutils import log
-
from build_scripts.utils import (find_files_using_glob, find_glob_in_path,
remove_tree, run_process, run_process_output)
+from build_scripts.log import log
-log.set_verbosity(1)
+log.setLevel(logging.DEBUG)
NEW_WHEELS = False