Skip to content
Browse files
Beefed up the "sdist" command so that if you don't have a…
…, 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

branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041087
  • Loading branch information
PJ Eby committed Jul 7, 2005
1 parent 8e7eabf commit d3add44007ad72fc795297dd208d9a37ac4b54a3
Showing with 85 additions and 3 deletions.
  1. +1 −1 setuptools/command/
  2. +82 −0 setuptools/command/
  3. +2 −2 setuptools/
@@ -354,7 +354,7 @@ def install_script(self, dist, script_name, script_text, dev_path=None):
"# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r\n"
"import pkg_resources\n"
"pkg_resources.run_main(%(spec)r, %(script_name)r)\n"
"pkg_resources.run_script(%(spec)r, %(script_name)r)\n"
) % locals()

if not self.dry_run:
@@ -0,0 +1,82 @@
from distutils.command.sdist import sdist as _sdist
from distutils.util import convert_path
import os,re

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 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
for path, pattern, postproc in patterns:
path = joinpath(dirname,path)
if os.path.isfile(path):
f = open(path,'rU')
data =
for match in pattern.finditer(data):
path =
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):
if not os.path.isfile(self.template):
self.force_manifest = 1 # always regen if no template

def add_defaults(self):

@@ -5,6 +5,7 @@
from setuptools.depends import Require
from setuptools.command.build_ext import build_ext
from setuptools.command.install import install
from setuptools.command.sdist import sdist
from setuptools.command.install_lib import install_lib
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.errors import DistutilsSetupError
@@ -79,7 +80,6 @@ class Distribution(_Distribution):
distribution for the included and excluded features.

def __init__ (self, attrs=None):
have_package_data = hasattr(self, "package_data")
if not have_package_data:
@@ -98,7 +98,7 @@ def __init__ (self, attrs=None):


0 comments on commit d3add44

Please sign in to comment.