- Got rid of newmodule.c
[python/dscho.git] / Lib / distutils / command / bdist_dumb.py
blob712fec884ed3e8188478a22d9d50a68fc5311d85
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 *
16 from distutils import log
18 class bdist_dumb (Command):
20 description = "create a \"dumb\" built distribution"
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)"),
38 boolean_options = ['keep-temp', 'skip-build']
40 default_format = { 'posix': 'gztar',
41 'nt': 'zip',
42 'os2': 'zip' }
45 def initialize_options (self):
46 self.bdist_dir = None
47 self.plat_name = None
48 self.format = None
49 self.keep_temp = 0
50 self.dist_dir = None
51 self.skip_build = 0
53 # initialize_options()
56 def finalize_options (self):
58 if self.bdist_dir is None:
59 bdist_base = self.get_finalized_command('bdist').bdist_base
60 self.bdist_dir = os.path.join(bdist_base, 'dumb')
62 if self.format is None:
63 try:
64 self.format = self.default_format[os.name]
65 except KeyError:
66 raise DistutilsPlatformError, \
67 ("don't know how to create dumb built distributions " +
68 "on platform %s") % os.name
70 self.set_undefined_options('bdist',
71 ('dist_dir', 'dist_dir'),
72 ('plat_name', 'plat_name'))
74 # finalize_options()
77 def run (self):
79 if not self.skip_build:
80 self.run_command('build')
82 install = self.reinitialize_command('install', reinit_subcommands=1)
83 install.root = self.bdist_dir
84 install.skip_build = self.skip_build
85 install.warn_dir = 0
87 log.info("installing to %s" % self.bdist_dir)
88 self.run_command('install')
90 # And make an archive relative to the root of the
91 # pseudo-installation tree.
92 archive_basename = "%s.%s" % (self.distribution.get_fullname(),
93 self.plat_name)
95 # OS/2 objects to any ":" characters in a filename (such as when
96 # a timestamp is used in a version) so change them to hyphens.
97 if os.name == "os2":
98 archive_basename = archive_basename.replace(":", "-")
100 self.make_archive(os.path.join(self.dist_dir, archive_basename),
101 self.format,
102 root_dir=self.bdist_dir)
104 if not self.keep_temp:
105 remove_tree(self.bdist_dir, dry_run=self.dry_run)
107 # run()
109 # class bdist_dumb