annotate Lib/distutils/command/bdist.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 3e26c9033306
children 147b9d530dd0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
1 """distutils.command.bdist
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
2
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
3 Implements the Distutils 'bdist' command (create a built [binary]
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
4 distribution)."""
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
5
41480
99027c2b3fd2 Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents: 33965
diff changeset
6 import os
63136
29a3eda89995 reverted distutils its 3.1 state. All new work is now happening in disutils2, and distutils is now feature-frozen.
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58559
diff changeset
7 from distutils.core import Command
29a3eda89995 reverted distutils its 3.1 state. All new work is now happening in disutils2, and distutils is now feature-frozen.
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58559
diff changeset
8 from distutils.errors import *
58559
38b90fe34623 Merged revisions 77759,77761 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 58558
diff changeset
9 from distutils.util import get_platform
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
10
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
11
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
12 def show_formats():
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
13 """Print list of available formats (arguments to "--format" option).
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
14 """
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 15216
diff changeset
15 from distutils.fancy_getopt import FancyGetopt
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
16 formats = []
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
17 for format in bdist.format_commands:
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
18 formats.append(("formats=" + format, None,
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
19 bdist.format_command[format][1]))
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
20 pretty_printer = FancyGetopt(formats)
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
21 pretty_printer.print_help("List of available distribution formats:")
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
22
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
23
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
24 class bdist(Command):
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
25
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
26 description = "create a built (binary) distribution"
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
27
12703
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
28 user_options = [('bdist-base=', 'b',
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
29 "temporary directory for creating built distributions"),
14507
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
30 ('plat-name=', 'p',
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
31 "platform name to embed in generated filenames "
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
32 "(default: %s)" % get_platform()),
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
33 ('formats=', None,
12997
27f3a18fd296 Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents: 12869
diff changeset
34 "formats for distribution (comma-separated list)"),
13348
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
35 ('dist-dir=', 'd',
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
36 "directory to put final built distributions in "
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
37 "[default: dist]"),
21714
630293be1035 Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents: 21268
diff changeset
38 ('skip-build', None,
630293be1035 Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents: 21268
diff changeset
39 "skip rebuilding everything (for testing/debugging)"),
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
40 ]
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
41
21714
630293be1035 Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents: 21268
diff changeset
42 boolean_options = ['skip-build']
630293be1035 Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents: 21268
diff changeset
43
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
44 help_options = [
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
45 ('help-formats', None,
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
46 "lists available distribution formats", show_formats),
15216
a3975d2811f0 Untabified.
Greg Ward <gward@python.net>
parents: 14948
diff changeset
47 ]
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
48
12691
7b466a73c961 Harry Henry Gebel: add support for the 'bdist_rpm' command, specifically
Gregory P. Smith <greg@mad-scientist.com>
parents: 12603
diff changeset
49 # The following commands do not take a format option from bdist
52919
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
50 no_format_option = ('bdist_rpm',)
12691
7b466a73c961 Harry Henry Gebel: add support for the 'bdist_rpm' command, specifically
Gregory P. Smith <greg@mad-scientist.com>
parents: 12603
diff changeset
51
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
52 # This won't do in reality: will need to distinguish RPM-ish Linux,
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
53 # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
52919
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
54 default_format = {'posix': 'gztar',
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
55 'nt': 'zip',
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
56 'os2': 'zip'}
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
57
13810
76237c0cbf13 Added 'wininst' to the 'format_commands' list, so it's included in
Greg Ward <gward@python.net>
parents: 13348
diff changeset
58 # Establish the preferred order (for the --help-formats option).
76237c0cbf13 Added 'wininst' to the 'format_commands' list, so it's included in
Greg Ward <gward@python.net>
parents: 13348
diff changeset
59 format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar',
52919
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
60 'wininst', 'zip', 'msi']
13810
76237c0cbf13 Added 'wininst' to the 'format_commands' list, so it's included in
Greg Ward <gward@python.net>
parents: 13348
diff changeset
61
76237c0cbf13 Added 'wininst' to the 'format_commands' list, so it's included in
Greg Ward <gward@python.net>
parents: 13348
diff changeset
62 # And the real information.
52919
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
63 format_command = {'rpm': ('bdist_rpm', "RPM distribution"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
64 'gztar': ('bdist_dumb', "gzip'ed tar file"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
65 'bztar': ('bdist_dumb', "bzip2'ed tar file"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
66 'ztar': ('bdist_dumb', "compressed tar file"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
67 'tar': ('bdist_dumb', "tar file"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
68 'wininst': ('bdist_wininst',
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
69 "Windows executable installer"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
70 'zip': ('bdist_dumb', "ZIP file"),
548ca34357cd Merged revisions 71291 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 46370
diff changeset
71 'msi': ('bdist_msi', "Microsoft Installer")
23113
e7513e142c70 Patch #531901 by Mark W. Alexander: adds a new distutils packager
Marc-André Lemburg <mal@egenix.com>
parents: 22912
diff changeset
72 }
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
73
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
74
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
75 def initialize_options(self):
12703
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
76 self.bdist_base = None
14507
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
77 self.plat_name = None
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
78 self.formats = None
13348
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
79 self.dist_dir = None
21714
630293be1035 Patch #414775: Add --skip-build option to bdist command.
Martin v. Löwis <martin@v.loewis.de>
parents: 21268
diff changeset
80 self.skip_build = 0
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
81
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
82 def finalize_options(self):
14507
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
83 # have to finalize 'plat_name' before 'bdist_base'
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
84 if self.plat_name is None:
46370
2e917b0c8f6e Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43026
diff changeset
85 if self.skip_build:
2e917b0c8f6e Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43026
diff changeset
86 self.plat_name = get_platform()
2e917b0c8f6e Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43026
diff changeset
87 else:
2e917b0c8f6e Merged revisions 62194,62197-62198,62204-62205,62214,62219-62221,62227,62229-62231,62233-62235,62237-62239 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43026
diff changeset
88 self.plat_name = self.get_finalized_command('build').plat_name
14507
c8727aca1404 Added --plat-name option to override sysconfig.get_platform() in
Greg Ward <gward@python.net>
parents: 13810
diff changeset
89
12703
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
90 # 'bdist_base' -- parent of per-built-distribution-format
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
91 # temporary directories (eg. we'll probably have
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
92 # "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.)
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
93 if self.bdist_base is None:
12783
b91b35c1d4c0 Some far-reaching naming changes:
Greg Ward <gward@python.net>
parents: 12703
diff changeset
94 build_base = self.get_finalized_command('build').build_base
14634
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
95 self.bdist_base = os.path.join(build_base,
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
96 'bdist.' + self.plat_name)
12703
f555fd805085 Added the 'bdist_base' option, the base temp directory for all bdist commands.
Gregory P. Smith <greg@mad-scientist.com>
parents: 12691
diff changeset
97
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
98 self.ensure_string_list('formats')
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
99 if self.formats is None:
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
100 try:
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
101 self.formats = [self.default_format[os.name]]
12155
fed89b57637a The 'bdist' command, for creating "built" (binary) distributions.
Greg Ward <gward@python.net>
parents:
diff changeset
102 except KeyError:
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
103 raise DistutilsPlatformError(
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
104 "don't know how to create built distributions "
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
105 "on platform %s" % os.name)
13348
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
106
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
107 if self.dist_dir is None:
7628882dcccd Added the --dist-dir option that the "bdist_*" will use to control where
Greg Ward <gward@python.net>
parents: 13030
diff changeset
108 self.dist_dir = "dist"
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 15216
diff changeset
109
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
110 def run(self):
14634
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
111 # Figure out which sub-commands we need to run.
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
112 commands = []
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
113 for format in self.formats:
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
114 try:
14634
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
115 commands.append(self.format_command[format][0])
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
116 except KeyError:
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
117 raise DistutilsOptionError("invalid format '%s'" % format)
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
118
14634
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
119 # Reinitialize and run each command.
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
120 for i in range(len(self.formats)):
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
121 cmd_name = commands[i]
12862
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
122 sub_cmd = self.reinitialize_command(cmd_name)
af0def063658 Support for multiple distribution formats in one run.
Greg Ward <gward@python.net>
parents: 12783
diff changeset
123 if cmd_name not in self.no_format_option:
14634
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
124 sub_cmd.format = self.formats[i]
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
125
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
126 # If we're going to need to run this command again, tell it to
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
127 # keep its temporary files around so subsequent runs go faster.
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
128 if cmd_name in commands[i+1:]:
8bd5349e7aa8 Rene Liebscher: if we have to run the same sub-command multiple times
Greg Ward <gward@python.net>
parents: 14507
diff changeset
129 sub_cmd.keep_temp = 1
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14634
diff changeset
130 self.run_command(cmd_name)