def get_file_list(self): """Figure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options. """ # 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 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) self.filelist.findall() if self.use_defaults: self.add_defaults() if template_exists: self.read_template() if self.prune: self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() self.write_manifest() def read_manifest(self): """Read the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source 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) 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()