From a4df5cc67ba6ee82c629f286fddb4c23325a0319 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 14 Sep 2020 12:26:08 +0530 Subject: [PATCH] Dont use -b flag when calling sip Was inexplicably removed from SIP5 --- setup/build.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/setup/build.py b/setup/build.py index c17570caa7..ba818a65a7 100644 --- a/setup/build.py +++ b/setup/build.py @@ -5,7 +5,7 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import textwrap, os, shlex, subprocess, glob, shutil, re, sys, json +import textwrap, os, shlex, subprocess, glob, shutil, sys, json from collections import namedtuple from setup import Command, islinux, isbsd, isfreebsd, ismacos, ishaiku, SRC, iswindows, __version__ @@ -476,19 +476,28 @@ class Build(Command): sbf = self.j(src_dir, self.b(sipf)+'.sbf') cmd = None if self.newer(sbf, [sipf]+ext.headers): - cmd = [pyqt['sip_bin'], '-w', '-c', src_dir, '-b', sbf, '-I' + pyqt['pyqt_sip_dir']] + shlex.split(pyqt['sip_flags']) + [sipf] + shutil.rmtree(src_dir) + os.mkdir(src_dir) + cmd = [pyqt['sip_bin'], '-w', '-c', src_dir, '-I' + pyqt['pyqt_sip_dir']] + shlex.split(pyqt['sip_flags']) + [sipf] return cmd, sbf def get_sip_data(self, sbf): - with open(sbf, 'rb') as f: - raw = f.read().decode('utf-8') + if os.path.exists(sbf): + with open(sbf) as f: + return json.loads(f.read()) + src_dir = os.path.dirname(sbf) - def read(x): - ans = re.search(r'^%s\s*=\s*(.+)$' % x, raw, flags=re.M).group(1).strip() - if x != 'target': - ans = ans.split() - return ans - return {x:read(x) for x in ('target', 'sources', 'headers')} + def transform(x): + return x.replace(os.sep, '/') + + ans = { + 'target': os.path.basename(src_dir), + 'sources': list(map(transform, glob.glob(os.path.join(src_dir, '*.cpp')))), + 'headers': list(map(transform, glob.glob(os.path.join(src_dir, '*.h')))), + } + with open(sbf, 'w') as f: + f.write(json.dumps(ans)) + return ans def build_pyqt_extension(self, ext, dest, sbf): self.info(f'\n####### Building {ext.name} extension', '#'*7)