diff options
author | PJ Eby <distutils-sig@python.org> | 2005-07-07 02:03:25 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-07-07 02:03:25 +0000 |
commit | d3add44007ad72fc795297dd208d9a37ac4b54a3 (patch) | |
tree | 5e431089b0458c8124904e4c7d94a5f551668536 /setuptools/command/sdist.py | |
parent | 8e7eabf110643907fd1f1979d0674cf615268124 (diff) | |
download | external_python_setuptools-d3add44007ad72fc795297dd208d9a37ac4b54a3.tar.gz external_python_setuptools-d3add44007ad72fc795297dd208d9a37ac4b54a3.tar.bz2 external_python_setuptools-d3add44007ad72fc795297dd208d9a37ac4b54a3.zip |
Beefed up the "sdist" command so that if you don't have a MANIFEST.in, it
will include all files under revision control (CVS or Subversion) in the
current directory, and it will regenerate the list every time you create a
source distribution, not just when you tell it to. This should make the
default "do what you mean" more often than the distutils' default behavior
did, while still retaining the old behavior in the presence of MANIFEST.in.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041087
Diffstat (limited to 'setuptools/command/sdist.py')
-rwxr-xr-x | setuptools/command/sdist.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py new file mode 100755 index 00000000..b39df36f --- /dev/null +++ b/setuptools/command/sdist.py @@ -0,0 +1,82 @@ +from distutils.command.sdist import sdist as _sdist +from distutils.util import convert_path +import os,re + +entities = [ + ("<","<"), (">", ">"), (""", '"'), ("'", "'"), + ("&", "&") +] +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 joinpath(prefix,suffix): + if not prefix: + return suffix + return os.path.join(prefix,suffix) + + + + + + + + + + + + + + + + + + + +def walk_revctrl(dirname='', memo=None): + """Find all files under revision control""" + if memo is None: + memo = {} + if dirname in memo: + # Don't rescan a scanned directory + return + for path, pattern, postproc in patterns: + 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) + if os.path.isfile(path): + yield path + elif os.path.isdir(path): + for item in walk_revctrl(path, memo): + yield item + +class sdist(_sdist): + """Smart sdist that finds anything supported by revision control""" + def finalize_options(self): + _sdist.finalize_options(self) + if not os.path.isfile(self.template): + self.force_manifest = 1 # always regen if no template + + def add_defaults(self): + _sdist.add_defaults(self) + self.filelist.extend(walk_revctrl()) + + + + + + + |