diff options
| author | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2022-10-11 18:01:26 +0200 |
|---|---|---|
| committer | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2022-10-13 18:56:55 +0200 |
| commit | 19acc417df1a920a5ded49258cf4b88f837fbcdc (patch) | |
| tree | 81ff795124b5797faa937663c98a4f9ae2926fdb | |
| parent | 90289a1be1735cde5fc2471bc599de30bcbefc89 (diff) | |
build: replace DistutilsSetupError by SetupError
Replacing the distutils errors by the setuptools one.
Task-number: PYSIDE-2079
Change-Id: I9968d9562f8dd40317344d3295943c194e3f2197
Reviewed-by: Christian Tismer <tismer@stackless.com>
| -rw-r--r-- | build_scripts/build_info_collector.py | 6 | ||||
| -rw-r--r-- | build_scripts/main.py | 38 | ||||
| -rw-r--r-- | build_scripts/utils.py | 12 | ||||
| -rw-r--r-- | build_scripts/wheel_utils.py | 17 |
4 files changed, 35 insertions, 38 deletions
diff --git a/build_scripts/build_info_collector.py b/build_scripts/build_info_collector.py index 9310c0552..8dca5c203 100644 --- a/build_scripts/build_info_collector.py +++ b/build_scripts/build_info_collector.py @@ -8,7 +8,7 @@ from sysconfig import get_config_var from setuptools._distutils import log from setuptools._distutils import sysconfig as sconfig -from setuptools._distutils.errors import DistutilsSetupError +from setuptools.errors import SetupError from .options import OPTION from .qtinfo import QtInfo @@ -50,7 +50,7 @@ def _get_py_library_win(build_type, py_version, py_prefix, py_libdir, # same base directory to define the py_libdir variable. py_libdir = os.path.join(os.path.dirname(py_include_dir), "libs") if not os.path.isdir(py_libdir): - raise DistutilsSetupError("Failed to locate the 'libs' directory") + raise SetupError("Failed to locate the 'libs' directory") dbg_postfix = "_d" if build_type == "Debug" else "" if OPTION["MAKESPEC"] == "mingw": static_lib_name = f"libpython{py_version.replace('.', '')}{dbg_postfix}.a" @@ -111,7 +111,7 @@ def _get_py_library_unix(build_type, py_version, py_prefix, py_libdir, return pypy_library libs_tried.append(pypy_library) _libs_tried = ', '.join(libs_tried) - raise DistutilsSetupError(f"Failed to locate the Python library with {_libs_tried}") + raise SetupError(f"Failed to locate the Python library with {_libs_tried}") def get_py_library(build_type, py_version, py_prefix, py_libdir, py_include_dir): diff --git a/build_scripts/main.py b/build_scripts/main.py index 803519de1..ed31c3384 100644 --- a/build_scripts/main.py +++ b/build_scripts/main.py @@ -30,7 +30,7 @@ from setuptools.command.install_scripts import install_scripts # noqa: preload from setuptools._distutils import log from setuptools._distutils import sysconfig as sconfig from setuptools._distutils.command.build import build as _build -from setuptools._distutils.errors import DistutilsSetupError +from setuptools.errors import SetupError from .build_info_collector import BuildInfoCollectorMixin from .config import config @@ -84,7 +84,7 @@ def _get_make(platform_arch, build_type): init_msvc_env(platform_arch, build_type) nmake_path = which("nmake") if not nmake_path or not os.path.exists(nmake_path): - raise DistutilsSetupError('"nmake" could not be found.') + raise SetupError('"nmake" could not be found.') if not OPTION["NO_JOM"]: jom_path = which("jom") if jom_path: @@ -93,13 +93,13 @@ def _get_make(platform_arch, build_type): log.info(f"nmake was found in {nmake_path}") if OPTION["JOBS"]: msg = "Option --jobs can only be used with 'jom' on Windows." - raise DistutilsSetupError(msg) + raise SetupError(msg) return (nmake_path, "NMake Makefiles") if makespec == "mingw": return ("mingw32-make", "mingw32-make") if makespec == "ninja": return ("ninja", "Ninja") - raise DistutilsSetupError(f'Invalid option --make-spec "{makespec}".') + raise SetupError(f'Invalid option --make-spec "{makespec}".') def get_make(platform_arch, build_type): @@ -110,7 +110,7 @@ def get_make(platform_arch, build_type): if not found_path or not os.path.exists(found_path): m = (f"You need the program '{make_path}' on your system path to " f"compile {PYSIDE_MODULE}.") - raise DistutilsSetupError(m) + raise SetupError(m) make_path = found_path return (make_path, make_generator) @@ -356,8 +356,8 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): log.info(f"Adding {clangBinDir} as detected by {clang_source} to PATH") additional_paths.append(clangBinDir) else: - raise DistutilsSetupError("Failed to detect Clang when checking " - "LLVM_INSTALL_DIR, CLANG_INSTALL_DIR, llvm-config") + raise SetupError("Failed to detect Clang when checking " + "LLVM_INSTALL_DIR, CLANG_INSTALL_DIR, llvm-config") update_env_path(additional_paths) @@ -684,8 +684,8 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): elif not OPTION["LIMITED_API"]: pass else: - raise DistutilsSetupError("option limited-api must be 'yes' or 'no' " - "(default yes if applicable, i.e. python version >= 3.6)") + raise SetupError("option limited-api must be 'yes' or 'no' " + "(default yes if applicable, i.e. python version >= 3.6)") if OPTION["VERBOSE_BUILD"]: cmake_cmd.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON") @@ -701,7 +701,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): or sys.platform.startswith('darwin')): cmake_cmd.append("-DSANITIZE_ADDRESS=ON") else: - raise DistutilsSetupError("Address sanitizer can only be used on Linux and macOS.") + raise SetupError("Address sanitizer can only be used on Linux and macOS.") if extension.lower() == PYSIDE: pyside_qt_conf_prefix = '' @@ -798,7 +798,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): if self.is_cross_compile and (not OPTION["SHIBOKEN_HOST_PATH"] or not os.path.exists(OPTION["SHIBOKEN_HOST_PATH"])): - raise DistutilsSetupError( + raise SetupError( "Please specify the location of host shiboken tools via --shiboken-host-path=") if self.shiboken_host_path: @@ -817,7 +817,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): if not OPTION["SKIP_CMAKE"]: log.info(f"Configuring module {extension} ({module_src_dir})...") if run_process(cmake_cmd) != 0: - raise DistutilsSetupError(f"Error configuring {extension}") + raise SetupError(f"Error configuring {extension}") else: log.info(f"Reusing old configuration for module {extension} ({module_src_dir})...") @@ -828,7 +828,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): if OPTION["VERBOSE_BUILD"] and self.make_generator == "Ninja": cmd_make.append("-v") if run_process(cmd_make) != 0: - raise DistutilsSetupError(f"Error compiling {extension}") + raise SetupError(f"Error compiling {extension}") if sys.version_info == (3, 6) and sys.platform == "darwin": # Python 3.6 has a Sphinx problem because of docutils 0.17 . @@ -846,7 +846,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): if OPTION["VERBOSE_BUILD"] and self.make_generator == "Ninja": make_doc_cmd.append("-v") if run_process(make_doc_cmd) != 0: - raise DistutilsSetupError("Error generating documentation " + raise SetupError("Error generating documentation " f"for {extension}") else: log.info("Sphinx not found, skipping documentation build") @@ -866,7 +866,7 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin): # ninja: error: unknown target 'install/fast' target = 'install/fast' if self.make_generator != 'Ninja' else 'install' if run_process([self.make_path, target]) != 0: - raise DistutilsSetupError(f"Error pseudo installing {extension}") + raise SetupError(f"Error pseudo installing {extension}") else: log.info(f"Skipped installing module {extension}") @@ -1208,7 +1208,7 @@ class PysideRstDocs(Command, DistUtilsCommandMixin): log.info("-- Generating PySide documentation") log.info(f"-- Documentation directory: 'html/{PYSIDE}/'") else: - raise DistutilsSetupError("Sphinx not found - aborting") + raise SetupError("Sphinx not found - aborting") self.html_dir = "html" # creating directories html/pyside6/shiboken6 @@ -1228,7 +1228,7 @@ class PysideRstDocs(Command, DistUtilsCommandMixin): elif self.name == PYSIDE: self.out_dir = os.path.join(self.html_dir, PYSIDE) except (PermissionError, FileExistsError): - raise DistutilsSetupError(f"Error while creating directories for {self.doc_dir}") + raise SetupError(f"Error while creating directories for {self.doc_dir}") def run(self): if not self.skip: @@ -1242,7 +1242,7 @@ class PysideRstDocs(Command, DistUtilsCommandMixin): if OPTION["QUIET"]: cmake_cmd.append('-DQUIET_BUILD=1') if run_process(cmake_cmd) != 0: - raise DistutilsSetupError(f"Error running CMake for {self.doc_dir}") + raise SetupError(f"Error running CMake for {self.doc_dir}") if self.name == PYSIDE: self.sphinx_src = os.path.join(self.out_dir, "rst") @@ -1252,7 +1252,7 @@ class PysideRstDocs(Command, DistUtilsCommandMixin): sphinx_cmd = ["sphinx-build", "-b", "html", "-j", "auto", "-c", self.sphinx_src, self.doc_dir, self.out_dir] if run_process(sphinx_cmd) != 0: - raise DistutilsSetupError(f"Error running CMake for {self.doc_dir}") + raise SetupError(f"Error running CMake for {self.doc_dir}") # Last message if not self.skip and self.name == PYSIDE: log.info(f"-- The documentation was built. Check html/{PYSIDE}/index.html") diff --git a/build_scripts/utils.py b/build_scripts/utils.py index 06a9cd1f2..86df71316 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -20,13 +20,13 @@ from textwrap import dedent, indent try: # Using the distutils implementation within setuptools from setuptools._distutils import log - from setuptools._distutils.errors import DistutilsSetupError + from setuptools.errors import SetupError 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.errors import DistutilsSetupError + from distutils.errors import DistutilsSetupError as SetupError try: WindowsError @@ -96,8 +96,8 @@ def winsdk_setenv(platform_arch, build_type): continue setenv_paths.append(setenv_path) if len(setenv_paths) == 0: - raise DistutilsSetupError("Failed to find the Windows SDK with MSVC compiler " - f"version {msvc9.VERSION}") + raise SetupError("Failed to find the Windows SDK with MSVC " + f"compiler version {msvc9.VERSION}") for setenv_path in setenv_paths: log.info(f"Found {setenv_path}") @@ -172,8 +172,8 @@ def init_msvc_env(platform_arch, build_type): log.info(f"Searching MSVC compiler version {msvc9.VERSION}") vcdir_path = find_vcdir(msvc9.VERSION) if not vcdir_path: - raise DistutilsSetupError(f"Failed to find the MSVC compiler version {msvc9.VERSION} on " - "your system.") + raise SetupError(f"Failed to find the MSVC compiler version {msvc9.VERSION} on " + "your system.") else: log.info(f"Found {vcdir_path}") diff --git a/build_scripts/wheel_utils.py b/build_scripts/wheel_utils.py index d485aeb2f..31d8c7bd0 100644 --- a/build_scripts/wheel_utils.py +++ b/build_scripts/wheel_utils.py @@ -6,7 +6,7 @@ import time from sysconfig import get_config_var, get_platform from packaging.version import parse as parse_version -from setuptools._distutils.errors import DistutilsSetupError +from setuptools.errors import SetupError from .options import OPTION from .qtinfo import QtInfo @@ -28,12 +28,11 @@ def get_qt_version(): qt_version = qtinfo.version if not qt_version: - raise DistutilsSetupError("Failed to query the Qt version with " - f"qmake {qtinfo.qmake_command}") + raise SetupError("Failed to query the Qt version with qmake {qtinfo.qmake_command}") if parse_version(qtinfo.version) < parse_version("5.7"): - raise DistutilsSetupError(f"Incompatible Qt version detected: {qt_version}. " - "A Qt version >= 5.7 is required.") + raise SetupError(f"Incompatible Qt version detected: {qt_version}. " + "A Qt version >= 5.7 is required.") return qt_version @@ -69,7 +68,7 @@ def macos_qt_min_deployment_target(): target = QtInfo().macos_min_deployment_target if not target: - raise DistutilsSetupError("Failed to query for Qt's QMAKE_MACOSX_DEPLOYMENT_TARGET.") + raise SetupError("Failed to query for Qt's QMAKE_MACOSX_DEPLOYMENT_TARGET.") return target @@ -102,11 +101,9 @@ def macos_pyside_min_deployment_target(): # precedence. if setup_target: if python_target and setup_target_split < python_target_split: - raise DistutilsSetupError(message.format(setup_target, "Python", - python_target)) + raise SetupError(message.format(setup_target, "Python", python_target)) if setup_target_split < qt_target_split: - raise DistutilsSetupError(message.format(setup_target, "Qt", - qt_target)) + raise SetupError(message.format(setup_target, "Qt", qt_target)) # All checks clear, use setup.py provided value. return setup_target |
