Updated for 2.1a3
[python/dscho.git] / Lib / distutils / command / bdist_dumb.py
blob8dfc3271dfaf18d8bdc8faa611b9e0efb0089985
1 """distutils.command.bdist_dumb
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)."""
7 # created 2000/03/29, Greg Ward
9 __revision__ = "$Id$"
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 *
17 class bdist_dumb (Command):
19 description = "create a \"dumb\" built distribution"
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"),
35 boolean_options = ['keep-temp']
37 default_format = { 'posix': 'gztar',
38 'nt': 'zip', }
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
48 # initialize_options()
51 def finalize_options (self):
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')
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
65 self.set_undefined_options('bdist',
66 ('dist_dir', 'dist_dir'),
67 ('plat_name', 'plat_name'))
69 # finalize_options()
72 def run (self):
74 self.run_command('build')
76 install = self.reinitialize_command('install', reinit_subcommands=1)
77 install.root = self.bdist_dir
79 self.announce("installing to %s" % self.bdist_dir)
80 self.run_command('install')
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)
90 if not self.keep_temp:
91 remove_tree(self.bdist_dir, self.verbose, self.dry_run)
93 # run()
95 # class bdist_dumb