aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/sdist.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2005-07-09 04:21:22 +0000
committerPJ Eby <distutils-sig@python.org>2005-07-09 04:21:22 +0000
commit72de8511ab1a6d622fc2bf8ee2c38440ba140ac3 (patch)
tree14f3845c8ffca2c91772afcbeb8ff3c7d87c7f02 /setuptools/command/sdist.py
parent82b1c266a8a07292eed2419b1177db78785b1ae4 (diff)
downloadexternal_python_setuptools-72de8511ab1a6d622fc2bf8ee2c38440ba140ac3.tar.gz
external_python_setuptools-72de8511ab1a6d622fc2bf8ee2c38440ba140ac3.tar.bz2
external_python_setuptools-72de8511ab1a6d622fc2bf8ee2c38440ba140ac3.zip
Include ``svn:externals`` directories in source distributions as well as
normal subversion-controlled files and directories. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041101
Diffstat (limited to 'setuptools/command/sdist.py')
-rwxr-xr-xsetuptools/command/sdist.py84
1 files changed, 42 insertions, 42 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py
index 673255bb..425ed8ba 100755
--- a/setuptools/command/sdist.py
+++ b/setuptools/command/sdist.py
@@ -6,15 +6,23 @@ entities = [
("&lt;","<"), ("&gt;", ">"), ("&quot;", '"'), ("&apos;", "'"),
("&amp;", "&")
]
+
def unescape(data):
for old,new in entities:
data = data.replace(old,new)
return data
-patterns = [
- (convert_path('CVS/Entries'), re.compile(r"^\w?/([^/]+)/", re.M), None),
- (convert_path('.svn/entries'), re.compile(r'name="([^"]+)"'), unescape),
-]
+def re_finder(pattern, postproc=None):
+ def find(dirname, filename):
+ f = open(filename,'rU')
+ data = f.read()
+ f.close()
+ for match in pattern.finditer(data):
+ path = match.group(1)
+ if postproc:
+ path = postproc(path)
+ yield joinpath(dirname,path)
+ return find
def joinpath(prefix,suffix):
if not prefix:
@@ -31,14 +39,6 @@ def joinpath(prefix,suffix):
-
-
-
-
-
-
-
-
def walk_revctrl(dirname='', memo=None):
"""Find all files under revision control"""
if memo is None:
@@ -46,38 +46,47 @@ def walk_revctrl(dirname='', memo=None):
if dirname in memo:
# Don't rescan a scanned directory
return
- for path, pattern, postproc in patterns:
+ for path, finder in finders:
path = joinpath(dirname,path)
if os.path.isfile(path):
- f = open(path,'rU')
- data = f.read()
- f.close()
- for match in pattern.finditer(data):
- path = match.group(1)
- if postproc:
- path = postproc(path)
- path = joinpath(dirname,path)
+ for path in finder(dirname,path):
if os.path.isfile(path):
yield path
elif os.path.isdir(path):
for item in walk_revctrl(path, memo):
yield item
+def externals_finder(dirname, filename):
+ """Find any 'svn:externals' directories"""
+ found = False
+ f = open(filename,'rb')
+ for line in iter(f.readline, ''): # can't use direct iter!
+ parts = line.split()
+ if len(parts)==2:
+ kind,length = parts
+ data = f.read(int(length))
+ if kind=='K' and data=='svn:externals':
+ found = True
+ elif kind=='V' and found:
+ f.close()
+ break
+ else:
+ f.close()
+ return
+ for line in data.splitlines():
+ parts = line.split()
+ if parts:
+ yield joinpath(dirname, parts[0])
-
-
-
-
-
-
-
-
-
-
-
-
+finders = [
+ (convert_path('CVS/Entries'),
+ re_finder(re.compile(r"^\w?/([^/]+)/", re.M))),
+ (convert_path('.svn/entries'),
+ re_finder(re.compile(r'name="([^"]+)"'), unescape)),
+ (convert_path('.svn/dir-props'), externals_finder),
+]
class sdist(_sdist):
@@ -112,12 +121,3 @@ class sdist(_sdist):
-
-
-
-
-
-
-
-
-