diff options
Diffstat (limited to 'build_scripts/wheel_utils.py')
-rw-r--r-- | build_scripts/wheel_utils.py | 97 |
1 files changed, 30 insertions, 67 deletions
diff --git a/build_scripts/wheel_utils.py b/build_scripts/wheel_utils.py index cea45b107..5ec26c742 100644 --- a/build_scripts/wheel_utils.py +++ b/build_scripts/wheel_utils.py @@ -1,54 +1,17 @@ -############################################################################# -## -## Copyright (C) 2020 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 +# 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 time +from pathlib import Path +from sysconfig import get_config_var, get_platform -from distutils.errors import DistutilsSetupError -from distutils.sysconfig import get_config_var -from distutils.util import get_platform -from distutils.version import LooseVersion +from packaging.version import parse as parse_version +from setuptools.errors import SetupError from .options import OPTION from .qtinfo import QtInfo -from .utils import memoize, get_python_dict -from .versions import PYSIDE +from .utils import memoize, parse_cmake_conf_assignments_by_key +from . import PYSIDE @memoize @@ -65,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 LooseVersion(qtinfo.version) < LooseVersion("5.7"): - raise DistutilsSetupError(f"Incompatible Qt version detected: {qt_version}. " - "A Qt version >= 5.7 is required.") + if parse_version(qtinfo.version) < parse_version("5.7"): + raise SetupError(f"Incompatible Qt version detected: {qt_version}. " + "A Qt version >= 5.7 is required.") return qt_version @@ -78,18 +40,21 @@ def get_qt_version(): @memoize def get_package_version(): """ Returns the version string for the PySide6 package. """ - setup_script_dir = os.getcwd() - pyside_version_py = os.path.join( - setup_script_dir, "sources", PYSIDE, "pyside_version.py") - d = get_python_dict(pyside_version_py) - final_version = f"{d['major_version']}.{d['minor_version']}.{d['patch_version']}" - release_version_type = d['release_version_type'] - pre_release_version = d['pre_release_version'] - if pre_release_version and release_version_type: + setup_script_dir = Path.cwd() + pyside_project_dir = setup_script_dir / "sources" / PYSIDE + d = parse_cmake_conf_assignments_by_key(pyside_project_dir) + major_version = d['pyside_MAJOR_VERSION'] + minor_version = d['pyside_MINOR_VERSION'] + patch_version = d['pyside_MICRO_VERSION'] + + final_version = f"{major_version}.{minor_version}.{patch_version}" + release_version_type = d.get('pyside_PRE_RELEASE_VERSION_TYPE') + pre_release_version = d.get('pyside_PRE_RELEASE_VERSION') + + if release_version_type and not release_version_type.startswith("comm") and pre_release_version: final_version = f"{final_version}{release_version_type}{pre_release_version}" - - if release_version_type.startswith("comm"): - final_version = f"{final_version}.{release_version_type}" + if release_version_type and release_version_type.startswith("comm"): + final_version = f"{final_version}+{release_version_type}" # Add the current timestamp to the version number, to suggest it # is a development snapshot build. @@ -102,7 +67,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 @@ -135,11 +100,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 |