[master 1/1] Make distutils.filelist.findall() do the right thing with symlinks maybe.

vathpela installerbot-noreply at redhat.com
Tue Oct 13 15:24:05 UTC 2015


From: Peter Jones <pjones at redhat.com>

I'm not sure this would be right if we actually wanted to /include/ the
symlink itself, but since so far they're all in directories we don't
include in the tarball, this will at least make the traversal of them
not fail.

Signed-off-by: Peter Jones <pjones at redhat.com>
---
 setup.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/setup.py b/setup.py
index 35a300d..7966e18 100644
--- a/setup.py
+++ b/setup.py
@@ -2,12 +2,42 @@
 # pylint: disable=interruptible-system-call
 
 from distutils.core import setup
+from distutils import filelist
 import subprocess
 import sys
 import glob
 import os
 import re
 
+def findall(dir = os.curdir):
+    from stat import ST_MODE, S_ISREG, S_ISDIR, S_ISLNK
+
+    list = []
+    stack = [dir]
+    pop = stack.pop
+    push = stack.append
+
+    while stack:
+        dir = pop()
+        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
+
+            stat = os.lstat(fullname)
+            mode = stat[ST_MODE]
+            if S_ISREG(mode):
+                list.append(fullname)
+            elif S_ISDIR(mode) and not S_ISLNK(mode):
+                push(fullname)
+
+    return list
+
+filelist.findall = findall
+
 AM_RE = r'(^.. automodule::.+?(?P<mo>^\s+?:member-order:.+?\n)?.+?:\n)\n(?(mo)NEVER)'
 
 def generate_api_docs():


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/20787742b34ae9fd69c8d3f8cf6ce68e8425d2f3


More information about the anaconda-patches mailing list