This commit is contained in:
Uwe Kindler 2020-07-03 22:22:52 +02:00
commit 0d242297ff

View File

@ -168,6 +168,7 @@ class build_ext(sipdistutils.build_ext):
return os.path.join(sys.prefix, 'sip', 'PyQt5')
def _sip_compile(self, sip_bin, source, sbf):
pyi = os.path.join(self.build_lib, "PyQtAds", "QtAds", "ads.pyi")
cmd = [sip_bin]
if hasattr(self, 'sip_opts'):
cmd += self.sip_opts
@ -180,12 +181,21 @@ class build_ext(sipdistutils.build_ext):
"-I", self.inc_dir,
"-c", self._sip_output_dir(),
"-b", sbf,
"-y", pyi,
"-w", "-o"]
cmd += shlex.split(self.pyqt_sip_flags) # use same SIP flags as for PyQt5
cmd.append(source)
self.spawn(cmd)
if os.path.exists(pyi):
with open(pyi) as f:
content = f.readlines()
with open(pyi, "w") as f:
for line in content:
if not line.startswith("class ads"):
f.write(line)
def swig_sources (self, sources, extension=None):
if not self.extensions:
return
@ -294,6 +304,17 @@ class build_ext(sipdistutils.build_ext):
sipdistutils.build_ext.build_extension(self, ext)
import inspect
sys.path.append(os.path.join(self.build_lib, 'PyQtAds', 'QtAds'))
import ads
with open(os.path.join(self.build_lib, 'PyQtAds', 'QtAds', '__init__.py'), 'w') as f:
f.write('from .._version import *\n')
f.write('from .ads import ads\n')
for name, member in sorted(inspect.getmembers(ads.ads)):
if not name.startswith('_'):
f.write('{0} = ads.{0}\n'.format(name))
class ProcessResourceCommand(cmd.Command):
"""A custom command to compile the resource file into a Python file"""