home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / BDIST_DUMB.PY < prev    next >
Encoding:
Python Source  |  2000-09-30  |  3.1 KB  |  96 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. # created 2000/03/29, Greg Ward
  8.  
  9. __revision__ = "$Id: bdist_dumb.py,v 1.16 2000/09/30 18:27:54 gward 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
  15. from distutils.errors import *
  16.  
  17. class bdist_dumb (Command):
  18.  
  19.     description = "create a \"dumb\" built distribution"
  20.  
  21.     user_options = [('bdist-dir=', 'd',
  22.                      "temporary directory for creating the distribution"),
  23.                     ('plat-name=', 'p',
  24.                      "platform name to embed in generated filenames "
  25.                      "(default: %s)" % get_platform()),
  26.                     ('format=', 'f',
  27.                      "archive format to create (tar, ztar, gztar, zip)"),
  28.                     ('keep-temp', 'k',
  29.                      "keep the pseudo-installation tree around after " +
  30.                      "creating the distribution archive"),
  31.                     ('dist-dir=', 'd',
  32.                      "directory to put final built distributions in"),
  33.                    ]
  34.  
  35.     boolean_options = ['keep-temp']
  36.  
  37.     default_format = { 'posix': 'gztar',
  38.                        'nt': 'zip', }
  39.  
  40.  
  41.     def initialize_options (self):
  42.         self.bdist_dir = None
  43.         self.plat_name = None
  44.         self.format = None
  45.         self.keep_temp = 0
  46.         self.dist_dir = None
  47.  
  48.     # initialize_options()
  49.  
  50.  
  51.     def finalize_options (self):
  52.  
  53.         if self.bdist_dir is None:
  54.             bdist_base = self.get_finalized_command('bdist').bdist_base
  55.             self.bdist_dir = os.path.join(bdist_base, 'dumb')
  56.  
  57.         if self.format is None:
  58.             try:
  59.                 self.format = self.default_format[os.name]
  60.             except KeyError:
  61.                 raise DistutilsPlatformError, \
  62.                       ("don't know how to create dumb built distributions " +
  63.                        "on platform %s") % os.name
  64.  
  65.         self.set_undefined_options('bdist',
  66.                                    ('dist_dir', 'dist_dir'),
  67.                                    ('plat_name', 'plat_name'))
  68.  
  69.     # finalize_options()
  70.  
  71.  
  72.     def run (self):
  73.  
  74.         self.run_command('build')
  75.  
  76.         install = self.reinitialize_command('install', reinit_subcommands=1)
  77.         install.root = self.bdist_dir
  78.  
  79.         self.announce("installing to %s" % self.bdist_dir)
  80.         self.run_command('install')
  81.  
  82.         # And make an archive relative to the root of the
  83.         # pseudo-installation tree.
  84.         archive_basename = "%s.%s" % (self.distribution.get_fullname(),
  85.                                       self.plat_name)
  86.         self.make_archive(os.path.join(self.dist_dir, archive_basename),
  87.                           self.format,
  88.                           root_dir=self.bdist_dir)
  89.  
  90.         if not self.keep_temp:
  91.             remove_tree(self.bdist_dir, self.verbose, self.dry_run)
  92.  
  93.     # run()
  94.  
  95. # class bdist_dumb
  96.