support adding pxd/pxi dependencies to Extension sources and force rebuild on depende...
authorStefan Behnel <scoder@users.berlios.de>
Fri, 14 Mar 2008 09:34:53 +0000 (10:34 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 14 Mar 2008 09:34:53 +0000 (10:34 +0100)
Cython/Distutils/build_ext.py

index 3b828900593c049204bf47dd2405b6b5d9127472..89330f68a7d6b1b5077d0c9fce5c4309f102372b 100644 (file)
@@ -155,6 +155,7 @@ class build_ext(_build_ext.build_ext):
         else:
             target_dir = None
 
+        newest_dependency = None
         for source in sources:
             (base, ext) = os.path.splitext(os.path.basename(source))
             if ext == ".pyx":                    # Cython source file
@@ -162,6 +163,10 @@ class build_ext(_build_ext.build_ext):
                 new_sources.append(os.path.join(output_dir, base + target_ext))
                 pyrex_sources.append(source)
                 pyrex_targets[source] = new_sources[-1]
+            elif ext == '.pxi' or ext == '.pxd':
+                if newest_dependency is None \
+                        or newer(source, newest_dependency):
+                    newest_dependency = source
             else:
                 new_sources.append(source)
 
@@ -172,7 +177,10 @@ class build_ext(_build_ext.build_ext):
 
         for source in pyrex_sources:
             target = pyrex_targets[source]
-            if self.force or newer(source, target):
+            rebuild = self.force or newer(source, target)
+            if not rebuild and newest_dependency is not None:
+                rebuild = newer(newest_dependency, target)
+            if rebuild:
                 log.info("cythoning %s to %s", source, target)
                 self.mkpath(os.path.dirname(target))
                 options = CompilationOptions(pyrex_default_options,