diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2022-11-21 16:37:34 +0100 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-02-08 11:22:23 +0100 |
commit | bf73772d2c43a71d13a55e9914c631591cd01815 (patch) | |
tree | 3d6954fa946b5c664af10bf4be242a49a255466f /build_scripts | |
parent | 08ec50ff3b569e2062285ee633f5c7e548c67545 (diff) |
PySide Build: find qtpaths before SetupRunner.run_setup()
- 'qtpaths' needs to be known while setting up the corresponding
setup.py command to ignore the pyside qt wrapper tools whose qt tool
does not exist
- This is an extension to 43109854a2966afe2e0cf29961157a6f54d5775c.
The aforementioned patch led to qtpaths being found 2 times, once
inside CommandMixin class and also much before that inside
SetupRunner.run_setup(). This redundancy is now removed by moving
the finding of OPTION['QTPATHS'] outside the mixin and before
CommandMixin object of the command being run is initialized
- the help commands, build_rst_docs and cross compilation command
should not complain about qtpaths anymore
- fixed cross compilation build
Task-number: PYSIDE-2195
Change-Id: I862baf954dea0a3bdaf5ddf411f119178b457c42
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'build_scripts')
-rw-r--r-- | build_scripts/config.py | 12 | ||||
-rw-r--r-- | build_scripts/options.py | 74 | ||||
-rw-r--r-- | build_scripts/setup_runner.py | 13 | ||||
-rw-r--r-- | build_scripts/utils.py | 14 |
4 files changed, 60 insertions, 53 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py index f13ed0482..1f01ccdd4 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -199,11 +199,13 @@ class Config(object): setup_kwargs['install_requires'] = [ f"{self.shiboken_module_st_name}=={package_version}" ] - _pyside_tools = available_pyside_tools(qt_tools_path=qt_install_path) - setup_kwargs['entry_points'] = { - 'console_scripts': [f'{PYSIDE}-{tool} = {package_name}.scripts.pyside_tool:{tool}' - for tool in _pyside_tools] - } + if qt_install_path: + _pyside_tools = available_pyside_tools(qt_tools_path=qt_install_path) + setup_kwargs['entry_points'] = { + 'console_scripts': [f'{PYSIDE}-{tool} = {package_name}.scripts.pyside_tool:' + f'{tool}' + for tool in _pyside_tools] + } self.setup_kwargs = setup_kwargs def get_long_description(self): diff --git a/build_scripts/options.py b/build_scripts/options.py index fdca440a5..d384be2c9 100644 --- a/build_scripts/options.py +++ b/build_scripts/options.py @@ -76,6 +76,7 @@ class Options(object): :return: Either the option value or None. """ + option = f"--{name}" short_option = f"-{short_option_name}" if short_option_name else None single_option_prefix = f"{option}=" @@ -125,6 +126,30 @@ def _jobs_option_value(): return '' +def find_qtpaths(): + # for these command --qtpaths should not be required + no_qtpaths_commands = ["--help", "--help-commands", "--qt-target-path", "build_rst_docs"] + + for no_qtpaths_command in no_qtpaths_commands: + if any(no_qtpaths_command in argument for argument in sys.argv): + return None + + qtpaths = option_value("qtpaths") + if qtpaths: + return qtpaths + + # if qtpaths is not given as cli option, try to find it in PATH + qtpaths = which("qtpaths6") + if qtpaths: + return str(qtpaths.resolve()) + + qtpaths = which("qtpaths") + if qtpaths: + return str(qtpaths.resolve()) + + return qtpaths + + # Declare options which need to be known when instantiating the setuptools # commands or even earlier during SetupRunner.run(). OPTION = { @@ -147,9 +172,13 @@ OPTION = { "CMAKE_TOOLCHAIN_FILE": option_value("cmake-toolchain-file"), "SHIBOKEN_HOST_PATH": option_value("shiboken-host-path"), "SHIBOKEN_HOST_PATH_QUERY_FILE": option_value("internal-shiboken-host-path-query-file"), - "QT_HOST_PATH": option_value("qt-host-path") + "QT_HOST_PATH": option_value("qt-host-path"), # This is used to identify the template for doc builds + "QTPATHS": find_qtpaths() + # This is an optional command line option. If --qtpaths is not provided via command-line, + # then qtpaths is checked inside PATH variable } + _deprecated_option_jobs = option_value('jobs') if _deprecated_option_jobs: _warn_deprecated_option('jobs', 'parallel') @@ -303,6 +332,9 @@ class CommandMixin(object): if key not in current_command_opts and key in mixin_options_set: current_command_opts[key] = value + # qtpaths is already known before running SetupRunner + self.qtpaths = OPTION["QTPATHS"] + @staticmethod @memoize def get_mixin_options_set(): @@ -398,9 +430,9 @@ class CommandMixin(object): OPTION['UNITY_BUILD_BATCH_SIZE'] = self.unity_build_batch_size qtpaths_abs_path = None - if self.qtpaths: - qtpaths_abs_path = self.qtpaths.resolve() - OPTION['QTPATHS'] = qtpaths_abs_path + if self.qtpaths and Path(self.qtpaths).exists(): + qtpaths_abs_path = Path(self.qtpaths).resolve() + # FIXME PYSIDE7: Remove qmake handling # make qtinfo.py independent of relative paths. qmake_abs_path = None @@ -428,18 +460,19 @@ class CommandMixin(object): qt_target_path=qt_target_path, cmake_toolchain_file=cmake_toolchain_file) - try: - QtInfo().prefix_dir - except Exception as e: - if not self.qt_target_path: - log.error( - "\nCould not find Qt. You can pass the --qt-target-path=<qt-dir> option as a " - "hint where to find Qt. Error was:\n\n\n") - else: - log.error( - f"\nCould not find Qt via provided option --qt-target-path={qt_target_path} " - "Error was:\n\n\n") - raise e + if 'build_rst_docs' not in sys.argv: + try: + QtInfo().prefix_dir + except Exception as e: + if not self.qt_target_path: + log.error( + "\nCould not find Qt. You can pass the --qt-target-path=<qt-dir> option " + "as a hint where to find Qt. Error was:\n\n\n") + else: + log.error( + f"\nCould not find Qt via provided option --qt-target-path={qt_target_path}" + "Error was:\n\n\n") + raise e OPTION['CMAKE'] = self.cmake.resolve() OPTION['OPENSSL'] = self.openssl @@ -487,10 +520,6 @@ class CommandMixin(object): return False return True - def _find_qtpaths_in_path(self): - if not self.qtpaths: - self.qtpaths = Path(which("qtpaths6")) - def _determine_defaults_and_check(self): if not self.cmake: self.cmake = Path(which("cmake")) @@ -523,11 +552,6 @@ class CommandMixin(object): self.has_qmake_option = True _warn_deprecated_option('qmake', 'qtpaths') - # If no option was given explicitly, prefer to find qtpaths - # in PATH. - if not self.qmake and not self.qtpaths: - self._find_qtpaths_in_path() - # If no tool was specified and qtpaths was not found in PATH, # ask to provide a path to qtpaths. if not self.qtpaths and not self.qmake and not self.qt_target_path: diff --git a/build_scripts/setup_runner.py b/build_scripts/setup_runner.py index fc4cb0e5e..6a7de04c9 100644 --- a/build_scripts/setup_runner.py +++ b/build_scripts/setup_runner.py @@ -14,7 +14,7 @@ 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, find_qt_install_path +from build_scripts.utils import run_process from build_scripts.log import log, LogLevel @@ -174,14 +174,9 @@ class SetupRunner(object): # PYSIDE-1746: We prevent the generation of .pyc/.pyo files during installation. # These files are generated anyway on their import. sys.dont_write_bytecode = True - - # find qtpaths - arg_qt = list(filter(lambda v: v.startswith("--qtpaths"), sys.argv)) - if len(arg_qt) != 0: - qt_install_path = arg_qt[0].replace("--qtpaths=", "") - qt_install_path = Path(qt_install_path).absolute().parents[1] - else: - qt_install_path = find_qt_install_path() + qt_install_path = OPTION["QTPATHS"] + if qt_install_path: + qt_install_path = Path(qt_install_path).parents[1] # Prepare initial config. config.init_config(build_type=OPTION["BUILD_TYPE"], diff --git a/build_scripts/utils.py b/build_scripts/utils.py index efb53ff25..54677a65f 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -1152,20 +1152,6 @@ def available_pyside_tools(qt_tools_path: Path, package_for_wheels: bool = False return pyside_tools -def find_qt_install_path() -> Path: - """ - Find Qt installation path - """ - - def where_is(x): - return Path(which(x)) - - qtpaths = where_is("qtpaths") if where_is("qtpaths") else where_is("qtpaths6") - if not qtpaths: - raise RuntimeError("qtpaths not found") - else: - return qtpaths.parents[1] - def copy_qt_metatypes(destination_qt_dir, _vars): """Copy the Qt metatypes files which changed location in 6.5""" # <qt>/[lib]?/metatypes/* -> <setup>/{st_package_name}/Qt/[lib]?/metatypes |