2000-03-31 02:55:12 +00: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 04:53:41 +00:00
|
|
|
from types import *
|
2000-03-31 02:55:12 +00:00
|
|
|
from distutils.core import Command
|
2000-03-31 05:08:50 +00:00
|
|
|
from distutils.errors import *
|
2000-03-31 02:55:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class bdist (Command):
|
|
|
|
|
|
|
|
description = "create a built (binary) distribution"
|
|
|
|
|
2000-03-31 05:08:50 +00:00
|
|
|
user_options = [('format=', 'f',
|
2000-04-25 01:38:20 +00:00
|
|
|
"format for distribution " +
|
|
|
|
"(tar, ztar, gztar, bztar, zip, ... )"),
|
2000-03-31 02:55:12 +00: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-04-25 01:38:20 +00:00
|
|
|
'bztar': 'bdist_dumb',
|
2000-03-31 04:53:41 +00:00
|
|
|
'ztar': 'bdist_dumb',
|
|
|
|
'tar': 'bdist_dumb',
|
2000-03-31 02:55:12 +00:00
|
|
|
'zip': 'bdist_dumb', }
|
|
|
|
|
|
|
|
|
|
|
|
def initialize_options (self):
|
2000-03-31 05:08:50 +00:00
|
|
|
self.format = None
|
2000-03-31 02:55:12 +00:00
|
|
|
|
|
|
|
# initialize_options()
|
|
|
|
|
|
|
|
|
|
|
|
def finalize_options (self):
|
2000-03-31 05:08:50 +00:00
|
|
|
if self.format is None:
|
2000-03-31 02:55:12 +00:00
|
|
|
try:
|
2000-03-31 05:08:50 +00:00
|
|
|
self.format = self.default_format[os.name]
|
2000-03-31 02:55:12 +00:00
|
|
|
except KeyError:
|
|
|
|
raise DistutilsPlatformError, \
|
|
|
|
"don't know how to create built distributions " + \
|
|
|
|
"on platform %s" % os.name
|
2000-03-31 05:08:50 +00:00
|
|
|
#elif type (self.format) is StringType:
|
|
|
|
# self.format = string.split (self.format, ',')
|
2000-03-31 02:55:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
# finalize_options()
|
|
|
|
|
|
|
|
|
|
|
|
def run (self):
|
|
|
|
|
2000-03-31 05:08:50 +00: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 05:21:27 +00:00
|
|
|
self.run_peer (cmd_name)
|
2000-03-31 02:55:12 +00:00
|
|
|
|
|
|
|
# run()
|
|
|
|
|
|
|
|
# class bdist
|