2000-03-31 10:55:12 +08:00
|
|
|
"""distutils.command.bdist
|
|
|
|
|
|
|
|
Implements the Distutils 'bdist' command (create a built [binary]
|
|
|
|
distribution)."""
|
|
|
|
|
|
|
|
# created 2000/03/29, Greg Ward
|
|
|
|
|
|
|
|
__revision__ = "$Id$"
|
|
|
|
|
|
|
|
import os, string
|
2000-03-31 12:53:41 +08:00
|
|
|
from types import *
|
2000-03-31 10:55:12 +08:00
|
|
|
from distutils.core import Command
|
2000-03-31 13:08:50 +08:00
|
|
|
from distutils.errors import *
|
2000-03-31 10:55:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
class bdist (Command):
|
|
|
|
|
|
|
|
description = "create a built (binary) distribution"
|
|
|
|
|
2000-03-31 13:08:50 +08:00
|
|
|
user_options = [('format=', 'f',
|
|
|
|
"format for distribution (tar, ztar, gztar, zip, ... )"),
|
2000-03-31 10:55:12 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
# 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',
|
2000-03-31 12:53:41 +08:00
|
|
|
'ztar': 'bdist_dumb',
|
|
|
|
'tar': 'bdist_dumb',
|
2000-03-31 10:55:12 +08:00
|
|
|
'zip': 'bdist_dumb', }
|
|
|
|
|
|
|
|
|
|
|
|
def initialize_options (self):
|
2000-03-31 13:08:50 +08:00
|
|
|
self.format = None
|
2000-03-31 10:55:12 +08:00
|
|
|
|
|
|
|
# initialize_options()
|
|
|
|
|
|
|
|
|
|
|
|
def finalize_options (self):
|
2000-03-31 13:08:50 +08:00
|
|
|
if self.format is None:
|
2000-03-31 10:55:12 +08:00
|
|
|
try:
|
2000-03-31 13:08:50 +08:00
|
|
|
self.format = self.default_format[os.name]
|
2000-03-31 10:55:12 +08:00
|
|
|
except KeyError:
|
|
|
|
raise DistutilsPlatformError, \
|
|
|
|
"don't know how to create built distributions " + \
|
|
|
|
"on platform %s" % os.name
|
2000-03-31 13:08:50 +08:00
|
|
|
#elif type (self.format) is StringType:
|
|
|
|
# self.format = string.split (self.format, ',')
|
2000-03-31 10:55:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
# finalize_options()
|
|
|
|
|
|
|
|
|
|
|
|
def run (self):
|
|
|
|
|
2000-03-31 13:08:50 +08:00
|
|
|
try:
|
|
|
|
cmd_name = self.format_command[self.format]
|
|
|
|
except KeyError:
|
|
|
|
raise DistutilsOptionError, \
|
|
|
|
"invalid archive format '%s'" % self.format
|
|
|
|
|
|
|
|
sub_cmd = self.find_peer (cmd_name)
|
|
|
|
sub_cmd.set_option ('format', self.format)
|
2000-03-31 13:21:27 +08:00
|
|
|
self.run_peer (cmd_name)
|
2000-03-31 10:55:12 +08:00
|
|
|
|
|
|
|
# run()
|
|
|
|
|
|
|
|
# class bdist
|