Filip Wasilewski avatar Filip Wasilewski committed 9dbdcd9

Added checks to sdist command.

Make sure that the generated .c files are in sync with .pyx files.

Comments (0)

Files changed (1)

 import sys
 from distutils.command.build_ext import build_ext as build_ext_distutils
 from distutils.command.sdist import sdist as sdist_distutils
+from distutils.errors import DistutilsClassError
 
 from util import templating
 
 
 
 class SdistCommand(sdist_distutils):
+
+    def initialize_options(self):
+        sdist_distutils.initialize_options(self)
+        self._pyx = []
+        for root, dirs, files in os.walk("src"):
+            for f in files:
+                if f.endswith(".pyx"):
+                    self._pyx.append(os.path.join(root, f))
+
     def run(self):
         self.force_manifest = 1
+        for pyx_file in self._pyx:
+            c_file = replace_extension(pyx_file, ".c")
+
+            if not os.path.exists(c_file):
+                raise DistutilsClassError(
+                    "C-source file '{0}' not found.".format(c_file))
+
+            if is_newer(pyx_file, c_file):
+                raise DistutilsClassError(
+                    "C-source file '{0}' seems out of date compared to '{1}'.".format(
+                        c_file, pyx_file))
+
         sdist_distutils.run(self)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.