mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 21:25:44 +08:00
Generate Python stubs file for linters (#214)
* Generate Python stubs file for linters * Sort members of ads namespace in generated __init__.py
This commit is contained in:
parent
281127c2c3
commit
6d0f14e1a5
21
setup.py
21
setup.py
@ -168,6 +168,7 @@ class build_ext(sipdistutils.build_ext):
|
|||||||
return os.path.join(sys.prefix, 'sip', 'PyQt5')
|
return os.path.join(sys.prefix, 'sip', 'PyQt5')
|
||||||
|
|
||||||
def _sip_compile(self, sip_bin, source, sbf):
|
def _sip_compile(self, sip_bin, source, sbf):
|
||||||
|
pyi = os.path.join(self.build_lib, "PyQtAds", "QtAds", "ads.pyi")
|
||||||
cmd = [sip_bin]
|
cmd = [sip_bin]
|
||||||
if hasattr(self, 'sip_opts'):
|
if hasattr(self, 'sip_opts'):
|
||||||
cmd += self.sip_opts
|
cmd += self.sip_opts
|
||||||
@ -180,12 +181,21 @@ class build_ext(sipdistutils.build_ext):
|
|||||||
"-I", self.inc_dir,
|
"-I", self.inc_dir,
|
||||||
"-c", self._sip_output_dir(),
|
"-c", self._sip_output_dir(),
|
||||||
"-b", sbf,
|
"-b", sbf,
|
||||||
|
"-y", pyi,
|
||||||
"-w", "-o"]
|
"-w", "-o"]
|
||||||
|
|
||||||
cmd += shlex.split(self.pyqt_sip_flags) # use same SIP flags as for PyQt5
|
cmd += shlex.split(self.pyqt_sip_flags) # use same SIP flags as for PyQt5
|
||||||
cmd.append(source)
|
cmd.append(source)
|
||||||
self.spawn(cmd)
|
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):
|
def swig_sources (self, sources, extension=None):
|
||||||
if not self.extensions:
|
if not self.extensions:
|
||||||
return
|
return
|
||||||
@ -294,6 +304,17 @@ class build_ext(sipdistutils.build_ext):
|
|||||||
|
|
||||||
sipdistutils.build_ext.build_extension(self, 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):
|
class ProcessResourceCommand(cmd.Command):
|
||||||
"""A custom command to compile the resource file into a Python file"""
|
"""A custom command to compile the resource file into a Python file"""
|
||||||
|
Loading…
Reference in New Issue
Block a user