aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-05-19 18:41:05 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-05-27 18:21:55 +0000
commit725be71849fe11f07d0b6f40eedec7e85b5f320d (patch)
tree9e16a7627859e2f61ee62b303f5d99547a1ae5b3 /build_scripts
parentcc09c222ee636af9742736af1357c8373cb2f9d3 (diff)
Limited_API: Fix PyIndex_Check once and for all
PyIndex_Check was left as a macro for Python <= 3.7 . This was fixed for Python 3.8 (I failed to submit the patch in time :( ) The problem is a bit weird, because we cannot do a compile time decision which Python version it is, because exactly that is only known at runtime. Therefore: - we cannot use a builtin version of PyIndex_Check, because this would create a link error with Python < 3.8 - PyType_GetSlot would help with this, but unfortunately this worked only with heap types, and the use case is on normal integers. The solution is quite ok: ------------------------- The structure of the type objects from Python 3.6 on is compatible enough for the field offset that we need here, so on old Python versions, the old type structure can be used. From Python 3.10 on, PyType_GetSlot is extended to non-heap types, and we can simply use that. This patch can be removed completely when we drop Python 3.7 . An automated warning that suggests this removal was added. [ChangeLog][shiboken6] The handling of a complex Limited API bug was fixed for different combinations of PySide/Python versions. Change-Id: I945aa5ae1ea5cd9de7c6e140c32a1e9467735a8e Fixes: PYSIDE-1797 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit bcd1ac22f8e4e804b4082e311d4a8c43f3f3d4d6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'build_scripts')
-rw-r--r--build_scripts/main.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index b4576d0e8..e25f22bd0 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -151,11 +151,12 @@ def get_make(platform_arch, build_type):
return (make_path, make_generator)
-def check_allowed_python_version():
- """
- Make sure that setup.py is run with an allowed python version.
- """
+_allowed_versions_cache = None
+def get_allowed_python_versions():
+ global _allowed_versions_cache
+ if _allowed_versions_cache is not None:
+ return _allowed_versions_cache
pattern = r'Programming Language :: Python :: (\d+)\.(\d+)'
supported = []
@@ -165,6 +166,17 @@ def check_allowed_python_version():
major = int(found.group(1))
minor = int(found.group(2))
supported.append((major, minor))
+
+ _allowed_versions_cache = sorted(supported)
+ return _allowed_versions_cache
+
+
+def check_allowed_python_version():
+ """
+ Make sure that setup.py is run with an allowed python version.
+ """
+
+ supported = get_allowed_python_versions()
this_py = sys.version_info[:2]
if this_py not in supported:
log.error(f"Unsupported python version detected. Supported versions: {supported}")
@@ -589,6 +601,8 @@ class PysideBuild(_build, DistUtilsCommandMixin, BuildInfoCollectorMixin):
f"-DQt5Help_DIR={self.qtinfo.docs_dir}",
f"-DCMAKE_BUILD_TYPE={self.build_type}",
f"-DCMAKE_INSTALL_PREFIX={self.install_dir}",
+ # Record the minimum Python version for later use in Shiboken.__init__
+ f"-DMINIMUM_PYTHON_VERSION={get_allowed_python_versions()[0]}",
module_src_dir
]