diff options
Diffstat (limited to 'build_scripts/config.py')
-rw-r--r-- | build_scripts/config.py | 137 |
1 files changed, 66 insertions, 71 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py index 3686f4ff0..0a6eebf78 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -1,45 +1,12 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of Qt for Python. -## -## $QT_BEGIN_LICENSE:LGPL$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 3 as published by the Free Software -## Foundation and appearing in the file LICENSE.LGPL3 included in the -## packaging of this file. Please review the following information to -## ensure the GNU Lesser General Public License version 3 requirements -## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 2.0 or (at your option) the GNU General -## Public license version 3 or any later version approved by the KDE Free -## Qt Foundation. The licenses are as published by the Free Software -## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-2.0.html and -## https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -import os -import distutils.log as log -from .versions import PYSIDE, PYSIDE_MODULE, SHIBOKEN +# Copyright (C) 2018 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 sys +from .log import log, LogLevel +from pathlib import Path + +from . import PYSIDE, PYSIDE_MODULE, SHIBOKEN +from .utils import available_pyside_tools class Config(object): @@ -82,24 +49,36 @@ class Config(object): self.shiboken_generator_st_name = f"{SHIBOKEN}-generator" self.pyside_st_name = PYSIDE_MODULE + # Path to CMake toolchain file when intending to cross compile + # the project. + self.cmake_toolchain_file = None + + # Store where host shiboken is built during a cross-build. + self.shiboken_host_query_path = None + # Used by check_allowed_python_version to validate the # interpreter version. self.python_version_classifiers = [ 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ] self.setup_script_dir = None - def init_config(self, build_type=None, internal_build_type=None, - cmd_class_dict=None, package_version=None, - ext_modules=None, setup_script_dir=None, - quiet=False): + def init_config(self, + build_type=None, + internal_build_type=None, + cmd_class_dict=None, + package_version=None, + ext_modules=None, + setup_script_dir=None, + cmake_toolchain_file=None, + log_level=LogLevel.INFO, + qt_install_path: Path = None): """ Sets up the global singleton config which is used in many parts of the setup process. @@ -120,7 +99,9 @@ class Config(object): else: self.build_type = self._build_type_all - self.setup_script_dir = setup_script_dir + self.setup_script_dir = Path(setup_script_dir) + + self.cmake_toolchain_file = cmake_toolchain_file setup_kwargs = {} setup_kwargs['long_description'] = self.get_long_description() @@ -134,10 +115,10 @@ class Config(object): setup_kwargs['zip_safe'] = False setup_kwargs['cmdclass'] = cmd_class_dict setup_kwargs['version'] = package_version - setup_kwargs['python_requires'] = ">=3.6, <3.10" + setup_kwargs['python_requires'] = ">=3.9, <3.13" - if quiet: - # Tells distutils / setuptools to be quiet, and only print warnings or errors. + if log_level == LogLevel.QUIET: + # Tells setuptools to be quiet, and only print warnings or errors. # Makes way less noise in the terminal when building. setup_kwargs['verbose'] = 0 @@ -201,7 +182,9 @@ class Config(object): elif self.internal_build_type == self.shiboken_generator_option_name: setup_kwargs['name'] = self.shiboken_generator_st_name setup_kwargs['description'] = "Python / C++ bindings generator" - setup_kwargs['install_requires'] = [f"{self.shiboken_module_st_name}=={package_version}"] + setup_kwargs['install_requires'] = [ + f"{self.shiboken_module_st_name}=={package_version}" + ] setup_kwargs['entry_points'] = { 'console_scripts': [ f'{SHIBOKEN} = {package_name}.scripts.shiboken_tool:main', @@ -211,20 +194,27 @@ class Config(object): elif self.internal_build_type == self.pyside_option_name: setup_kwargs['name'] = self.pyside_st_name - setup_kwargs['description'] = "Python bindings for the Qt cross-platform application and UI framework" - setup_kwargs['install_requires'] = [f"{self.shiboken_module_st_name}=={package_version}"] - setup_kwargs['entry_points'] = { - 'console_scripts': [ - f'{PYSIDE}-uic = {package_name}.scripts.pyside_tool:uic', - f'{PYSIDE}-rcc = {package_name}.scripts.pyside_tool:rcc', - f'{PYSIDE}-assistant = {package_name}.scripts.pyside_tool:assistant', - f'{PYSIDE}-designer= {package_name}.scripts.pyside_tool:designer', - f'{PYSIDE}-linguist = {package_name}.scripts.pyside_tool:linguist', - f'{PYSIDE}-lupdate = {package_name}.scripts.pyside_tool:lupdate', - f'{PYSIDE}-lrelease = {package_name}.scripts.pyside_tool:lrelease', - f'{PYSIDE}-genpyi = {package_name}.scripts.pyside_tool:genpyi', - ] - } + setup_kwargs['description'] = ("Python bindings for the Qt cross-platform application " + "and UI framework") + setup_kwargs['install_requires'] = [ + f"{self.shiboken_module_st_name}=={package_version}" + ] + if qt_install_path: + _pyside_tools = available_pyside_tools(qt_tools_path=qt_install_path) + + # replacing pyside6-android_deploy by pyside6-android-deploy for consistency + # Also, the tool should not exist in any other platform than Linux + _console_scripts = [] + if ("android_deploy" in _pyside_tools) and sys.platform.startswith("linux"): + _console_scripts = [(f"{PYSIDE}-android-deploy =" + " PySide6.scripts.pyside_tool:android_deploy")] + _pyside_tools.remove("android_deploy") + + _console_scripts.extend([f'{PYSIDE}-{tool} = {package_name}.scripts.pyside_tool:' + f'{tool}' for tool in _pyside_tools]) + + setup_kwargs['entry_points'] = {'console_scripts': _console_scripts} + self.setup_kwargs = setup_kwargs def get_long_description(self): @@ -241,7 +231,7 @@ class Config(object): content = '' changes = '' try: - with open(os.path.join(self.setup_script_dir, readme_filename)) as f: + with open(self.setup_script_dir / readme_filename) as f: readme = f.read() except Exception as e: log.error(f"Couldn't read contents of {readme_filename}. {e}") @@ -252,7 +242,7 @@ class Config(object): include_changes = False if include_changes: try: - with open(os.path.join(self.setup_script_dir, changes_filename)) as f: + with open(self.setup_script_dir / changes_filename) as f: changes = f.read() except Exception as e: log.error(f"Couldn't read contents of {changes_filename}. {e}") @@ -260,7 +250,7 @@ class Config(object): content += readme if changes: - content += "\n\n" + changes + content += f"\n\n{changes}" return content @@ -364,6 +354,11 @@ class Config(object): def is_top_level_build_pyside(self): return self.build_type == self.pyside_option_name + def is_cross_compile(self): + if not self.cmake_toolchain_file: + return False + return True + def set_internal_build_type(self, internal_build_type): self.internal_build_type = internal_build_type |