]> scripts.mit.edu Git - wizard.git/commitdiff
Monkeypatch egg_info not to do stupid things.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 4 Sep 2011 21:08:20 +0000 (17:08 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 4 Sep 2011 21:08:20 +0000 (17:08 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
setup.py

index 072c9b39aa0db24da28bdebf52e0f96f2e3e37f6..da739b3662fc056fafba42686e75928f33a24756 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,46 @@
 import setuptools
 
+# MONKEYPATCH: Stop egg_info from stupidly traversing the entire
+# development directory.
+import setuptools.command.egg_info
+import os
+class FileList(setuptools.command.egg_info.FileList):
+    def findall(self, dir=os.curdir):
+        """Find all files under 'dir' and return the list of full filenames
+        (relative to 'dir').
+        """
+        from stat import ST_MODE, S_ISREG, S_ISDIR, S_ISLNK
+
+        list = []
+        stack = [dir]
+        pop = stack.pop
+        push = stack.append
+
+        while stack:
+            dir = pop()
+            # BEGIN MODIFICATION
+            if dir in ("tests", "srv", ".git"):
+                continue
+            # END MODIFICATION
+            names = os.listdir(dir)
+
+            for name in names:
+                if dir != os.curdir:        # avoid the dreaded "./" syndrome
+                    fullname = os.path.join(dir, name)
+                else:
+                    fullname = name
+
+                # Avoid excess stat calls -- just one will do, thank you!
+                stat = os.stat(fullname)
+                mode = stat[ST_MODE]
+                if S_ISREG(mode):
+                    list.append(fullname)
+                elif S_ISDIR(mode) and not S_ISLNK(mode):
+                    push(fullname)
+        self.allfiles = list
+setuptools.command.egg_info.FileList = FileList
+# END MONKEYPATCH
+
 setuptools.setup(
     name = 'wizard',
     version = '0.1.dev',