Rename 'formats' option to 'format', and remove the ability to generate

multiple built distributions in one run -- it seemed a bit dodgy and I'd
rather remove it than try to beat it into submission right now.
This commit is contained in:
Greg Ward 2000-03-31 05:08:50 +00:00
parent 6b213766d8
commit 02296cea39

View file

@ -10,14 +10,15 @@ __revision__ = "$Id$"
import os, string import os, string
from types import * from types import *
from distutils.core import Command from distutils.core import Command
from distutils.errors import *
class bdist (Command): class bdist (Command):
description = "create a built (binary) distribution" description = "create a built (binary) distribution"
user_options = [('formats=', 'f', user_options = [('format=', 'f',
"formats for distribution (tar, ztar, gztar, zip, ... )"), "format for distribution (tar, ztar, gztar, zip, ... )"),
] ]
# This won't do in reality: will need to distinguish RPM-ish Linux, # This won't do in reality: will need to distinguish RPM-ish Linux,
@ -32,21 +33,21 @@ class bdist (Command):
def initialize_options (self): def initialize_options (self):
self.formats = None self.format = None
# initialize_options() # initialize_options()
def finalize_options (self): def finalize_options (self):
if self.formats is None: if self.format is None:
try: try:
self.formats = [self.default_format[os.name]] self.format = self.default_format[os.name]
except KeyError: except KeyError:
raise DistutilsPlatformError, \ raise DistutilsPlatformError, \
"don't know how to create built distributions " + \ "don't know how to create built distributions " + \
"on platform %s" % os.name "on platform %s" % os.name
elif type (self.formats) is StringType: #elif type (self.format) is StringType:
self.formats = string.split (self.formats, ',') # self.format = string.split (self.format, ',')
# finalize_options() # finalize_options()
@ -54,19 +55,14 @@ class bdist (Command):
def run (self): def run (self):
for format in self.formats: try:
cmd_name = self.format_command[format] cmd_name = self.format_command[self.format]
sub_cmd = self.find_peer (cmd_name) except KeyError:
sub_cmd.set_option ('format', format) raise DistutilsOptionError, \
"invalid archive format '%s'" % self.format
# XXX blecchhh!! should formalize this: at least a sub_cmd = self.find_peer (cmd_name)
# 'forget_run()' (?) method, possibly complicate the sub_cmd.set_option ('format', self.format)
# '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() # run()