summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command/bdist.py
blob: 5630828580d5d443350fd39337651d1f597d9dc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""distutils.command.bdist

Implements the Distutils 'bdist' command (create a built [binary]
distribution)."""

# created 2000/03/29, Greg Ward

__revision__ = "$Id$"

import os, string
from distutils.core import Command


class bdist (Command):

    description = "create a built (binary) distribution"

    user_options = [('formats=', 'f',
                     "formats for distribution (tar, ztar, gztar, zip, ... )"),
                   ]

    # This won't do in reality: will need to distinguish RPM-ish Linux,
    # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
    default_format = { 'posix': 'gztar',
                       'nt': 'zip', }

    format_command = { 'gztar': 'bdist_dumb',
                       'zip':   'bdist_dumb', }


    def initialize_options (self):
        self.formats = None

    # initialize_options()


    def finalize_options (self):
        if self.formats is None:
            try:
                self.formats = [self.default_format[os.name]]
            except KeyError:
                raise DistutilsPlatformError, \
                      "don't know how to create built distributions " + \
                      "on platform %s" % os.name
        elif type (self.formats) is StringType:
            self.formats = string.split (self.formats, ',')
            

    # finalize_options()


    def run (self):

        for format in self.formats:
            cmd_name = self.format_command[format]
            sub_cmd = self.find_peer (cmd_name)
            sub_cmd.set_option ('format', format)

            # XXX blecchhh!! should formalize this: at least a
            # 'forget_run()' (?)  method, possibly complicate the
            # 'have_run' dictionary to include some command state as well
            # as the command name -- eg. in this case we might want
            # ('bdist_dumb','zip') to be marked "have run", but not
            # ('bdist_dumb','gztar').
            self.distribution.have_run[cmd_name] = 0
            self.run_peer (cmd_name)

    # run()

# class bdist