33Implements the Distutils 'bdist' command (create a built [binary]
44distribution)."""
55
6- # This module should be kept compatible with Python 2.1.
7-
8- __revision__ = "$Id: bdist.py 62197 2008-04-07 01:53:39Z mark.hammond $"
6+ __revision__ = "$Id$"
97
108import os
11- from types import *
12- from distutils .core import Command
13- from distutils .errors import *
9+
1410from distutils .util import get_platform
11+ from distutils .core import Command
12+ from distutils .errors import DistutilsPlatformError , DistutilsOptionError
1513
1614
17- def show_formats ():
15+ def show_formats ():
1816 """Print list of available formats (arguments to "--format" option).
1917 """
2018 from distutils .fancy_getopt import FancyGetopt
21- formats = []
19+ formats = []
2220 for format in bdist .format_commands :
2321 formats .append (("formats=" + format , None ,
2422 bdist .format_command [format ][1 ]))
2523 pretty_printer = FancyGetopt (formats )
2624 pretty_printer .print_help ("List of available distribution formats:" )
2725
2826
29- class bdist (Command ):
27+ class bdist (Command ):
3028
3129 description = "create a built (binary) distribution"
3230
@@ -42,6 +40,12 @@ class bdist (Command):
4240 "[default: dist]" ),
4341 ('skip-build' , None ,
4442 "skip rebuilding everything (for testing/debugging)" ),
43+ ('owner=' , 'u' ,
44+ "Owner name used when creating a tar file"
45+ " [default: current user]" ),
46+ ('group=' , 'g' ,
47+ "Group name used when creating a tar file"
48+ " [default: current group]" ),
4549 ]
4650
4751 boolean_options = ['skip-build' ]
@@ -52,50 +56,42 @@ class bdist (Command):
5256 ]
5357
5458 # The following commands do not take a format option from bdist
55- no_format_option = ('bdist_rpm' ,
56- #'bdist_sdux', 'bdist_pkgtool'
57- )
59+ no_format_option = ('bdist_rpm' ,)
5860
5961 # This won't do in reality: will need to distinguish RPM-ish Linux,
6062 # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS.
61- default_format = { 'posix' : 'gztar' ,
62- 'java' : 'gztar' ,
63- 'nt' : 'zip' ,
64- 'os2' : 'zip' , }
63+ default_format = {'posix' : 'gztar' ,
64+ 'java' : 'gztar' ,
65+ 'nt' : 'zip' ,
66+ 'os2' : 'zip' }
6567
6668 # Establish the preferred order (for the --help-formats option).
6769 format_commands = ['rpm' , 'gztar' , 'bztar' , 'ztar' , 'tar' ,
68- 'wininst' , 'zip' ,
69- #'pkgtool', 'sdux'
70- ]
70+ 'wininst' , 'zip' , 'msi' ]
7171
7272 # And the real information.
73- format_command = { 'rpm' : ('bdist_rpm' , "RPM distribution" ),
74- 'zip' : ('bdist_dumb' , "ZIP file" ),
75- 'gztar' : ('bdist_dumb' , "gzip'ed tar file" ),
76- 'bztar' : ('bdist_dumb' , "bzip2'ed tar file" ),
77- 'ztar' : ('bdist_dumb' , "compressed tar file" ),
78- 'tar' : ('bdist_dumb' , "tar file" ),
79- 'wininst' : ('bdist_wininst' ,
80- "Windows executable installer" ),
81- 'zip' : ('bdist_dumb' , "ZIP file" ),
82- #'pkgtool': ('bdist_pkgtool',
83- # "Solaris pkgtool distribution"),
84- #'sdux': ('bdist_sdux', "HP-UX swinstall depot"),
73+ format_command = {'rpm' : ('bdist_rpm' , "RPM distribution" ),
74+ 'gztar' : ('bdist_dumb' , "gzip'ed tar file" ),
75+ 'bztar' : ('bdist_dumb' , "bzip2'ed tar file" ),
76+ 'ztar' : ('bdist_dumb' , "compressed tar file" ),
77+ 'tar' : ('bdist_dumb' , "tar file" ),
78+ 'wininst' : ('bdist_wininst' ,
79+ "Windows executable installer" ),
80+ 'zip' : ('bdist_dumb' , "ZIP file" ),
81+ 'msi' : ('bdist_msi' , "Microsoft Installer" )
8582 }
8683
8784
88- def initialize_options (self ):
85+ def initialize_options (self ):
8986 self .bdist_base = None
9087 self .plat_name = None
9188 self .formats = None
9289 self .dist_dir = None
9390 self .skip_build = 0
91+ self .group = None
92+ self .owner = None
9493
95- # initialize_options()
96-
97-
98- def finalize_options (self ):
94+ def finalize_options (self ):
9995 # have to finalize 'plat_name' before 'bdist_base'
10096 if self .plat_name is None :
10197 if self .skip_build :
@@ -123,10 +119,7 @@ def finalize_options (self):
123119 if self .dist_dir is None :
124120 self .dist_dir = "dist"
125121
126- # finalize_options()
127-
128- def run (self ):
129-
122+ def run (self ):
130123 # Figure out which sub-commands we need to run.
131124 commands = []
132125 for format in self .formats :
@@ -142,12 +135,13 @@ def run (self):
142135 if cmd_name not in self .no_format_option :
143136 sub_cmd .format = self .formats [i ]
144137
138+ # passing the owner and group names for tar archiving
139+ if cmd_name == 'bdist_dumb' :
140+ sub_cmd .owner = self .owner
141+ sub_cmd .group = self .group
142+
145143 # If we're going to need to run this command again, tell it to
146144 # keep its temporary files around so subsequent runs go faster.
147145 if cmd_name in commands [i + 1 :]:
148146 sub_cmd .keep_temp = 1
149147 self .run_command (cmd_name )
150-
151- # run()
152-
153- # class bdist
0 commit comments