PyXR

c:\python24\lib \ distutils \ command \ bdist_dumb.py



0001 """distutils.command.bdist_dumb
0002 
0003 Implements the Distutils 'bdist_dumb' command (create a "dumb" built
0004 distribution -- i.e., just an archive to be unpacked under $prefix or
0005 $exec_prefix)."""
0006 
0007 # This module should be kept compatible with Python 1.5.2.
0008 
0009 __revision__ = "$Id: bdist_dumb.py,v 1.24 2004/07/18 06:14:42 tim_one Exp $"
0010 
0011 import os
0012 from distutils.core import Command
0013 from distutils.util import get_platform
0014 from distutils.dir_util import create_tree, remove_tree, ensure_relative
0015 from distutils.errors import *
0016 from distutils import log
0017 
0018 class bdist_dumb (Command):
0019 
0020     description = "create a \"dumb\" built distribution"
0021 
0022     user_options = [('bdist-dir=', 'd',
0023                      "temporary directory for creating the distribution"),
0024                     ('plat-name=', 'p',
0025                      "platform name to embed in generated filenames "
0026                      "(default: %s)" % get_platform()),
0027                     ('format=', 'f',
0028                      "archive format to create (tar, ztar, gztar, zip)"),
0029                     ('keep-temp', 'k',
0030                      "keep the pseudo-installation tree around after " +
0031                      "creating the distribution archive"),
0032                     ('dist-dir=', 'd',
0033                      "directory to put final built distributions in"),
0034                     ('skip-build', None,
0035                      "skip rebuilding everything (for testing/debugging)"),
0036                     ('relative', None,
0037                      "build the archive using relative paths"
0038                      "(default: false)"),
0039                    ]
0040 
0041     boolean_options = ['keep-temp', 'skip-build', 'relative']
0042 
0043     default_format = { 'posix': 'gztar',
0044                        'nt': 'zip',
0045                        'os2': 'zip' }
0046 
0047 
0048     def initialize_options (self):
0049         self.bdist_dir = None
0050         self.plat_name = None
0051         self.format = None
0052         self.keep_temp = 0
0053         self.dist_dir = None
0054         self.skip_build = 0
0055         self.relative = 0
0056 
0057     # initialize_options()
0058 
0059 
0060     def finalize_options (self):
0061 
0062         if self.bdist_dir is None:
0063             bdist_base = self.get_finalized_command('bdist').bdist_base
0064             self.bdist_dir = os.path.join(bdist_base, 'dumb')
0065 
0066         if self.format is None:
0067             try:
0068                 self.format = self.default_format[os.name]
0069             except KeyError:
0070                 raise DistutilsPlatformError, \
0071                       ("don't know how to create dumb built distributions " +
0072                        "on platform %s") % os.name
0073 
0074         self.set_undefined_options('bdist',
0075                                    ('dist_dir', 'dist_dir'),
0076                                    ('plat_name', 'plat_name'))
0077 
0078     # finalize_options()
0079 
0080 
0081     def run (self):
0082 
0083         if not self.skip_build:
0084             self.run_command('build')
0085 
0086         install = self.reinitialize_command('install', reinit_subcommands=1)
0087         install.root = self.bdist_dir
0088         install.skip_build = self.skip_build
0089         install.warn_dir = 0
0090 
0091         log.info("installing to %s" % self.bdist_dir)
0092         self.run_command('install')
0093 
0094         # And make an archive relative to the root of the
0095         # pseudo-installation tree.
0096         archive_basename = "%s.%s" % (self.distribution.get_fullname(),
0097                                       self.plat_name)
0098 
0099         # OS/2 objects to any ":" characters in a filename (such as when
0100         # a timestamp is used in a version) so change them to hyphens.
0101         if os.name == "os2":
0102             archive_basename = archive_basename.replace(":", "-")
0103 
0104         pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
0105         if not self.relative:
0106             archive_root = self.bdist_dir
0107         else:
0108             if (self.distribution.has_ext_modules() and
0109                 (install.install_base != install.install_platbase)):
0110                 raise DistutilsPlatformError, \
0111                       ("can't make a dumb built distribution where "
0112                        "base and platbase are different (%s, %s)"
0113                        % (repr(install.install_base),
0114                           repr(install.install_platbase)))
0115             else:
0116                 archive_root = os.path.join(self.bdist_dir,
0117                                    ensure_relative(install.install_base))
0118 
0119         # Make the archive
0120         self.make_archive(pseudoinstall_root,
0121                           self.format, root_dir=archive_root)
0122 
0123         if not self.keep_temp:
0124             remove_tree(self.bdist_dir, dry_run=self.dry_run)
0125 
0126     # run()
0127 
0128 # class bdist_dumb
0129 

Generated by PyXR 0.9.4
SourceForge.net Logo