home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / python2.5 / site-packages / sipdistutils.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-04-29  |  3.1 KB  |  81 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. import distutils.command.build_ext as distutils
  5. from distutils.dep_util import newer
  6. import os
  7. import sys
  8.  
  9. def replace_suffix(path, new_suffix):
  10.     return os.path.splitext(path)[0] + new_suffix
  11.  
  12.  
  13. class build_ext(distutils.command.build_ext.build_ext):
  14.     description = 'Compiler SIP descriptions, then build C/C++ extensions (compile/link to build directory)'
  15.     
  16.     def _get_sip_output_list(self, sbf):
  17.         '''
  18.         Parse the sbf file specified to extract the name of the generated source
  19.         files. Make them absolute assuming they reside in the temp directory.
  20.         '''
  21.         for L in file(sbf):
  22.             (key, value) = L.split('=', 1)
  23.             if key.strip() == 'sources':
  24.                 out = []
  25.                 for o in value.split():
  26.                     out.append(os.path.join(self.build_temp, o))
  27.                 
  28.                 return out
  29.                 continue
  30.         
  31.         raise RuntimeError, "cannot parse SIP-generated '%s'" % sbf
  32.  
  33.     
  34.     def _find_sip(self):
  35.         import sipconfig
  36.         cfg = sipconfig.Configuration()
  37.         return cfg.sip_bin
  38.  
  39.     
  40.     def _sip_inc_dir(self):
  41.         import sipconfig
  42.         cfg = sipconfig.Configuration()
  43.         return cfg.sip_inc_dir
  44.  
  45.     
  46.     def swig_sources(self, sources, extension = None):
  47.         if not self.extensions:
  48.             return None
  49.         
  50.         if extension is not None:
  51.             extension.include_dirs.append(self._sip_inc_dir())
  52.         else:
  53.             self.include_dirs.append(self._sip_inc_dir())
  54.         if not os.path.isdir(self.build_temp):
  55.             os.makedirs(self.build_temp)
  56.         
  57.         sip_sources = []
  58.         sip_sources = _[1]
  59.         other_sources = _[2]
  60.         generated_sources = []
  61.         sip_bin = self._find_sip()
  62.         for sip in sip_sources:
  63.             sipbasename = os.path.basename(sip)
  64.             sbf = os.path.join(self.build_temp, replace_suffix(sipbasename, 'sbf'))
  65.             out = self._get_sip_output_list(sbf)
  66.             generated_sources.extend(out)
  67.         
  68.         return generated_sources + other_sources
  69.  
  70.     
  71.     def _sip_compile(self, sip_bin, source, sbf):
  72.         self.spawn([
  73.             sip_bin,
  74.             '-c',
  75.             self.build_temp,
  76.             '-b',
  77.             sbf,
  78.             source])
  79.  
  80.  
  81.