aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristián Maureira-Fredes <[email protected]>2024-12-03 15:00:32 +0100
committerCristián Maureira-Fredes <[email protected]>2024-12-05 15:51:55 +0100
commitc5880ced5b6cfc7a07af9d4e7079af563ceae089 (patch)
treea5c198665e0be16f56e4d355bc9902d9f44ed20d
parentc660766e30737238310e4918eb163b933129ab24 (diff)
build: fetch metadata from pyproject.toml file
In a couple of releases we had inconsistencies between the wheel meta information from the build_scripts old scripts and the create_wheels new script. For old versions, we rely on tomli, but on new ones we use the standard tomllib one. Pick-to: 6.8 Change-Id: I114d8b0a240ad41cad8b57c27a0b3afadc928d94 Reviewed-by: Friedemann Kleint <[email protected]>
-rw-r--r--build_scripts/__init__.py3
-rw-r--r--build_scripts/config.py117
-rw-r--r--build_scripts/main.py2
-rw-r--r--create_wheels.py14
-rw-r--r--wheel_artifacts/pyproject.toml.base14
5 files changed, 66 insertions, 84 deletions
diff --git a/build_scripts/__init__.py b/build_scripts/__init__.py
index 569b5a2a2..17975e34d 100644
--- a/build_scripts/__init__.py
+++ b/build_scripts/__init__.py
@@ -1,6 +1,7 @@
# 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
from __future__ import annotations
+from pathlib import Path
PYSIDE = 'pyside6'
PYSIDE_MODULE = 'PySide6'
@@ -42,3 +43,5 @@ PYSIDE_WINDOWS_BIN_TOOLS = PYSIDE_UNIX_LIBEXEC_TOOLS + PYSIDE_LINUX_BIN_TOOLS
PYSIDE_MULTIMEDIA_LIBS = ["avcodec", "avformat", "avutil",
"swresample", "swscale"]
+
+PYPROJECT_PATH = Path(__file__).parents[1] / "wheel_artifacts" / "pyproject.toml.base"
diff --git a/build_scripts/config.py b/build_scripts/config.py
index 7d5bafc5f..ca7a148ab 100644
--- a/build_scripts/config.py
+++ b/build_scripts/config.py
@@ -6,9 +6,14 @@ import sys
from .log import log, LogLevel
from pathlib import Path
-from . import PYSIDE, PYSIDE_MODULE, SHIBOKEN
+from . import PYSIDE, PYSIDE_MODULE, SHIBOKEN, PYPROJECT_PATH
from .utils import available_pyside_tools
+try:
+ import tomllib
+except ModuleNotFoundError:
+ import tomli as tomllib
+
class Config(object):
def __init__(self):
@@ -57,20 +62,30 @@ class Config(object):
# 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.9',
- 'Programming Language :: Python :: 3.10',
- 'Programming Language :: Python :: 3.11',
- 'Programming Language :: Python :: 3.12',
- 'Programming Language :: Python :: 3.13',
- ]
-
self.setup_script_dir = None
+ # Getting data from base pyproject.toml file to be consistent
+
+ if not PYPROJECT_PATH.exists():
+ log.error("'pyproject.toml.base' not found in '{pyproject_path}'")
+
+ with open(PYPROJECT_PATH, "rb") as f:
+ _pyproject_data = tomllib.load(f)["project"]
+
+ self.setup_kwargs = {}
+ self.setup_kwargs['long_description_content_type'] = 'text/markdown'
+
+ self.setup_kwargs['keywords'] = _pyproject_data["keywords"]
+ _author, _email = _pyproject_data["authors"][0]
+ self.setup_kwargs['author'] = _author
+ self.setup_kwargs['author_email'] = _email
+ self.setup_kwargs['url'] = _pyproject_data["urls"]["Homepage"]
+ self.setup_kwargs['license'] = _pyproject_data["license"]["text"]
+ self.setup_kwargs['python_requires'] = _pyproject_data["requires-python"]
+
+ self.classifiers = _pyproject_data["classifiers"]
+ self.setup_kwargs['classifiers'] = self.classifiers
+
def init_config(self,
build_type=None,
internal_build_type=None,
@@ -105,24 +120,14 @@ class Config(object):
self.cmake_toolchain_file = cmake_toolchain_file
- setup_kwargs = {}
- setup_kwargs['long_description'] = self.get_long_description()
- setup_kwargs['long_description_content_type'] = 'text/markdown'
- setup_kwargs['keywords'] = 'Qt'
- setup_kwargs['author'] = 'Qt for Python Team'
- setup_kwargs['author_email'] = '[email protected]'
- setup_kwargs['url'] = 'https://www.pyside.org'
- setup_kwargs['download_url'] = 'https://download.qt.io/official_releases/QtForPython'
- setup_kwargs['license'] = 'LGPL'
- setup_kwargs['zip_safe'] = False
- setup_kwargs['cmdclass'] = cmd_class_dict
- setup_kwargs['version'] = package_version
- setup_kwargs['python_requires'] = ">=3.9, <3.14"
+ self.setup_kwargs['long_description'] = self.get_long_description()
+ self.setup_kwargs['cmdclass'] = cmd_class_dict
+ self.setup_kwargs['version'] = package_version
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
+ self.setup_kwargs['verbose'] = 0
# Setting these two keys is still a bit of a discussion point.
# In general not setting them will allow using "build" and
@@ -140,54 +145,29 @@ class Config(object):
# The only plausible usage of it, is if we will implement a
# correctly functioning setup.py develop command (or bdist_egg).
# But currently that doesn't seem to work.
- setup_kwargs['packages'] = self.get_setup_tools_packages_for_current_build()
- setup_kwargs['package_dir'] = self.get_package_name_to_dir_path_mapping()
+ self.setup_kwargs['packages'] = self.get_setup_tools_packages_for_current_build()
+ self.setup_kwargs['package_dir'] = self.get_package_name_to_dir_path_mapping()
# Add a bogus extension module (will never be built here since
# we are overriding the build command to do it using cmake) so
# things like bdist_egg will know that there are extension
# modules and will name the dist with the full platform info.
- setup_kwargs['ext_modules'] = ext_modules
-
- common_classifiers = [
- 'Development Status :: 5 - Production/Stable',
- 'Environment :: Console',
- 'Environment :: MacOS X',
- 'Environment :: X11 Applications :: Qt',
- 'Environment :: Win32 (MS Windows)',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)',
- 'License :: Other/Proprietary License',
- 'Operating System :: MacOS :: MacOS X',
- 'Operating System :: POSIX',
- 'Operating System :: POSIX :: Linux',
- 'Operating System :: Microsoft',
- 'Operating System :: Microsoft :: Windows',
- 'Programming Language :: C++']
- common_classifiers.extend(self.python_version_classifiers)
- common_classifiers.extend([
- 'Topic :: Database',
- 'Topic :: Software Development',
- 'Topic :: Software Development :: Code Generators',
- 'Topic :: Software Development :: Libraries :: Application Frameworks',
- 'Topic :: Software Development :: User Interfaces',
- 'Topic :: Software Development :: Widget Sets'])
- setup_kwargs['classifiers'] = common_classifiers
+ self.setup_kwargs['ext_modules'] = ext_modules
package_name = self.package_name()
if self.internal_build_type == self.shiboken_module_option_name:
- setup_kwargs['name'] = self.shiboken_module_st_name
- setup_kwargs['description'] = "Python / C++ bindings helper module"
- setup_kwargs['entry_points'] = {}
+ self.setup_kwargs['name'] = self.shiboken_module_st_name
+ self.setup_kwargs['description'] = "Python / C++ bindings helper module"
+ self.setup_kwargs['entry_points'] = {}
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'] = [
+ self.setup_kwargs['name'] = self.shiboken_generator_st_name
+ self.setup_kwargs['description'] = "Python / C++ bindings generator"
+ self.setup_kwargs['install_requires'] = [
f"{self.shiboken_module_st_name}=={package_version}"
]
- setup_kwargs['entry_points'] = {
+ self.setup_kwargs['entry_points'] = {
'console_scripts': [
f'{SHIBOKEN} = {package_name}.scripts.shiboken_tool:main',
f'{SHIBOKEN}-genpyi = {package_name}.scripts.shiboken_tool:genpyi',
@@ -195,10 +175,11 @@ 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'] = [
+ self.setup_kwargs['name'] = self.pyside_st_name
+ self.setup_kwargs['description'] = (
+ "Python bindings for the Qt cross-platform application and UI framework"
+ )
+ self.setup_kwargs['install_requires'] = [
f"{self.shiboken_module_st_name}=={package_version}"
]
if qt_install_path:
@@ -215,9 +196,7 @@ class Config(object):
_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
+ self.setup_kwargs['entry_points'] = {'console_scripts': _console_scripts}
def get_long_description(self):
readme_filename = 'README.md'
diff --git a/build_scripts/main.py b/build_scripts/main.py
index 7e06c3ddc..68ab512a0 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -121,7 +121,7 @@ def get_allowed_python_versions():
pattern = r'Programming Language :: Python :: (\d+)\.(\d+)'
supported = []
- for line in config.python_version_classifiers:
+ for line in config.classifiers:
found = re.search(pattern, line)
if found:
major = int(found.group(1))
diff --git a/create_wheels.py b/create_wheels.py
index 14130eee7..32a89a6a7 100644
--- a/create_wheels.py
+++ b/create_wheels.py
@@ -184,13 +184,13 @@ def generate_pyproject_toml(artifacts: Path, setup: SetupData) -> str:
with open(artifacts / "pyproject.toml.base") as f:
content = (
f.read()
- .replace("PROJECT_NAME", f'"{setup.name}"')
- .replace("PROJECT_VERSION", f'"{setup.version[1]}"')
- .replace("PROJECT_DESCRIPTION", f'"{setup.description}"')
- .replace("PROJECT_README", f'"{setup.readme}"')
- .replace("PROJECT_TAG", f'"{_tag}"')
- .replace("PROJECT_SCRIPTS", _console_scripts)
- .replace("PROJECT_DEPENDENCIES", f"{_dependencies}")
+ .replace('"PROJECT_NAME"', f'"{setup.name}"')
+ .replace('"PROJECT_VERSION"', f'"{setup.version[1]}"')
+ .replace('"PROJECT_DESCRIPTION"', f'"{setup.description}"')
+ .replace('"PROJECT_README"', f'"{setup.readme}"')
+ .replace('"PROJECT_TAG"', f'"{_tag}"')
+ .replace('# PROJECT_SCRIPTS', _console_scripts)
+ .replace('"PROJECT_DEPENDENCIES"', f"{_dependencies}")
)
return content
diff --git a/wheel_artifacts/pyproject.toml.base b/wheel_artifacts/pyproject.toml.base
index 5e73b2bd3..3e289fd79 100644
--- a/wheel_artifacts/pyproject.toml.base
+++ b/wheel_artifacts/pyproject.toml.base
@@ -3,17 +3,17 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project]
-name = PROJECT_NAME
+name = "PROJECT_NAME"
authors = [
{name = "Qt for Python Team", email = "[email protected]"},
]
-description = PROJECT_DESCRIPTION
-readme = PROJECT_README
+description = "PROJECT_DESCRIPTION"
+readme = "PROJECT_README"
dynamic = ["version"]
requires-python = ">=3.9, <3.14"
keywords = ["Qt"]
license = {text = "LGPL"}
-dependencies = PROJECT_DEPENDENCIES
+dependencies = "PROJECT_DEPENDENCIES"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
@@ -51,11 +51,11 @@ Repository = "https://code.qt.io/cgit/pyside/pyside-setup.git/"
Changelog = "https://code.qt.io/cgit/pyside/pyside-setup.git/tree/doc/changelogs"
Tracker = "https://bugreports.qt.io/projects/PYSIDE"
-PROJECT_SCRIPTS
+# PROJECT_SCRIPTS
[tool.distutils.bdist_wheel]
py_limited_api = "cp39"
-plat_name = PROJECT_TAG
+plat_name = "PROJECT_TAG"
[tool.setuptools.dynamic]
-version = {attr = PROJECT_VERSION}
+version = {attr = "PROJECT_VERSION"}