@@ -168,6 +168,7 @@ def _sip_sipfiles_dir(self):
168168 return os .path .join (sys .prefix , 'sip' , 'PyQt5' )
169169
170170 def _sip_compile (self , sip_bin , source , sbf ):
171+ pyi = os .path .join (self .build_lib , "PyQtAds" , "QtAds" , "ads.pyi" )
171172 cmd = [sip_bin ]
172173 if hasattr (self , 'sip_opts' ):
173174 cmd += self .sip_opts
@@ -180,11 +181,20 @@ def _sip_compile(self, sip_bin, source, sbf):
180181 "-I" , self .inc_dir ,
181182 "-c" , self ._sip_output_dir (),
182183 "-b" , sbf ,
184+ "-y" , pyi ,
183185 "-w" , "-o" ]
184186
185187 cmd += shlex .split (self .pyqt_sip_flags ) # use same SIP flags as for PyQt5
186188 cmd .append (source )
187189 self .spawn (cmd )
190+
191+ if os .path .exists (pyi ):
192+ with open (pyi ) as f :
193+ content = f .readlines ()
194+ with open (pyi , "w" ) as f :
195+ for line in content :
196+ if not line .startswith ("class ads" ):
197+ f .write (line )
188198
189199 def swig_sources (self , sources , extension = None ):
190200 if not self .extensions :
@@ -293,6 +303,17 @@ def get_moc_args(out_file, source):
293303 ext .sources .append (out_file )
294304
295305 sipdistutils .build_ext .build_extension (self , ext )
306+
307+ import inspect
308+ sys .path .append (os .path .join (self .build_lib , 'PyQtAds' , 'QtAds' ))
309+ import ads
310+
311+ with open (os .path .join (self .build_lib , 'PyQtAds' , 'QtAds' , '__init__.py' ), 'w' ) as f :
312+ f .write ('from .._version import *\n ' )
313+ f .write ('from .ads import ads\n ' )
314+ for name , member in sorted (inspect .getmembers (ads .ads )):
315+ if not name .startswith ('_' ):
316+ f .write ('{0} = ads.{0}\n ' .format (name ))
296317
297318
298319class ProcessResourceCommand (cmd .Command ):
0 commit comments