diff options
| author | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2022-10-13 12:36:23 +0200 |
|---|---|---|
| committer | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2022-10-18 11:34:52 +0200 |
| commit | 2afcf8e7545c681e412e5b6d04ab8867e5edd5c7 (patch) | |
| tree | 060e956fa8aa99301a60bab605b2fd3d3ed19f13 /build_scripts/options.py | |
| parent | 7f2c40d9b32b7b7b161d224c483b1fe23270c446 (diff) | |
pathlib: migrate build_scripts away from os.path
There is a usage of os.path.relpath that cannot be migrated
to pathlib, which remain the only usage of os.path
Task-number: PYSIDE-2080
Change-Id: Iac781e9c9324fb8b9d3559b4225912d56782072a
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'build_scripts/options.py')
| -rw-r--r-- | build_scripts/options.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/build_scripts/options.py b/build_scripts/options.py index c019a1061..9f1cb1f5e 100644 --- a/build_scripts/options.py +++ b/build_scripts/options.py @@ -14,11 +14,10 @@ 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 +from .utils import memoize, which _AVAILABLE_MKSPECS = ["ninja", "msvc", "mingw"] if sys.platform == "win32" else ["ninja", "make"] @@ -363,13 +362,13 @@ class CommandMixin(object): qtpaths_abs_path = None if self.qtpaths: - qtpaths_abs_path = os.path.abspath(self.qtpaths) + qtpaths_abs_path = self.qtpaths.resolve() OPTION['QTPATHS'] = qtpaths_abs_path # FIXME PYSIDE7: Remove qmake handling # make qtinfo.py independent of relative paths. qmake_abs_path = None if self.qmake: - qmake_abs_path = os.path.abspath(self.qmake) + qmake_abs_path = Path(self.qmake).resolve() OPTION['QMAKE'] = qmake_abs_path OPTION['HAS_QMAKE_OPTION'] = self.has_qmake_option OPTION['QT_VERSION'] = self.qt @@ -378,14 +377,15 @@ class CommandMixin(object): qt_target_path = None if self.qt_target_path: + self.qt_target_path = Path(self.qt_target_path) qt_target_path = self.qt_target_path # We use the CMake project to find host Qt if neither qmake or # qtpaths is available. This happens when building the host # tools in the overall cross-building process. use_cmake = False - if using_cmake_toolchain_file or \ - (not self.qmake and not self.qtpaths and self.qt_target_path): + if (using_cmake_toolchain_file or + (not self.qmake and not self.qtpaths and self.qt_target_path)): use_cmake = True QtInfo().setup(qtpaths_abs_path, self.cmake, qmake_abs_path, @@ -407,7 +407,7 @@ class CommandMixin(object): "Error was:\n\n\n") raise e - OPTION['CMAKE'] = os.path.abspath(self.cmake) + OPTION['CMAKE'] = self.cmake.resolve() OPTION['OPENSSL'] = self.openssl OPTION['SHIBOKEN_CONFIG_DIR'] = self.shiboken_config_dir if self.shiboken_config_dir: @@ -455,20 +455,26 @@ class CommandMixin(object): def _find_qtpaths_in_path(self): if not self.qtpaths: - self.qtpaths = which("qtpaths") + self.qtpaths = Path(which("qtpaths")) if not self.qtpaths: - self.qtpaths = which("qtpaths6") + self.qtpaths = Path(which("qtpaths6")) def _determine_defaults_and_check(self): if not self.cmake: - self.cmake = which("cmake") + self.cmake = Path(which("cmake")) if not self.cmake: log.error("cmake could not be found.") return False - if not os.path.exists(self.cmake): + if not self.cmake.exists(): log.error(f"'{self.cmake}' does not exist.") return False + # Setting up the Paths when passing via command line + if isinstance(self.qtpaths, str): + self.qtpaths = Path(self.qtpaths) + if isinstance(self.qmake, str): + self.qmake = Path(self.qmake) + # When cross-compiling, we only accept the qt-target-path # option and don't rely on auto-searching in PATH or the other # qtpaths / qmake options. @@ -493,17 +499,17 @@ class CommandMixin(object): return False # Validate that the given tool path exists. - if self.qtpaths and not os.path.exists(self.qtpaths): + if self.qtpaths and not self.qtpaths.exists(): log.error(f"The specified qtpaths path '{self.qtpaths}' does not exist.") return False - if self.qmake and not os.path.exists(self.qmake): + if self.qmake and not self.qmake.exists(): log.error(f"The specified qmake path '{self.qmake}' does not exist.") return False else: # Check for existence, but don't require if it's not set. A # check later will be done to see if it's needed. - if self.qt_target_path and not os.path.exists(self.qt_target_path): + if self.qt_target_path and not self.qt_target_path.exists(): log.error(f"Provided --qt-target-path='{self.qt_target_path}' " "path does not exist.") return False |
