home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / bdist_dumb.py < prev    next >
Text File  |  2003-12-30  |  5KB  |  129 lines

  1. """distutils.command.bdist_dumb
  2.  
  3. Implements the Distutils 'bdist_dumb' command (create a "dumb" built
  4. distribution -- i.e., just an archive to be unpacked under $prefix or
  5. $exec_prefix)."""
  6.  
  7. # This module should be kept compatible with Python 1.5.2.
  8.  
  9. __revision__ = "$Id: bdist_dumb.py,v 1.23 2002/11/26 17:45:19 akuchling Exp $"
  10.  
  11. import os
  12. from distutils.core import Command
  13. from distutils.util import get_platform
  14. from distutils.dir_util import create_tree, remove_tree, ensure_relative
  15. from distutils.errors import *
  16. from distutils import log
  17.  
  18. class bdist_dumb (Command):
  19.  
  20.     description = "create a \"dumb\" built distribution"
  21.  
  22.     user_options = [('bdist-dir=', 'd',
  23.                      "temporary directory for creating the distribution"),
  24.                     ('plat-name=', 'p',
  25.                      "platform name to embed in generated filenames "
  26.                      "(default: %s)" % get_platform()),
  27.                     ('format=', 'f',
  28.                      "archive format to create (tar, ztar, gztar, zip)"),
  29.                     ('keep-temp', 'k',
  30.                      "keep the pseudo-installation tree around after " +
  31.                      "creating the distribution archive"),
  32.                     ('dist-dir=', 'd',
  33.                      "directory to put final built distributions in"),
  34.                     ('skip-build', None,
  35.                      "skip rebuilding everything (for testing/debugging)"),
  36.                     ('relative', None,
  37.                      "build the archive using relative paths"
  38.                      "(default: false)"),
  39.                    ]
  40.  
  41.     boolean_options = ['keep-temp', 'skip-build', 'relative']
  42.  
  43.     default_format = { 'posix': 'gztar',
  44.                        'nt': 'zip',
  45.                        'os2': 'zip' }
  46.  
  47.  
  48.     def initialize_options (self):
  49.         self.bdist_dir = None
  50.         self.plat_name = None
  51.         self.format = None
  52.         self.keep_temp = 0
  53.         self.dist_dir = None
  54.         self.skip_build = 0
  55.         self.relative = 0
  56.         
  57.     # initialize_options()
  58.  
  59.  
  60.     def finalize_options (self):
  61.  
  62.         if self.bdist_dir is None:
  63.             bdist_base = self.get_finalized_command('bdist').bdist_base
  64.             self.bdist_dir = os.path.join(bdist_base, 'dumb')
  65.  
  66.         if self.format is None:
  67.             try:
  68.                 self.format = self.default_format[os.name]
  69.             except KeyError:
  70.                 raise DistutilsPlatformError, \
  71.                       ("don't know how to create dumb built distributions " +
  72.                        "on platform %s") % os.name
  73.  
  74.         self.set_undefined_options('bdist',
  75.                                    ('dist_dir', 'dist_dir'),
  76.                                    ('plat_name', 'plat_name'))
  77.  
  78.     # finalize_options()
  79.  
  80.  
  81.     def run (self):
  82.  
  83.         if not self.skip_build:
  84.             self.run_command('build')
  85.  
  86.         install = self.reinitialize_command('install', reinit_subcommands=1)
  87.         install.root = self.bdist_dir
  88.         install.skip_build = self.skip_build
  89.         install.warn_dir = 0
  90.  
  91.         log.info("installing to %s" % self.bdist_dir)
  92.         self.run_command('install')
  93.  
  94.         # And make an archive relative to the root of the
  95.         # pseudo-installation tree.
  96.         archive_basename = "%s.%s" % (self.distribution.get_fullname(),
  97.                                       self.plat_name)
  98.  
  99.         # OS/2 objects to any ":" characters in a filename (such as when
  100.         # a timestamp is used in a version) so change them to hyphens.
  101.         if os.name == "os2":
  102.             archive_basename = archive_basename.replace(":", "-")
  103.  
  104.         pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
  105.         if not self.relative:
  106.             archive_root = self.bdist_dir
  107.         else:
  108.             if (self.distribution.has_ext_modules() and
  109.                 (install.install_base != install.install_platbase)):
  110.                 raise DistutilsPlatformError, \
  111.                       ("can't make a dumb built distribution where "
  112.                        "base and platbase are different (%s, %s)"
  113.                        % (repr(install.install_base),
  114.                           repr(install.install_platbase)))
  115.             else:
  116.                 archive_root = os.path.join(self.bdist_dir,
  117.                                    ensure_relative(install.install_base))
  118.  
  119.         # Make the archive
  120.         self.make_archive(pseudoinstall_root,
  121.                           self.format, root_dir=archive_root)
  122.  
  123.         if not self.keep_temp:
  124.             remove_tree(self.bdist_dir, dry_run=self.dry_run)
  125.  
  126.     # run()
  127.  
  128. # class bdist_dumb
  129.