Index: sdist.py =================================================================== --- sdist.py (revision 88286) +++ sdist.py (working copy) @@ -6,6 +6,7 @@ import os import string +import re import sys from glob import glob from warnings import warn @@ -182,18 +183,24 @@ reading the manifest, or just using the default file set -- it all depends on the user's options. """ - # new behavior: + # new behavior when using a template: # the file list is recalculated everytime because # even if MANIFEST.in or setup.py are not changed # the user might have added some files in the tree that # need to be included. # - # This makes --force the default and only behavior. + # This makes --force the default and only behavior with templates template_exists = os.path.isfile(self.template) + manifest_exists = os.path.isfile(self.manifest) + if not template_exists and manifest_exists: + self.read_manifest() + return + if not template_exists: self.warn(("manifest template '%s' does not exist " + - "(using default file list)") % - self.template) + "(using default file list)") % + self.template) + self.filelist.findall() if self.use_defaults: @@ -372,13 +379,18 @@ distribution. """ log.info("reading manifest file '%s'", self.manifest) + + # regular expression to match from # comment char to end of line + comment_regexp = re.compile('#.*') + manifest = open(self.manifest) - while 1: - line = manifest.readline() - if line == '': # end of file - break - if line[-1] == '\n': - line = line[0:-1] + for line in manifest.readlines(): + # kill comments, will leave some whitespace + line = comment_regexp.sub('', line) + # trim leading/trailing whitespace, but preserve embedded whitespace + line = line.strip() + # skip lines without any non-whitespace character remaining + if len(line) == 0: continue self.filelist.append(line) manifest.close()