diff --git a/setup/build.py b/setup/build.py index f183a9365528..eaea80aa76d4 100644 --- a/setup/build.py +++ b/setup/build.py @@ -487,6 +487,10 @@ def build_headless(self): os.rename(self.j(self.d(target), 'libheadless.dylib'), self.j(self.d(target), 'headless.so')) def create_sip_build_skeleton(self, src_dir, ext): + from setup.build_environment import pyqt_sip_abi_version + abi_version = '' + if pyqt_sip_abi_version(): + abi_version = f'abi-version = "{pyqt_sip_abi_version()}"' sipf = ext.sip_files[0] needs_exceptions = 'true' if ext.needs_exceptions else 'false' with open(os.path.join(src_dir, 'pyproject.toml'), 'w') as f: @@ -504,6 +508,7 @@ def create_sip_build_skeleton(self, src_dir, ext): [tool.sip.project] sip-files-dir = "." +{abi_version} [tool.sip.bindings.pictureflow] headers = {ext.headers} diff --git a/setup/build_environment.py b/setup/build_environment.py index 41dccb1021ff..d40842e2cdfd 100644 --- a/setup/build_environment.py +++ b/setup/build_environment.py @@ -7,12 +7,26 @@ __docformat__ = 'restructuredtext en' import os, subprocess, re, shutil +from functools import lru_cache from setup import ismacos, iswindows, is64bit, islinux, ishaiku NMAKE = RC = msvc = MT = win_inc = win_lib = win_cc = win_ld = None +@lru_cache(maxsize=2) +def pyqt_sip_abi_version(): + import PyQt5 + if getattr(PyQt5, '__file__', None): + bindings_path = os.path.join(os.path.dirname(PyQt5.__file__), 'bindings', 'QtCore', 'QtCore.toml') + if os.path.exists(bindings_path): + with open(bindings_path) as f: + raw = f.read() + m = re.search(r'^sip-abi-version\s*=\s*"(.+?)"', raw, flags=re.MULTILINE) + if m is not None: + return m.group(1) + + def merge_paths(a, b): a = [os.path.normcase(os.path.normpath(x)) for x in a.split(os.pathsep)] for q in b.split(os.pathsep):