[PyKDE] [PATCH] sipdistuils: allow .sip in depends

Giovanni Bajo rasky at develer.com
Tue Dec 19 14:20:21 GMT 2006


Hello Phil,

when working on a module made of several .sip files (with a main .sip file
with %Module, and others included through %Include), there is currently no
way to tell distutils that it needs to re-run sip whenever an %Included .sip
file changes.

With this patch, it's now possible to list the %Included .sip files in the
"depends" argument of the setup() call, and distutils will take care of
calling sip.exe when necessary.

Thanks!
-- 
Giovanni Bajo
-------------- next part --------------
Index: sipdistutils.py
===================================================================
--- sipdistutils.py	(revision 9595)
+++ sipdistutils.py	(revision 9597)
@@ -5,7 +5,7 @@
 # Based on Pyrex.Distutils, written by Graham Fawcett and Darrel Gallion.
 
 import distutils.command.build_ext
-from distutils.dep_util import newer
+from distutils.dep_util import newer, newer_group
 import os
 import sys
 
@@ -48,10 +48,18 @@
         # Add the SIP include directory to the include path
         if extension is not None:
             extension.include_dirs.append(self._sip_inc_dir())
+            depends = extension.depends
         else:
             # pre-2.4 compatibility
             self.include_dirs.append(self._sip_inc_dir())
+            depends = []  # ?
 
+        # Filter dependencies list: we are interested only in .sip files,
+        # since the main .sip files can only depend on additional .sip
+        # files. For instance, if a .h changes, there is no need to
+        # run sip again.
+        depends = [f for f in depends if os.path.splitext(f)[1] == ".sip"]
+
         # Create the temporary directory if it does not exist already
         if not os.path.isdir(self.build_temp):
             os.makedirs(self.build_temp)
@@ -67,8 +75,8 @@
         for sip in sip_sources:
             # Use the sbf file as dependency check
             sipbasename = os.path.basename(sip)
-            sbf = os.path.join(self.build_temp, replace_suffix(sipbasename, "sbf"))
-            if newer(sip, sbf) or self.force:
+            sbf = os.path.join(self.build_temp, replace_suffix(sipbasename, ".sbf"))
+            if newer_group([sip]+depends, sbf) or self.force:
                 self._sip_compile(sip_bin, sip, sbf)
             out = self._get_sip_output_list(sbf)
             generated_sources.extend(out)


More information about the PyQt mailing list