blob: 805aa0a9ebfce452f522bd2dd6b915d3f87c0356 [file] [log] [blame]
Greg Warde1664bd2000-03-31 02:56:34 +00001"""distutils.command.bdist_dumb
2
3Implements the Distutils 'bdist_dumb' command (create a "dumb" built
4distribution -- 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$"
10
11import os
12from distutils.core import Command
Greg Wardb4c850c2000-03-31 05:22:47 +000013from distutils.util import get_platform, create_tree, remove_tree
Greg Ward6ce94b72000-04-26 02:29:51 +000014from distutils.errors import *
Greg Warde1664bd2000-03-31 02:56:34 +000015
16class bdist_dumb (Command):
17
18 description = "create a \"dumb\" built distribution"
19
Gregory P. Smithba0506b2000-05-13 03:06:56 +000020 user_options = [('bdist-dir=', 'd',
21 "temporary directory for creating the distribution"),
22 ('format=', 'f',
Greg Warde1664bd2000-03-31 02:56:34 +000023 "archive format to create (tar, ztar, gztar, zip)"),
Greg Wardb4c850c2000-03-31 05:22:47 +000024 ('keep-tree', 'k',
25 "keep the pseudo-installation tree around after " +
26 "creating the distribution archive"),
Greg Wardc4eb84a2000-07-05 03:07:37 +000027 ('dist-dir=', 'd',
28 "directory to put final built distributions in"),
Greg Warde1664bd2000-03-31 02:56:34 +000029 ]
30
31 default_format = { 'posix': 'gztar',
32 'nt': 'zip', }
33
34
35 def initialize_options (self):
Gregory P. Smithba0506b2000-05-13 03:06:56 +000036 self.bdist_dir = None
Greg Warde1664bd2000-03-31 02:56:34 +000037 self.format = None
Greg Wardb4c850c2000-03-31 05:22:47 +000038 self.keep_tree = 0
Greg Wardc4eb84a2000-07-05 03:07:37 +000039 self.dist_dir = None
Greg Warde1664bd2000-03-31 02:56:34 +000040
41 # initialize_options()
42
43
44 def finalize_options (self):
Gregory P. Smithba0506b2000-05-13 03:06:56 +000045 if self.bdist_dir is None:
Greg Ward4fb29e52000-05-27 17:27:23 +000046 bdist_base = self.get_finalized_command('bdist').bdist_base
Gregory P. Smithba0506b2000-05-13 03:06:56 +000047 self.bdist_dir = os.path.join(bdist_base, 'dumb')
48
Greg Warde1664bd2000-03-31 02:56:34 +000049 if self.format is None:
50 try:
51 self.format = self.default_format[os.name]
52 except KeyError:
53 raise DistutilsPlatformError, \
54 ("don't know how to create dumb built distributions " +
55 "on platform %s") % os.name
56
Greg Wardc4eb84a2000-07-05 03:07:37 +000057 self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
58
Greg Warde1664bd2000-03-31 02:56:34 +000059 # finalize_options()
60
61
62 def run (self):
63
Greg Ward4fb29e52000-05-27 17:27:23 +000064 self.run_command ('build')
Greg Warde1664bd2000-03-31 02:56:34 +000065
Greg Wardedc6a512000-06-28 00:36:40 +000066 install = self.reinitialize_command('install')
Gregory P. Smithba0506b2000-05-13 03:06:56 +000067 install.root = self.bdist_dir
Greg Warde1664bd2000-03-31 02:56:34 +000068
Gregory P. Smithba0506b2000-05-13 03:06:56 +000069 self.announce ("installing to %s" % self.bdist_dir)
Greg Ward4fb29e52000-05-27 17:27:23 +000070 install.ensure_finalized()
Gregory P. Smithba0506b2000-05-13 03:06:56 +000071 install.run()
Greg Warde1664bd2000-03-31 02:56:34 +000072
73 # And make an archive relative to the root of the
74 # pseudo-installation tree.
Greg Ward0ae7f762000-04-22 02:51:25 +000075 archive_basename = "%s.%s" % (self.distribution.get_fullname(),
Greg Warde1664bd2000-03-31 02:56:34 +000076 get_platform())
Gregory P. Smithba0506b2000-05-13 03:06:56 +000077 print "self.bdist_dir = %s" % self.bdist_dir
Greg Wardb4c850c2000-03-31 05:22:47 +000078 print "self.format = %s" % self.format
Greg Wardc4eb84a2000-07-05 03:07:37 +000079 self.make_archive (os.path.join(self.dist_dir, archive_basename),
80 self.format,
Gregory P. Smithba0506b2000-05-13 03:06:56 +000081 root_dir=self.bdist_dir)
Greg Warde1664bd2000-03-31 02:56:34 +000082
Greg Wardb4c850c2000-03-31 05:22:47 +000083 if not self.keep_tree:
Gregory P. Smithba0506b2000-05-13 03:06:56 +000084 remove_tree (self.bdist_dir, self.verbose, self.dry_run)
Greg Wardb4c850c2000-03-31 05:22:47 +000085
Greg Warde1664bd2000-03-31 02:56:34 +000086 # run()
87
Greg Warde1664bd2000-03-31 02:56:34 +000088# class bdist_dumb