Current Path: > > opt > alt > python27 > lib64 > python2.7 > > distutils > command
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
__init__.py | File | 822 bytes | January 08 2025 10:43:30. | |
__init__.pyc | File | 678 bytes | January 08 2025 10:43:30. | |
__init__.pyo | File | 678 bytes | January 08 2025 10:43:30. | |
bdist.py | File | 5596 bytes | January 08 2025 10:43:30. | |
bdist.pyc | File | 5247 bytes | January 08 2025 10:43:30. | |
bdist.pyo | File | 5247 bytes | January 08 2025 10:43:30. | |
bdist_dumb.py | File | 5196 bytes | January 08 2025 10:43:30. | |
bdist_dumb.pyc | File | 5048 bytes | January 08 2025 10:43:30. | |
bdist_dumb.pyo | File | 5048 bytes | January 08 2025 10:43:30. | |
bdist_msi.py | File | 35193 bytes | January 08 2025 10:43:30. | |
bdist_msi.pyc | File | 24182 bytes | January 08 2025 10:43:29. | |
bdist_msi.pyo | File | 24075 bytes | January 08 2025 10:43:30. | |
bdist_rpm.py | File | 21049 bytes | January 08 2025 10:43:30. | |
bdist_rpm.pyc | File | 17725 bytes | January 08 2025 10:43:29. | |
bdist_rpm.pyo | File | 17641 bytes | January 08 2025 10:43:30. | |
bdist_wininst.py | File | 14999 bytes | January 08 2025 10:43:30. | |
bdist_wininst.pyc | File | 10855 bytes | January 08 2025 10:43:30. | |
bdist_wininst.pyo | File | 10776 bytes | January 08 2025 10:43:30. | |
build.py | File | 5456 bytes | January 08 2025 10:43:30. | |
build.pyc | File | 5276 bytes | January 08 2025 10:43:30. | |
build.pyo | File | 5276 bytes | January 08 2025 10:43:30. | |
build_clib.py | File | 8131 bytes | January 08 2025 10:43:29. | |
build_clib.pyc | File | 6477 bytes | January 08 2025 10:43:30. | |
build_clib.pyo | File | 6477 bytes | January 08 2025 10:43:30. | |
build_ext.py | File | 32502 bytes | January 08 2025 10:43:29. | |
build_ext.py.debug-build | File | 32270 bytes | January 08 2025 10:43:30. | |
build_ext.pyc | File | 19591 bytes | January 08 2025 10:43:30. | |
build_ext.pyo | File | 19591 bytes | January 08 2025 10:43:30. | |
build_py.py | File | 16338 bytes | January 08 2025 10:43:30. | |
build_py.pyc | File | 11766 bytes | January 08 2025 10:43:29. | |
build_py.pyo | File | 11694 bytes | January 08 2025 10:43:30. | |
build_scripts.py | File | 4598 bytes | January 08 2025 10:43:29. | |
build_scripts.pyc | File | 4568 bytes | January 08 2025 10:43:30. | |
build_scripts.pyo | File | 4568 bytes | January 08 2025 10:43:30. | |
check.py | File | 5672 bytes | January 08 2025 10:43:30. | |
check.pyc | File | 6418 bytes | January 08 2025 10:43:30. | |
check.pyo | File | 6418 bytes | January 08 2025 10:43:30. | |
clean.py | File | 2814 bytes | January 08 2025 10:43:30. | |
clean.pyc | File | 3134 bytes | January 08 2025 10:43:30. | |
clean.pyo | File | 3134 bytes | January 08 2025 10:43:30. | |
command_template | File | 719 bytes | January 08 2025 10:43:30. | |
config.py | File | 13130 bytes | January 08 2025 10:43:30. | |
config.pyc | File | 12945 bytes | January 08 2025 10:43:29. | |
config.pyo | File | 12945 bytes | January 08 2025 10:43:29. | |
install.py | File | 26264 bytes | January 08 2025 10:43:30. | |
install.pyc | File | 17130 bytes | January 08 2025 10:43:30. | |
install.pyo | File | 17130 bytes | January 08 2025 10:43:30. | |
install_data.py | File | 2845 bytes | January 08 2025 10:43:30. | |
install_data.pyc | File | 3209 bytes | January 08 2025 10:43:29. | |
install_data.pyo | File | 3209 bytes | January 08 2025 10:43:29. | |
install_egg_info.py | File | 2587 bytes | January 08 2025 10:43:30. | |
install_egg_info.pyc | File | 3861 bytes | January 08 2025 10:43:30. | |
install_egg_info.pyo | File | 3861 bytes | January 08 2025 10:43:30. | |
install_headers.py | File | 1346 bytes | January 08 2025 10:43:30. | |
install_headers.pyc | File | 2346 bytes | January 08 2025 10:43:30. | |
install_headers.pyo | File | 2346 bytes | January 08 2025 10:43:30. | |
install_lib.py | File | 8338 bytes | January 08 2025 10:43:30. | |
install_lib.pyc | File | 6837 bytes | January 08 2025 10:43:30. | |
install_lib.pyo | File | 6837 bytes | January 08 2025 10:43:30. | |
install_scripts.py | File | 2068 bytes | January 08 2025 10:43:29. | |
install_scripts.pyc | File | 3019 bytes | January 08 2025 10:43:29. | |
install_scripts.pyo | File | 3019 bytes | January 08 2025 10:43:29. | |
register.py | File | 11839 bytes | January 08 2025 10:43:30. | |
register.pyc | File | 10377 bytes | January 08 2025 10:43:30. | |
register.pyo | File | 10377 bytes | January 08 2025 10:43:30. | |
sdist.py | File | 18557 bytes | January 08 2025 10:43:30. | |
sdist.pyc | File | 16930 bytes | January 08 2025 10:43:30. | |
sdist.pyo | File | 16930 bytes | January 08 2025 10:43:30. | |
upload.py | File | 7000 bytes | January 08 2025 10:43:30. | |
upload.pyc | File | 6386 bytes | January 08 2025 10:43:30. | |
upload.pyo | File | 6386 bytes | January 08 2025 10:43:30. | |
wininst-6.0.exe | File | 61440 bytes | January 08 2025 10:43:29. | |
wininst-7.1.exe | File | 65536 bytes | January 08 2025 10:43:30. | |
wininst-8.0.exe | File | 61440 bytes | January 08 2025 10:43:30. | |
wininst-9.0-amd64.exe | File | 223744 bytes | January 08 2025 10:43:29. | |
wininst-9.0.exe | File | 196096 bytes | January 08 2025 10:43:30. |
"""distutils.command.sdist Implements the Distutils 'sdist' command (create a source distribution).""" __revision__ = "$Id$" import os import string import sys from glob import glob from warnings import warn from distutils.core import Command from distutils import dir_util, dep_util, file_util, archive_util from distutils.text_file import TextFile from distutils.errors import (DistutilsPlatformError, DistutilsOptionError, DistutilsTemplateError) from distutils.filelist import FileList from distutils import log from distutils.util import convert_path def show_formats(): """Print all possible values for the 'formats' option (used by the "--help-formats" command-line option). """ from distutils.fancy_getopt import FancyGetopt from distutils.archive_util import ARCHIVE_FORMATS formats = [] for format in ARCHIVE_FORMATS.keys(): formats.append(("formats=" + format, None, ARCHIVE_FORMATS[format][2])) formats.sort() FancyGetopt(formats).print_help( "List of available source distribution formats:") class sdist(Command): description = "create a source distribution (tarball, zip file, etc.)" def checking_metadata(self): """Callable used for the check sub-command. Placed here so user_options can view it""" return self.metadata_check user_options = [ ('template=', 't', "name of manifest template file [default: MANIFEST.in]"), ('manifest=', 'm', "name of manifest file [default: MANIFEST]"), ('use-defaults', None, "include the default file set in the manifest " "[default; disable with --no-defaults]"), ('no-defaults', None, "don't include the default file set"), ('prune', None, "specifically exclude files/directories that should not be " "distributed (build tree, RCS/CVS dirs, etc.) " "[default; disable with --no-prune]"), ('no-prune', None, "don't automatically exclude anything"), ('manifest-only', 'o', "just regenerate the manifest and then stop " "(implies --force-manifest)"), ('force-manifest', 'f', "forcibly regenerate the manifest and carry on as usual. " "Deprecated: now the manifest is always regenerated."), ('formats=', None, "formats for source distribution (comma-separated list)"), ('keep-temp', 'k', "keep the distribution tree around after creating " + "archive file(s)"), ('dist-dir=', 'd', "directory to put the source distribution archive(s) in " "[default: dist]"), ('metadata-check', None, "Ensure that all required elements of meta-data " "are supplied. Warn if any missing. [default]"), ('owner=', 'u', "Owner name used when creating a tar file [default: current user]"), ('group=', 'g', "Group name used when creating a tar file [default: current group]"), ] boolean_options = ['use-defaults', 'prune', 'manifest-only', 'force-manifest', 'keep-temp', 'metadata-check'] help_options = [ ('help-formats', None, "list available distribution formats", show_formats), ] negative_opt = {'no-defaults': 'use-defaults', 'no-prune': 'prune' } default_format = {'posix': 'gztar', 'nt': 'zip' } sub_commands = [('check', checking_metadata)] def initialize_options(self): # 'template' and 'manifest' are, respectively, the names of # the manifest template and manifest file. self.template = None self.manifest = None # 'use_defaults': if true, we will include the default file set # in the manifest self.use_defaults = 1 self.prune = 1 self.manifest_only = 0 self.force_manifest = 0 self.formats = None self.keep_temp = 0 self.dist_dir = None self.archive_files = None self.metadata_check = 1 self.owner = None self.group = None def finalize_options(self): if self.manifest is None: self.manifest = "MANIFEST" if self.template is None: self.template = "MANIFEST.in" self.ensure_string_list('formats') if self.formats is None: try: self.formats = [self.default_format[os.name]] except KeyError: raise DistutilsPlatformError, \ "don't know how to create source distributions " + \ "on platform %s" % os.name bad_format = archive_util.check_archive_formats(self.formats) if bad_format: raise DistutilsOptionError, \ "unknown archive format '%s'" % bad_format if self.dist_dir is None: self.dist_dir = "dist" def run(self): # 'filelist' contains the list of files that will make up the # manifest self.filelist = FileList() # Run sub commands for cmd_name in self.get_sub_commands(): self.run_command(cmd_name) # Do whatever it takes to get the list of files to process # (process the manifest template, read an existing manifest, # whatever). File list is accumulated in 'self.filelist'. self.get_file_list() # If user just wanted us to regenerate the manifest, stop now. if self.manifest_only: return # Otherwise, go ahead and create the source distribution tarball, # or zipfile, or whatever. self.make_distribution() def check_metadata(self): """Deprecated API.""" warn("distutils.command.sdist.check_metadata is deprecated, \ use the check command instead", PendingDeprecationWarning) check = self.distribution.get_command_obj('check') check.ensure_finalized() check.run() 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 every time 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) if not template_exists and self._manifest_is_not_generated(): self.read_manifest() self.filelist.sort() self.filelist.remove_duplicates() 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 add_defaults(self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as scripts. - all C sources listed as part of extensions or C libraries in the setup script (doesn't catch C headers!) Warns if (README or README.txt) or setup.py are missing; everything else is optional. """ standards = [('README', 'README.txt'), self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): alts = fn got_it = 0 for fn in alts: if os.path.exists(fn): got_it = 1 self.filelist.append(fn) break if not got_it: self.warn("standard file not found: should have one of " + string.join(alts, ', ')) else: if os.path.exists(fn): self.filelist.append(fn) else: self.warn("standard file '%s' not found" % fn) optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: files = filter(os.path.isfile, glob(pattern)) if files: self.filelist.extend(files) # build_py is used to get: # - python modules # - files defined in package_data build_py = self.get_finalized_command('build_py') # getting python files if self.distribution.has_pure_modules(): self.filelist.extend(build_py.get_source_files()) # getting package_data files # (computed in build_py.data_files by build_py.finalize_options) for pkg, src_dir, build_dir, filenames in build_py.data_files: for filename in filenames: self.filelist.append(os.path.join(src_dir, filename)) # getting distribution.data_files if self.distribution.has_data_files(): for item in self.distribution.data_files: if isinstance(item, str): # plain file item = convert_path(item) if os.path.isfile(item): self.filelist.append(item) else: # a (dirname, filenames) tuple dirname, filenames = item for f in filenames: f = convert_path(f) if os.path.isfile(f): self.filelist.append(f) if self.distribution.has_ext_modules(): build_ext = self.get_finalized_command('build_ext') self.filelist.extend(build_ext.get_source_files()) if self.distribution.has_c_libraries(): build_clib = self.get_finalized_command('build_clib') self.filelist.extend(build_clib.get_source_files()) if self.distribution.has_scripts(): build_scripts = self.get_finalized_command('build_scripts') self.filelist.extend(build_scripts.get_source_files()) def read_template(self): """Read and parse manifest template file named by self.template. (usually "MANIFEST.in") The parsing and processing is done by 'self.filelist', which updates itself accordingly. """ log.info("reading manifest template '%s'", self.template) template = TextFile(self.template, strip_comments=1, skip_blanks=1, join_lines=1, lstrip_ws=1, rstrip_ws=1, collapse_join=1) try: while 1: line = template.readline() if line is None: # end of file break try: self.filelist.process_template_line(line) # the call above can raise a DistutilsTemplateError for # malformed lines, or a ValueError from the lower-level # convert_path function except (DistutilsTemplateError, ValueError) as msg: self.warn("%s, line %d: %s" % (template.filename, template.current_line, msg)) finally: template.close() def prune_file_list(self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS, CVS, .svn, .hg, .git, .bzr, _darcs directories """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) # pruning out vcs directories # both separators are used under win32 if sys.platform == 'win32': seps = r'/|\\' else: seps = '/' vcs_dirs = ['RCS', 'CVS', r'\.svn', r'\.hg', r'\.git', r'\.bzr', '_darcs'] vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps) self.filelist.exclude_pattern(vcs_ptrn, is_regex=1) def write_manifest(self): """Write the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ if self._manifest_is_not_generated(): log.info("not writing to manually maintained " "manifest file '%s'" % self.manifest) return content = self.filelist.files[:] content.insert(0, '# file GENERATED by distutils, do NOT edit') self.execute(file_util.write_file, (self.manifest, content), "writing manifest file '%s'" % self.manifest) def _manifest_is_not_generated(self): # check for special comment used in 2.7.1 and higher if not os.path.isfile(self.manifest): return False fp = open(self.manifest, 'rU') try: first_line = fp.readline() finally: fp.close() return first_line != '# file GENERATED by distutils, do NOT edit\n' 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) manifest = open(self.manifest) for line in manifest: # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: continue self.filelist.append(line) manifest.close() def make_release_tree(self, base_dir, files): """Create the directory tree that will become the source distribution archive. All directories implied by the filenames in 'files' are created under 'base_dir', and then we hard link or copy (if hard linking is unavailable) those files into place. Essentially, this duplicates the developer's source tree, but in a directory named after the distribution, containing only the files to be distributed. """ # Create all the directories under 'base_dir' necessary to # put 'files' there; the 'mkpath()' is just so we don't die # if the manifest happens to be empty. self.mkpath(base_dir) dir_util.create_tree(base_dir, files, dry_run=self.dry_run) # And walk over the list of files, either making a hard link (if # os.link exists) to each one that doesn't already exist in its # corresponding location under 'base_dir', or copying each file # that's out-of-date in 'base_dir'. (Usually, all files will be # out-of-date, because by default we blow away 'base_dir' when # we're done making the distribution archives.) if hasattr(os, 'link'): # can make hard links on this system link = 'hard' msg = "making hard links in %s..." % base_dir else: # nope, have to copy link = None msg = "copying files to %s..." % base_dir if not files: log.warn("no files to distribute -- empty manifest?") else: log.info(msg) for file in files: if not os.path.isfile(file): log.warn("'%s' not a regular file -- skipping" % file) else: dest = os.path.join(base_dir, file) self.copy_file(file, dest, link=link) self.distribution.metadata.write_pkg_info(base_dir) def make_distribution(self): """Create the source distribution(s). First, we create the release tree with 'make_release_tree()'; then, we create all required archive files (according to 'self.formats') from the release tree. Finally, we clean up by blowing away the release tree (unless 'self.keep_temp' is true). The list of archive files created is stored so it can be retrieved later by 'get_archive_files()'. """ # Don't warn about missing meta-data here -- should be (and is!) # done elsewhere. base_dir = self.distribution.get_fullname() base_name = os.path.join(self.dist_dir, base_dir) self.make_release_tree(base_dir, self.filelist.files) archive_files = [] # remember names of files we create # tar archive must be created last to avoid overwrite and remove if 'tar' in self.formats: self.formats.append(self.formats.pop(self.formats.index('tar'))) for fmt in self.formats: file = self.make_archive(base_name, fmt, base_dir=base_dir, owner=self.owner, group=self.group) archive_files.append(file) self.distribution.dist_files.append(('sdist', '', file)) self.archive_files = archive_files if not self.keep_temp: dir_util.remove_tree(base_dir, dry_run=self.dry_run) def get_archive_files(self): """Return the list of archive files created when the command was run, or None if the command hasn't run yet. """ return self.archive_files
SILENT KILLER Tool