Add ability to generate code into a .py file which does the import of the extension module. This will be used to add Python code to a module so we dont' have to do everything in C++.

git-svn-id: https://svn.wxwidgets.org/svn/wx/sandbox/trunk/Phoenix@66126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2010-11-12 22:19:32 +00:00
parent 8ffaf69b50
commit 7ddbef68b5
3 changed files with 21 additions and 4 deletions

View File

@@ -36,9 +36,10 @@ class Configuration(object):
SIPFILES = 'sip' # where to find other sip files for %Include or %Import
SIPOUT = 'sip/cpp' # where to put the generated C++ code
SIPOPTS = ' '.join(['-e', # turn on exceptions support
'-k', # turn on keyword args support
SIPOPTS = ' '.join(['-k', # turn on keyword args support
'-o', # turn on auto-docstrings
'-e', # turn on exceptions support
'-T', # turn off writing the timestamp to the generated files
#'-g', # always release and reaquire the GIL
#'-r', # turn on function call tracing
'-I', 'src'

View File

@@ -367,9 +367,25 @@ class etgsip_build_ext(build_ext):
# cmd.append('--verbose')
self.spawn(cmd)
if '%Module ' in file(sipfile).read():
if '%Module(' in file(sipfile).read():
other_sources.append(sipfile)
# now call the base class version of this method
return build_ext.swig_sources(self, other_sources, extension)
def _sip_compile(self, sip_bin, source, sbf):
other_opts = []
base = os.path.basename(source)
if base.startswith('_'):
cfg = Config()
pycode = os.path.splitext(base[1:])[0] + '.py'
pycode = os.path.join(cfg.PKGDIR, pycode)
other_opts = ['-X', 'pycode:'+pycode]
self.spawn([sip_bin] + self.sip_opts +
other_opts +
["-c", self._sip_output_dir(),
"-b", sbf,
"-I", self._sip_sipfiles_dir(),
source])