def get_source_files(self): source_list = filelist.FileList() source_list.set_allfiles(self.get_allfiles()) # Add the files used to create the Distribution source_list.append(self.script_name) if os.path.exists('setup.cfg'): source_list.append('setup.cfg') if self.package_file: source_list.append(self.package_file) # Get the source files from the command groupds for cmd_name in ('generate', 'build', 'install'): cmd = self.get_command_obj(cmd_name) cmd.ensure_finalized() source_list.extend(cmd.get_source_files()) # 'license_file' is used by bdist_inno if self.license_file: source_list.append(self.license_file) # Add the files not included by the commands for line in self.manifest_templates: try: source_list.process_template_line(line) except DistutilsTemplateError, msg: self.warn(str(msg))
def get_allfiles(self): if self._allfiles is None: # If a "main" distribution exists, use its files to prevent # unnecessary additional searches. if self.main_distribution: self._allfiles = self.main_distribution.get_allfiles() else: source_list = filelist.FileList() source_list.extend(filelist.findall()) # Remove files that don't really belong in the file list. # Note the leading slash (\) before os.sep substitutions. It is # needed to prevent regex-escaping when os.sep is '\' (Windows). exclude_patterns = ( # revision control (CVS client) files r'\%s?CVS(\.sandboxinfo)?\%s' % (os.sep, os.sep), r'\.cvsignore$', r'\.#[^\%s]+$' % os.sep, # (X)Emacs temporary files r'\.?#[^\%s]+#$' % os.sep, # common editor backup files r'[^\%s]+~$' % os.sep, # python bytecode files r'\.py[co]$', ) for pattern in exclude_patterns: source_list.exclude_pattern(pattern, is_regex=True) self._allfiles = source_list.files return self._allfiles
def check_distribution(self): # Start out with all files included allfiles = filelist.FileList() allfiles.set_allfiles([]) allfiles.extend(self.distribution.get_allfiles()) # Prune the same files as the distribution filelist self.prune_file_list(allfiles) # Exclude files included by other sub-packages validate_distributions = [self.distribution] if self.distribution.main_distribution: main_distribution = self.distribution.main_distribution validate_distributions.append(main_distribution) for name in main_distribution.package_options: dist = main_distribution.get_package_distribution(name) if dist is not self.distribution: # Remove the other sub-package source files for filename in dist.get_source_files(): filename = util.convert_path(filename) allfiles.exclude_pattern(filename) validate_distributions.append(dist) # Process the ignorable files for all available distributions for distribution in validate_distributions: for line in distribution.validate_templates: try: allfiles.process_template_line(line) except DistutilsTemplateError, msg: self.warn('in %s: %s' % (dist.package_file, msg))
def get_file_list(self): """Create list of files to include in the source distribution Create 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. """ self.filelist = filelist.FileList() self.filelist.files = manifest.DIST_FILES self.filelist.sort() self.filelist.remove_duplicates() self.write_manifest()
def from_templates(cls, *templates, **kwargs): """ Initialize from template """ files = _filelist.FileList() for tpl in templates: for line in tpl.split(';'): files.process_template_line(line.strip()) files.sort() files.remove_duplicates() result = [] for filename in files.files: _, elems = splitpath(filename) if '.svn' in elems or '.git' in elems: continue result.append(filename) return cls(result, **kwargs)
def collect(top_dir, includes=INCLUDES, excludes=EXCLUDES): old_dir = os.getcwd() os.chdir(top_dir) try: fl = filelist.FileList() fl.findall() for inc in includes: fl.include_pattern(inc, is_regex=1) for exc in excludes: fl.exclude_pattern(exc, is_regex=1) return fl.files finally: os.chdir(old_dir)
from distutils.core import setup from distutils.core import Extension pack_name = 'rpy2' pack_version = __import__('rpy').__version__ package_prefix = '.' if sys.version_info >= (3, ): print( "Using 2to3 to translate Python2-only idioms into Python3 code. Please wait..." ) # Python 3 and we need to translate code package_prefix = os.path.join('build', 'python3_rpy') from distutils import filelist, dir_util, file_util, util #, log #log.set_verbosity(1) fl = filelist.FileList() tmp = open("MANIFEST.in") for line in tmp: line = line.rstrip() if line != '': fl.process_template_line(line) tmp.close() dir_util.create_tree(package_prefix, fl.files) outfiles_2to3 = [] #dist_script = os.path.join("build", "src", "distribute_setup.py") for f in fl.files: outf, copied = file_util.copy_file(f, os.path.join(package_prefix, f), update=1) if copied and outf.endswith(".py"): #and outf != dist_script: outfiles_2to3.append(outf)