@@ -168,6 +168,7 @@ def _sip_sipfiles_dir(self):
168
168
return os .path .join (sys .prefix , 'sip' , 'PyQt5' )
169
169
170
170
def _sip_compile (self , sip_bin , source , sbf ):
171
+ pyi = os .path .join (self .build_lib , "PyQtAds" , "QtAds" , "ads.pyi" )
171
172
cmd = [sip_bin ]
172
173
if hasattr (self , 'sip_opts' ):
173
174
cmd += self .sip_opts
@@ -180,11 +181,20 @@ def _sip_compile(self, sip_bin, source, sbf):
180
181
"-I" , self .inc_dir ,
181
182
"-c" , self ._sip_output_dir (),
182
183
"-b" , sbf ,
184
+ "-y" , pyi ,
183
185
"-w" , "-o" ]
184
186
185
187
cmd += shlex .split (self .pyqt_sip_flags ) # use same SIP flags as for PyQt5
186
188
cmd .append (source )
187
189
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 )
188
198
189
199
def swig_sources (self , sources , extension = None ):
190
200
if not self .extensions :
@@ -293,6 +303,17 @@ def get_moc_args(out_file, source):
293
303
ext .sources .append (out_file )
294
304
295
305
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 ))
296
317
297
318
298
319
class ProcessResourceCommand (cmd .Command ):
0 commit comments