Commit cade95e3 authored by Greg Ward's avatar Greg Ward

Standardized whitespace around function calls.

parent 48647d7a
...@@ -132,7 +132,7 @@ class bdist (Command): ...@@ -132,7 +132,7 @@ class bdist (Command):
# keep its temporary files around so subsequent runs go faster. # keep its temporary files around so subsequent runs go faster.
if cmd_name in commands[i+1:]: if cmd_name in commands[i+1:]:
sub_cmd.keep_temp = 1 sub_cmd.keep_temp = 1
self.run_command (cmd_name) self.run_command(cmd_name)
# run() # run()
......
...@@ -71,24 +71,24 @@ class bdist_dumb (Command): ...@@ -71,24 +71,24 @@ class bdist_dumb (Command):
def run (self): def run (self):
self.run_command ('build') self.run_command('build')
install = self.reinitialize_command('install', reinit_subcommands=1) install = self.reinitialize_command('install', reinit_subcommands=1)
install.root = self.bdist_dir install.root = self.bdist_dir
self.announce ("installing to %s" % self.bdist_dir) self.announce("installing to %s" % self.bdist_dir)
self.run_command('install') self.run_command('install')
# And make an archive relative to the root of the # And make an archive relative to the root of the
# pseudo-installation tree. # pseudo-installation tree.
archive_basename = "%s.%s" % (self.distribution.get_fullname(), archive_basename = "%s.%s" % (self.distribution.get_fullname(),
self.plat_name) self.plat_name)
self.make_archive (os.path.join(self.dist_dir, archive_basename), self.make_archive(os.path.join(self.dist_dir, archive_basename),
self.format, self.format,
root_dir=self.bdist_dir) root_dir=self.bdist_dir)
if not self.keep_temp: if not self.keep_temp:
remove_tree (self.bdist_dir, self.verbose, self.dry_run) remove_tree(self.bdist_dir, self.verbose, self.dry_run)
# run() # run()
......
...@@ -258,7 +258,7 @@ class bdist_rpm (Command): ...@@ -258,7 +258,7 @@ class bdist_rpm (Command):
# Make a source distribution and copy to SOURCES directory with # Make a source distribution and copy to SOURCES directory with
# optional icon. # optional icon.
sdist = self.reinitialize_command ('sdist') sdist = self.reinitialize_command('sdist')
if self.use_bzip2: if self.use_bzip2:
sdist.formats = ['bztar'] sdist.formats = ['bztar']
else: else:
......
...@@ -56,8 +56,8 @@ class bdist_wininst (Command): ...@@ -56,8 +56,8 @@ class bdist_wininst (Command):
if self.distribution.has_ext_modules(): if self.distribution.has_ext_modules():
short_version = sys.version[:3] short_version = sys.version[:3]
if self.target_version and self.target_version != short_version: if self.target_version and self.target_version != short_version:
raise DistutilsOptionError ("target version can only be" + raise DistutilsOptionError, \
short_version) "target version can only be" + short_version
self.target_version = short_version self.target_version = short_version
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
...@@ -73,7 +73,7 @@ class bdist_wininst (Command): ...@@ -73,7 +73,7 @@ class bdist_wininst (Command):
("distribution contains extensions and/or C libraries; " ("distribution contains extensions and/or C libraries; "
"must be compiled on a Windows 32 platform") "must be compiled on a Windows 32 platform")
self.run_command ('build') self.run_command('build')
install = self.reinitialize_command('install') install = self.reinitialize_command('install')
install.root = self.bdist_dir install.root = self.bdist_dir
...@@ -91,7 +91,7 @@ class bdist_wininst (Command): ...@@ -91,7 +91,7 @@ class bdist_wininst (Command):
install_lib.ensure_finalized() install_lib.ensure_finalized()
self.announce ("installing to %s" % self.bdist_dir) self.announce("installing to %s" % self.bdist_dir)
install.ensure_finalized() install.ensure_finalized()
install.run() install.run()
...@@ -103,24 +103,24 @@ class bdist_wininst (Command): ...@@ -103,24 +103,24 @@ class bdist_wininst (Command):
# Our archive MUST be relative to sys.prefix, which is the # Our archive MUST be relative to sys.prefix, which is the
# same as install_purelib in the 'nt' scheme. # same as install_purelib in the 'nt' scheme.
root_dir = os.path.normpath (install.install_purelib) root_dir = os.path.normpath(install.install_purelib)
# Sanity check: Make sure everything is included # Sanity check: Make sure everything is included
for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
attrname = 'install_' + key attrname = 'install_' + key
install_x = getattr (install, attrname) install_x = getattr(install, attrname)
# (Use normpath so that we can string.find to look for # (Use normpath so that we can string.find to look for
# subdirectories) # subdirectories)
install_x = os.path.normpath (install_x) install_x = os.path.normpath(install_x)
if string.find (install_x, root_dir) != 0: if string.find(install_x, root_dir) != 0:
raise DistutilsInternalError \ raise DistutilsInternalError \
("'%s' not included in install_lib" % key) ("'%s' not included in install_lib" % key)
arcname = self.make_archive (archive_basename, "zip", arcname = self.make_archive(archive_basename, "zip",
root_dir=root_dir) root_dir=root_dir)
self.create_exe (arcname, fullname) self.create_exe(arcname, fullname)
if not self.keep_temp: if not self.keep_temp:
remove_tree (self.bdist_dir, self.verbose, self.dry_run) remove_tree(self.bdist_dir, self.verbose, self.dry_run)
# run() # run()
...@@ -133,37 +133,37 @@ class bdist_wininst (Command): ...@@ -133,37 +133,37 @@ class bdist_wininst (Command):
# Write the [metadata] section. Values are written with # Write the [metadata] section. Values are written with
# repr()[1:-1], so they do not contain unprintable characters, and # repr()[1:-1], so they do not contain unprintable characters, and
# are not surrounded by quote chars. # are not surrounded by quote chars.
lines.append ("[metadata]") lines.append("[metadata]")
# 'info' will be displayed in the installer's dialog box, # 'info' will be displayed in the installer's dialog box,
# describing the items to be installed. # describing the items to be installed.
info = (metadata.long_description or '') + '\n' info = (metadata.long_description or '') + '\n'
for name in dir (metadata): for name in dir(metadata):
if (name != 'long_description'): if (name != 'long_description'):
data = getattr (metadata, name) data = getattr(metadata, name)
if data: if data:
info = info + ("\n %s: %s" % \ info = info + ("\n %s: %s" % \
(string.capitalize (name), data)) (string.capitalize(name), data))
lines.append ("%s=%s" % (name, repr (data)[1:-1])) lines.append("%s=%s" % (name, repr(data)[1:-1]))
# The [setup] section contains entries controlling # The [setup] section contains entries controlling
# the installer runtime. # the installer runtime.
lines.append ("\n[Setup]") lines.append("\n[Setup]")
lines.append ("info=%s" % repr (info)[1:-1]) lines.append("info=%s" % repr(info)[1:-1])
lines.append ("target_compile=%d" % (not self.no_target_compile)) lines.append("target_compile=%d" % (not self.no_target_compile))
lines.append ("target_optimize=%d" % (not self.no_target_optimize)) lines.append("target_optimize=%d" % (not self.no_target_optimize))
if self.target_version: if self.target_version:
lines.append ("target_version=%s" % self.target_version) lines.append("target_version=%s" % self.target_version)
title = self.distribution.get_fullname() title = self.distribution.get_fullname()
lines.append ("title=%s" % repr (title)[1:-1]) lines.append("title=%s" % repr(title)[1:-1])
import time import time
import distutils import distutils
build_info = "Build %s with distutils-%s" % \ build_info = "Build %s with distutils-%s" % \
(time.ctime (time.time()), distutils.__version__) (time.ctime(time.time()), distutils.__version__)
lines.append ("build_info=%s" % build_info) lines.append("build_info=%s" % build_info)
return string.join (lines, "\n") return string.join(lines, "\n")
# get_inidata() # get_inidata()
...@@ -183,36 +183,36 @@ class bdist_wininst (Command): ...@@ -183,36 +183,36 @@ class bdist_wininst (Command):
else: else:
installer_name = os.path.join(self.dist_dir, installer_name = os.path.join(self.dist_dir,
"%s.win32.exe" % fullname) "%s.win32.exe" % fullname)
self.announce ("creating %s" % installer_name) self.announce("creating %s" % installer_name)
file = open (installer_name, "wb") file = open(installer_name, "wb")
file.write (self.get_exe_bytes ()) file.write(self.get_exe_bytes())
file.write (cfgdata) file.write(cfgdata)
header = struct.pack ("<ii", header = struct.pack("<ii",
0x12345679, # tag 0x12345679, # tag
len (cfgdata)) # length len(cfgdata)) # length
file.write (header) file.write(header)
file.write (open (arcname, "rb").read()) file.write(open(arcname, "rb").read())
# create_exe() # create_exe()
def get_exe_bytes (self): def get_exe_bytes (self):
import base64 import base64
return base64.decodestring (EXEDATA) return base64.decodestring(EXEDATA)
# class bdist_wininst # class bdist_wininst
if __name__ == '__main__': if __name__ == '__main__':
# recreate EXEDATA from wininst.exe by rewriting this file # recreate EXEDATA from wininst.exe by rewriting this file
import re, base64 import re, base64
moddata = open ("bdist_wininst.py", "r").read() moddata = open("bdist_wininst.py", "r").read()
exedata = open ("../../misc/wininst.exe", "rb").read() exedata = open("../../misc/wininst.exe", "rb").read()
print "wininst.exe length is %d bytes" % len (exedata) print "wininst.exe length is %d bytes" % len(exedata)
print "wininst.exe encoded length is %d bytes" % len (base64.encodestring (exedata)) print "wininst.exe encoded length is %d bytes" % len(base64.encodestring(exedata))
exp = re.compile ('EXE'+'DATA = """\\\\(\n.*)*\n"""', re.M) exp = re.compile('EXE'+'DATA = """\\\\(\n.*)*\n"""', re.M)
data = exp.sub ('EXE' + 'DATA = """\\\\\n%s"""' % data = exp.sub('EXE' + 'DATA = """\\\\\n%s"""' %
base64.encodestring (exedata), moddata) base64.encodestring(exedata), moddata)
open ("bdist_wininst.py", "w").write (data) open("bdist_wininst.py", "w").write(data)
print "bdist_wininst.py recreated" print "bdist_wininst.py recreated"
EXEDATA = """\ EXEDATA = """\
......
...@@ -70,9 +70,9 @@ class build (Command): ...@@ -70,9 +70,9 @@ class build (Command):
# 'lib.<plat>' under the base build directory. We only use one of # 'lib.<plat>' under the base build directory. We only use one of
# them for a given distribution, though -- # them for a given distribution, though --
if self.build_purelib is None: if self.build_purelib is None:
self.build_purelib = os.path.join (self.build_base, 'lib') self.build_purelib = os.path.join(self.build_base, 'lib')
if self.build_platlib is None: if self.build_platlib is None:
self.build_platlib = os.path.join (self.build_base, self.build_platlib = os.path.join(self.build_base,
'lib' + plat_specifier) 'lib' + plat_specifier)
# 'build_lib' is the actual directory that we will use for this # 'build_lib' is the actual directory that we will use for this
...@@ -87,10 +87,10 @@ class build (Command): ...@@ -87,10 +87,10 @@ class build (Command):
# 'build_temp' -- temporary directory for compiler turds, # 'build_temp' -- temporary directory for compiler turds,
# "build/temp.<plat>" # "build/temp.<plat>"
if self.build_temp is None: if self.build_temp is None:
self.build_temp = os.path.join (self.build_base, self.build_temp = os.path.join(self.build_base,
'temp' + plat_specifier) 'temp' + plat_specifier)
if self.build_scripts is None: if self.build_scripts is None:
self.build_scripts = os.path.join (self.build_base, 'scripts') self.build_scripts = os.path.join(self.build_base, 'scripts')
# finalize_options () # finalize_options ()
......
...@@ -80,7 +80,7 @@ class build_clib (Command): ...@@ -80,7 +80,7 @@ class build_clib (Command):
# I think that C libraries are really just temporary build # I think that C libraries are really just temporary build
# by-products, at least from the point of view of building Python # by-products, at least from the point of view of building Python
# extensions -- but I want to keep my options open. # extensions -- but I want to keep my options open.
self.set_undefined_options ('build', self.set_undefined_options('build',
('build_temp', 'build_clib'), ('build_temp', 'build_clib'),
('build_temp', 'build_temp'), ('build_temp', 'build_temp'),
('compiler', 'compiler'), ('compiler', 'compiler'),
...@@ -89,12 +89,12 @@ class build_clib (Command): ...@@ -89,12 +89,12 @@ class build_clib (Command):
self.libraries = self.distribution.libraries self.libraries = self.distribution.libraries
if self.libraries: if self.libraries:
self.check_library_list (self.libraries) self.check_library_list(self.libraries)
if self.include_dirs is None: if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or [] self.include_dirs = self.distribution.include_dirs or []
if type (self.include_dirs) is StringType: if type(self.include_dirs) is StringType:
self.include_dirs = string.split (self.include_dirs, self.include_dirs = string.split(self.include_dirs,
os.pathsep) os.pathsep)
# XXX same as for build_ext -- what about 'self.define' and # XXX same as for build_ext -- what about 'self.define' and
...@@ -110,23 +110,23 @@ class build_clib (Command): ...@@ -110,23 +110,23 @@ class build_clib (Command):
# Yech -- this is cut 'n pasted from build_ext.py! # Yech -- this is cut 'n pasted from build_ext.py!
from distutils.ccompiler import new_compiler from distutils.ccompiler import new_compiler
self.compiler = new_compiler (compiler=self.compiler, self.compiler = new_compiler(compiler=self.compiler,
verbose=self.verbose, verbose=self.verbose,
dry_run=self.dry_run, dry_run=self.dry_run,
force=self.force) force=self.force)
customize_compiler(self.compiler) customize_compiler(self.compiler)
if self.include_dirs is not None: if self.include_dirs is not None:
self.compiler.set_include_dirs (self.include_dirs) self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None: if self.define is not None:
# 'define' option is a list of (name,value) tuples # 'define' option is a list of (name,value) tuples
for (name,value) in self.define: for (name,value) in self.define:
self.compiler.define_macro (name, value) self.compiler.define_macro(name, value)
if self.undef is not None: if self.undef is not None:
for macro in self.undef: for macro in self.undef:
self.compiler.undefine_macro (macro) self.compiler.undefine_macro(macro)
self.build_libraries (self.libraries) self.build_libraries(self.libraries)
# run() # run()
...@@ -141,16 +141,16 @@ class build_clib (Command): ...@@ -141,16 +141,16 @@ class build_clib (Command):
# Yechh, blecch, ackk: this is ripped straight out of build_ext.py, # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,
# with only names changed to protect the innocent! # with only names changed to protect the innocent!
if type (libraries) is not ListType: if type(libraries) is not ListType:
raise DistutilsSetupError, \ raise DistutilsSetupError, \
"'libraries' option must be a list of tuples" "'libraries' option must be a list of tuples"
for lib in libraries: for lib in libraries:
if type (lib) is not TupleType and len (lib) != 2: if type(lib) is not TupleType and len(lib) != 2:
raise DistutilsSetupError, \ raise DistutilsSetupError, \
"each element of 'libraries' must a 2-tuple" "each element of 'libraries' must a 2-tuple"
if type (lib[0]) is not StringType: if type(lib[0]) is not StringType:
raise DistutilsSetupError, \ raise DistutilsSetupError, \
"first element of each tuple in 'libraries' " + \ "first element of each tuple in 'libraries' " + \
"must be a string (the library name)" "must be a string (the library name)"
...@@ -160,7 +160,7 @@ class build_clib (Command): ...@@ -160,7 +160,7 @@ class build_clib (Command):
"may not contain directory separators") % \ "may not contain directory separators") % \
lib[0] lib[0]
if type (lib[1]) is not DictionaryType: if type(lib[1]) is not DictionaryType:
raise DistutilsSetupError, \ raise DistutilsSetupError, \
"second element of each tuple in 'libraries' " + \ "second element of each tuple in 'libraries' " + \
"must be a dictionary (build info)" "must be a dictionary (build info)"
...@@ -178,7 +178,7 @@ class build_clib (Command): ...@@ -178,7 +178,7 @@ class build_clib (Command):
lib_names = [] lib_names = []
for (lib_name, build_info) in self.libraries: for (lib_name, build_info) in self.libraries:
lib_names.append (lib_name) lib_names.append(lib_name)
return lib_names return lib_names
# get_library_names () # get_library_names ()
...@@ -189,22 +189,22 @@ class build_clib (Command): ...@@ -189,22 +189,22 @@ class build_clib (Command):
compiler = self.compiler compiler = self.compiler
for (lib_name, build_info) in libraries: for (lib_name, build_info) in libraries:
sources = build_info.get ('sources') sources = build_info.get('sources')
if sources is None or type (sources) not in (ListType, TupleType): if sources is None or type(sources) not in (ListType, TupleType):
raise DistutilsSetupError, \ raise DistutilsSetupError, \
("in 'libraries' option (library '%s'), " + ("in 'libraries' option (library '%s'), " +
"'sources' must be present and must be " + "'sources' must be present and must be " +
"a list of source filenames") % lib_name "a list of source filenames") % lib_name
sources = list (sources) sources = list(sources)
self.announce ("building '%s' library" % lib_name) self.announce("building '%s' library" % lib_name)
# First, compile the source code to object files in the library # First, compile the source code to object files in the library
# directory. (This should probably change to putting object # directory. (This should probably change to putting object
# files in a temporary build directory.) # files in a temporary build directory.)
macros = build_info.get ('macros') macros = build_info.get('macros')
include_dirs = build_info.get ('include_dirs') include_dirs = build_info.get('include_dirs')
objects = self.compiler.compile (sources, objects = self.compiler.compile(sources,
output_dir=self.build_temp, output_dir=self.build_temp,
macros=macros, macros=macros,
include_dirs=include_dirs, include_dirs=include_dirs,
...@@ -213,7 +213,7 @@ class build_clib (Command): ...@@ -213,7 +213,7 @@ class build_clib (Command):
# Now "link" the object files together into a static library. # Now "link" the object files together into a static library.
# (On Unix at least, this isn't really linking -- it just # (On Unix at least, this isn't really linking -- it just
# builds an archive. Whatever.) # builds an archive. Whatever.)
self.compiler.create_static_lib (objects, lib_name, self.compiler.create_static_lib(objects, lib_name,
output_dir=self.build_clib, output_dir=self.build_clib,
debug=self.debug) debug=self.debug)
......
...@@ -112,7 +112,7 @@ class build_ext (Command): ...@@ -112,7 +112,7 @@ class build_ext (Command):
def finalize_options (self): def finalize_options (self):
from distutils import sysconfig from distutils import sysconfig
self.set_undefined_options ('build', self.set_undefined_options('build',
('build_lib', 'build_lib'), ('build_lib', 'build_lib'),
('build_temp', 'build_temp'), ('build_temp', 'build_temp'),
('compiler', 'compiler'), ('compiler', 'compiler'),
...@@ -131,17 +131,16 @@ class build_ext (Command): ...@@ -131,17 +131,16 @@ class build_ext (Command):
plat_py_include = sysconfig.get_python_inc(plat_specific=1) plat_py_include = sysconfig.get_python_inc(plat_specific=1)
if self.include_dirs is None: if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or [] self.include_dirs = self.distribution.include_dirs or []
if type (self.include_dirs) is StringType: if type(self.include_dirs) is StringType:
self.include_dirs = string.split (self.include_dirs, self.include_dirs = string.split(self.include_dirs, os.pathsep)
os.pathsep)
# Put the Python "system" include dir at the end, so that # Put the Python "system" include dir at the end, so that
# any local include dirs take precedence. # any local include dirs take precedence.
self.include_dirs.append (py_include) self.include_dirs.append(py_include)
if plat_py_include != py_include: if plat_py_include != py_include:
self.include_dirs.append (plat_py_include) self.include_dirs.append(plat_py_include)
if type (self.libraries) is StringType: if type(self.libraries) is StringType:
self.libraries = [self.libraries] self.libraries = [self.libraries]
# Life is easier if we're not forever checking for None, so # Life is easier if we're not forever checking for None, so
...@@ -157,11 +156,11 @@ class build_ext (Command): ...@@ -157,11 +156,11 @@ class build_ext (Command):
# for Release and Debug builds. # for Release and Debug builds.
# also Python's library directory must be appended to library_dirs # also Python's library directory must be appended to library_dirs
if os.name == 'nt': if os.name == 'nt':
self.library_dirs.append (os.path.join(sys.exec_prefix, 'libs')) self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
if self.debug: if self.debug:
self.build_temp = os.path.join (self.build_temp, "Debug") self.build_temp = os.path.join(self.build_temp, "Debug")
else: else:
self.build_temp = os.path.join (self.build_temp, "Release") self.build_temp = os.path.join(self.build_temp, "Release")
# finalize_options () # finalize_options ()
...@@ -188,13 +187,13 @@ class build_ext (Command): ...@@ -188,13 +187,13 @@ class build_ext (Command):
# directory where we put them is in the library search path for # directory where we put them is in the library search path for
# linking extensions. # linking extensions.
if self.distribution.has_c_libraries(): if self.distribution.has_c_libraries():
build_clib = self.get_finalized_command ('build_clib') build_clib = self.get_finalized_command('build_clib')
self.libraries.extend (build_clib.get_library_names() or []) self.libraries.extend(build_clib.get_library_names() or [])
self.library_dirs.append (build_clib.build_clib) self.library_dirs.append(build_clib.build_clib)
# Setup the CCompiler object that we'll use to do all the # Setup the CCompiler object that we'll use to do all the
# compiling and linking # compiling and linking
self.compiler = new_compiler (compiler=self.compiler, self.compiler = new_compiler(compiler=self.compiler,
verbose=self.verbose, verbose=self.verbose,
dry_run=self.dry_run, dry_run=self.dry_run,
force=self.force) force=self.force)
...@@ -205,25 +204,25 @@ class build_ext (Command): ...@@ -205,25 +204,25 @@ class build_ext (Command):
# that CCompiler object -- that way, they automatically apply to # that CCompiler object -- that way, they automatically apply to
# all compiling and linking done here. # all compiling and linking done here.
if self.include_dirs is not None: if self.include_dirs is not None:
self.compiler.set_include_dirs (self.include_dirs) self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None: if self.define is not None:
# 'define' option is a list of (name,value) tuples # 'define' option is a list of (name,value) tuples
for (name,value) in self.define: for (name,value) in self.define:
self.compiler.define_macro (name, value) self.compiler.define_macro(name, value)
if self.undef is not None: if self.undef is not None:
for macro in self.undef: for macro in self.undef:
self.compiler.undefine_macro (macro) self.compiler.undefine_macro(macro)
if self.libraries is not None: if self.libraries is not None:
self.compiler.set_libraries (self.libraries) self.compiler.set_libraries(self.libraries)
if self.library_dirs is not None: if self.library_dirs is not None:
self.compiler.set_library_dirs (self.library_dirs) self.compiler.set_library_dirs(self.library_dirs)
if self.rpath is not None: if self.rpath is not None:
self.compiler.set_runtime_library_dirs (self.rpath) self.compiler.set_runtime_library_dirs(self.rpath)
if self.link_objects is not None: if self.link_objects is not None:
self.compiler.set_link_objects (self.link_objects) self.compiler.set_link_objects(self.link_objects)
# Now actually compile and link everything. # Now actually compile and link everything.
self.build_extensions () self.build_extensions()
# run () # run ()
...@@ -320,7 +319,7 @@ class build_ext (Command): ...@@ -320,7 +319,7 @@ class build_ext (Command):
# Wouldn't it be neat if we knew the names of header files too... # Wouldn't it be neat if we knew the names of header files too...
for ext in self.extensions: for ext in self.extensions:
filenames.extend (ext.sources) filenames.extend(ext.sources)
return filenames return filenames
...@@ -330,15 +329,15 @@ class build_ext (Command): ...@@ -330,15 +329,15 @@ class build_ext (Command):
# Sanity check the 'extensions' list -- can't assume this is being # Sanity check the 'extensions' list -- can't assume this is being
# done in the same run as a 'build_extensions()' call (in fact, we # done in the same run as a 'build_extensions()' call (in fact, we
# can probably assume that it *isn't*!). # can probably assume that it *isn't*!).
self.check_extensions_list (self.extensions) self.check_extensions_list(self.extensions)
# And build the list of output (built) filenames. Note that this # And build the list of output (built) filenames. Note that this
# ignores the 'inplace' flag, and assumes everything goes in the # ignores the 'inplace' flag, and assumes everything goes in the
# "build" tree. # "build" tree.
outputs = [] outputs = []
for ext in self.extensions: for ext in self.extensions:
fullname = self.get_ext_fullname (ext.name) fullname = self.get_ext_fullname(ext.name)
outputs.append (os.path.join (self.build_lib, outputs.append(os.path.join(self.build_lib,
self.get_ext_filename(fullname))) self.get_ext_filename(fullname)))
return outputs return outputs
...@@ -348,40 +347,40 @@ class build_ext (Command): ...@@ -348,40 +347,40 @@ class build_ext (Command):
def build_extensions (self): def build_extensions (self):
# First, sanity-check the 'extensions' list # First, sanity-check the 'extensions' list
self.check_extensions_list (self.extensions) self.check_extensions_list(self.extensions)
for ext in self.extensions: for ext in self.extensions:
sources = ext.sources sources = ext.sources
if sources is None or type (sources) not in (ListType, TupleType): if sources is None or type(sources) not in (ListType, TupleType):
raise DistutilsSetupError, \ raise DistutilsSetupError, \
("in 'ext_modules' option (extension '%s'), " + ("in 'ext_modules' option (extension '%s'), " +
"'sources' must be present and must be " + "'sources' must be present and must be " +
"a list of source filenames") % ext.name "a list of source filenames") % ext.name
sources = list (sources) sources = list(sources)
fullname = self.get_ext_fullname (ext.name) fullname = self.get_ext_fullname(ext.name)
if self.inplace: if self.inplace:
# ignore build-lib -- put the compiled extension into # ignore build-lib -- put the compiled extension into
# the source tree along with pure Python modules # the source tree along with pure Python modules
modpath = string.split (fullname, '.') modpath = string.split(fullname, '.')
package = string.join (modpath[0:-1], '.') package = string.join(modpath[0:-1], '.')
base = modpath[-1] base = modpath[-1]
build_py = self.get_finalized_command ('build_py') build_py = self.get_finalized_command('build_py')
package_dir = build_py.get_package_dir (package) package_dir = build_py.get_package_dir(package)
ext_filename = os.path.join (package_dir, ext_filename = os.path.join(package_dir,
self.get_ext_filename(base)) self.get_ext_filename(base))
else: else:
ext_filename = os.path.join (self.build_lib, ext_filename = os.path.join(self.build_lib,
self.get_ext_filename(fullname)) self.get_ext_filename(fullname))
if not (self.force or newer_group(sources, ext_filename, 'newer')): if not (self.force or newer_group(sources, ext_filename, 'newer')):
self.announce ("skipping '%s' extension (up-to-date)" % self.announce("skipping '%s' extension (up-to-date)" %
ext.name) ext.name)
continue # 'for' loop over all extensions continue # 'for' loop over all extensions
else: else:
self.announce ("building '%s' extension" % ext.name) self.announce("building '%s' extension" % ext.name)
# First, scan the sources for SWIG definition files (.i), run # First, scan the sources for SWIG definition files (.i), run
# SWIG on 'em to create .c files, and modify the sources list # SWIG on 'em to create .c files, and modify the sources list
...@@ -416,7 +415,7 @@ class build_ext (Command): ...@@ -416,7 +415,7 @@ class build_ext (Command):
if os.environ.has_key('CFLAGS'): if os.environ.has_key('CFLAGS'):
extra_args.extend(string.split(os.environ['CFLAGS'])) extra_args.extend(string.split(os.environ['CFLAGS']))
objects = self.compiler.compile (sources, objects = self.compiler.compile(sources,
output_dir=self.build_temp, output_dir=self.build_temp,
macros=macros, macros=macros,
include_dirs=ext.include_dirs, include_dirs=ext.include_dirs,
...@@ -427,11 +426,11 @@ class build_ext (Command): ...@@ -427,11 +426,11 @@ class build_ext (Command):
# of course, first we have to figure out all the other things # of course, first we have to figure out all the other things
# that go into the mix. # that go into the mix.
if ext.extra_objects: if ext.extra_objects:
objects.extend (ext.extra_objects) objects.extend(ext.extra_objects)
extra_args = ext.extra_link_args or [] extra_args = ext.extra_link_args or []
self.compiler.link_shared_object ( self.compiler.link_shared_object(
objects, ext_filename, objects, ext_filename,
libraries=self.get_libraries(ext), libraries=self.get_libraries(ext),
library_dirs=ext.library_dirs, library_dirs=ext.library_dirs,
...@@ -481,11 +480,11 @@ class build_ext (Command): ...@@ -481,11 +480,11 @@ class build_ext (Command):
swig = self.find_swig() swig = self.find_swig()
swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] swig_cmd = [swig, "-python", "-dnone", "-ISWIG"]
if self.swig_cpp: if self.swig_cpp:
swig_cmd.append ("-c++") swig_cmd.append("-c++")
for source in swig_sources: for source in swig_sources:
target = swig_targets[source] target = swig_targets[source]
self.announce ("swigging %s to %s" % (source, target)) self.announce("swigging %s to %s" % (source, target))
self.spawn(swig_cmd + ["-o", target, source]) self.spawn(swig_cmd + ["-o", target, source])
return new_sources return new_sources
...@@ -507,7 +506,7 @@ class build_ext (Command): ...@@ -507,7 +506,7 @@ class build_ext (Command):
# if not, act like Unix and assume it's in the PATH. # if not, act like Unix and assume it's in the PATH.
for vers in ("1.3", "1.2", "1.1"): for vers in ("1.3", "1.2", "1.1"):
fn = os.path.join("c:\\swig%s" % vers, "swig.exe") fn = os.path.join("c:\\swig%s" % vers, "swig.exe")
if os.path.isfile (fn): if os.path.isfile(fn):
return fn return fn
else: else:
return "swig.exe" return "swig.exe"
...@@ -535,12 +534,12 @@ class build_ext (Command): ...@@ -535,12 +534,12 @@ class build_ext (Command):
""" """
from distutils.sysconfig import get_config_var from distutils.sysconfig import get_config_var
ext_path = string.split (ext_name, '.') ext_path = string.split(ext_name, '.')
# extensions in debug_mode are named 'module_d.pyd' under windows # extensions in debug_mode are named 'module_d.pyd' under windows
so_ext = get_config_var('SO') so_ext = get_config_var('SO')
if os.name == 'nt' and self.debug: if os.name == 'nt' and self.debug:
return apply (os.path.join, ext_path) + '_d' + so_ext return apply(os.path.join, ext_path) + '_d' + so_ext
return apply (os.path.join, ext_path) + so_ext return apply(os.path.join, ext_path) + so_ext
def get_export_symbols (self, ext): def get_export_symbols (self, ext):
"""Return the list of symbols that a shared extension has to """Return the list of symbols that a shared extension has to
......
...@@ -34,7 +34,7 @@ class build_py (Command): ...@@ -34,7 +34,7 @@ class build_py (Command):
self.force = None self.force = None
def finalize_options (self): def finalize_options (self):
self.set_undefined_options ('build', self.set_undefined_options('build',
('build_lib', 'build_lib'), ('build_lib', 'build_lib'),
('force', 'force')) ('force', 'force'))
...@@ -83,9 +83,9 @@ class build_py (Command): ...@@ -83,9 +83,9 @@ class build_py (Command):
# Now we're down to two cases: 'py_modules' only and 'packages' only. # Now we're down to two cases: 'py_modules' only and 'packages' only.
if self.py_modules: if self.py_modules:
self.build_modules () self.build_modules()
else: else:
self.build_packages () self.build_packages()
# run () # run ()
...@@ -95,24 +95,24 @@ class build_py (Command): ...@@ -95,24 +95,24 @@ class build_py (Command):
distribution, where package 'package' should be found distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any).""" (at least according to the 'package_dir' option, if any)."""
path = string.split (package, '.') path = string.split(package, '.')
if not self.package_dir: if not self.package_dir:
if path: if path:
return apply (os.path.join, path) return apply(os.path.join, path)
else: else:
return '' return ''
else: else:
tail = [] tail = []
while path: while path:
try: try:
pdir = self.package_dir[string.join (path, '.')] pdir = self.package_dir[string.join(path, '.')]
except KeyError: except KeyError:
tail.insert (0, path[-1]) tail.insert(0, path[-1])
del path[-1] del path[-1]
else: else:
tail.insert (0, pdir) tail.insert(0, pdir)
return apply (os.path.join, tail) return apply(os.path.join, tail)
else: else:
# Oops, got all the way through 'path' without finding a # Oops, got all the way through 'path' without finding a
# match in package_dir. If package_dir defines a directory # match in package_dir. If package_dir defines a directory
...@@ -126,7 +126,7 @@ class build_py (Command): ...@@ -126,7 +126,7 @@ class build_py (Command):
tail.insert(0, pdir) tail.insert(0, pdir)
if tail: if tail:
return apply (os.path.join, tail) return apply(os.path.join, tail)
else: else:
return '' return ''
...@@ -140,21 +140,21 @@ class build_py (Command): ...@@ -140,21 +140,21 @@ class build_py (Command):
# my "empty string means current dir" convention, so we have to # my "empty string means current dir" convention, so we have to
# circumvent them. # circumvent them.
if package_dir != "": if package_dir != "":
if not os.path.exists (package_dir): if not os.path.exists(package_dir):
raise DistutilsFileError, \ raise DistutilsFileError, \
"package directory '%s' does not exist" % package_dir "package directory '%s' does not exist" % package_dir
if not os.path.isdir (package_dir): if not os.path.isdir(package_dir):
raise DistutilsFileError, \ raise DistutilsFileError, \
("supposed package directory '%s' exists, " + ("supposed package directory '%s' exists, " +
"but is not a directory") % package_dir "but is not a directory") % package_dir
# Require __init__.py for all but the "root package" # Require __init__.py for all but the "root package"
if package: if package:
init_py = os.path.join (package_dir, "__init__.py") init_py = os.path.join(package_dir, "__init__.py")
if os.path.isfile (init_py): if os.path.isfile(init_py):
return init_py return init_py
else: else:
self.warn (("package init file '%s' not found " + self.warn(("package init file '%s' not found " +
"(or not a regular file)") % init_py) "(or not a regular file)") % init_py)
# Either not in a package at all (__init__.py not expected), or # Either not in a package at all (__init__.py not expected), or
...@@ -165,8 +165,8 @@ class build_py (Command): ...@@ -165,8 +165,8 @@ class build_py (Command):
def check_module (self, module, module_file): def check_module (self, module, module_file):
if not os.path.isfile (module_file): if not os.path.isfile(module_file):
self.warn ("file %s (for module %s) not found" % self.warn("file %s (for module %s) not found" %
(module_file, module)) (module_file, module))
return 0 return 0
else: else:
...@@ -176,16 +176,16 @@ class build_py (Command): ...@@ -176,16 +176,16 @@ class build_py (Command):
def find_package_modules (self, package, package_dir): def find_package_modules (self, package, package_dir):
self.check_package (package, package_dir) self.check_package(package, package_dir)
module_files = glob (os.path.join (package_dir, "*.py")) module_files = glob(os.path.join(package_dir, "*.py"))
modules = [] modules = []
setup_script = os.path.abspath(self.distribution.script_name) setup_script = os.path.abspath(self.distribution.script_name)
for f in module_files: for f in module_files:
abs_f = os.path.abspath (f) abs_f = os.path.abspath(f)
if abs_f != setup_script: if abs_f != setup_script:
module = os.path.splitext (os.path.basename (f))[0] module = os.path.splitext(os.path.basename(f))[0]
modules.append ((package, module, f)) modules.append((package, module, f))
else: else:
self.debug_print("excluding %s" % setup_script) self.debug_print("excluding %s" % setup_script)
return modules return modules
...@@ -218,18 +218,18 @@ class build_py (Command): ...@@ -218,18 +218,18 @@ class build_py (Command):
# - don't check for __init__.py in directory for empty package # - don't check for __init__.py in directory for empty package
for module in self.py_modules: for module in self.py_modules:
path = string.split (module, '.') path = string.split(module, '.')
package = string.join(path[0:-1], '.') package = string.join(path[0:-1], '.')
module_base = path[-1] module_base = path[-1]
try: try:
(package_dir, checked) = packages[package] (package_dir, checked) = packages[package]
except KeyError: except KeyError:
package_dir = self.get_package_dir (package) package_dir = self.get_package_dir(package)
checked = 0 checked = 0
if not checked: if not checked:
init_py = self.check_package (package, package_dir) init_py = self.check_package(package, package_dir)
packages[package] = (package_dir, 1) packages[package] = (package_dir, 1)
if init_py: if init_py:
modules.append((package, "__init__", init_py)) modules.append((package, "__init__", init_py))
...@@ -237,11 +237,11 @@ class build_py (Command): ...@@ -237,11 +237,11 @@ class build_py (Command):
# XXX perhaps we should also check for just .pyc files # XXX perhaps we should also check for just .pyc files
# (so greedy closed-source bastards can distribute Python # (so greedy closed-source bastards can distribute Python
# modules too) # modules too)
module_file = os.path.join (package_dir, module_base + ".py") module_file = os.path.join(package_dir, module_base + ".py")
if not self.check_module (module, module_file): if not self.check_module(module, module_file):
continue continue
modules.append ((package, module_base, module_file)) modules.append((package, module_base, module_file))
return modules return modules
...@@ -256,13 +256,13 @@ class build_py (Command): ...@@ -256,13 +256,13 @@ class build_py (Command):
'find_package_modules()' do.""" 'find_package_modules()' do."""
if self.py_modules: if self.py_modules:
modules = self.find_modules () modules = self.find_modules()
else: else:
modules = [] modules = []
for package in self.packages: for package in self.packages:
package_dir = self.get_package_dir (package) package_dir = self.get_package_dir(package)
m = self.find_package_modules (package, package_dir) m = self.find_package_modules(package, package_dir)
modules.extend (m) modules.extend(m)
return modules return modules
...@@ -271,43 +271,43 @@ class build_py (Command): ...@@ -271,43 +271,43 @@ class build_py (Command):
def get_source_files (self): def get_source_files (self):
modules = self.find_all_modules () modules = self.find_all_modules()
filenames = [] filenames = []
for module in modules: for module in modules:
filenames.append (module[-1]) filenames.append(module[-1])
return filenames return filenames
def get_module_outfile (self, build_dir, package, module): def get_module_outfile (self, build_dir, package, module):
outfile_path = [build_dir] + list(package) + [module + ".py"] outfile_path = [build_dir] + list(package) + [module + ".py"]
return apply (os.path.join, outfile_path) return apply(os.path.join, outfile_path)
def get_outputs (self): def get_outputs (self):
modules = self.find_all_modules () modules = self.find_all_modules()
outputs = [] outputs = []
for (package, module, module_file) in modules: for (package, module, module_file) in modules:
package = string.split (package, '.') package = string.split(package, '.')
outputs.append (self.get_module_outfile (self.build_lib, outputs.append(self.get_module_outfile(self.build_lib,
package, module)) package, module))
return outputs return outputs
def build_module (self, module, module_file, package): def build_module (self, module, module_file, package):
if type (package) is StringType: if type(package) is StringType:
package = string.split (package, '.') package = string.split(package, '.')
elif type (package) not in (ListType, TupleType): elif type(package) not in (ListType, TupleType):
raise TypeError, \ raise TypeError, \
"'package' must be a string (dot-separated), list, or tuple" "'package' must be a string (dot-separated), list, or tuple"
# Now put the module source file into the "build" area -- this is # Now put the module source file into the "build" area -- this is
# easy, we just copy it somewhere under self.build_lib (the build # easy, we just copy it somewhere under self.build_lib (the build
# directory for Python source). # directory for Python source).
outfile = self.get_module_outfile (self.build_lib, package, module) outfile = self.get_module_outfile(self.build_lib, package, module)
dir = os.path.dirname (outfile) dir = os.path.dirname(outfile)
self.mkpath (dir) self.mkpath(dir)
return self.copy_file (module_file, outfile, preserve_mode=0) return self.copy_file(module_file, outfile, preserve_mode=0)
def build_modules (self): def build_modules (self):
...@@ -319,7 +319,7 @@ class build_py (Command): ...@@ -319,7 +319,7 @@ class build_py (Command):
# self.build_lib (the build directory for Python source). # self.build_lib (the build directory for Python source).
# (Actually, it gets copied to the directory for this package # (Actually, it gets copied to the directory for this package
# under self.build_lib.) # under self.build_lib.)
self.build_module (module, module_file, package) self.build_module(module, module_file, package)
# build_modules () # build_modules ()
...@@ -337,14 +337,14 @@ class build_py (Command): ...@@ -337,14 +337,14 @@ class build_py (Command):
# already know its package!), and 'module_file' is the path to # already know its package!), and 'module_file' is the path to
# the .py file, relative to the current directory # the .py file, relative to the current directory
# (ie. including 'package_dir'). # (ie. including 'package_dir').
package_dir = self.get_package_dir (package) package_dir = self.get_package_dir(package)
modules = self.find_package_modules (package, package_dir) modules = self.find_package_modules(package, package_dir)
# Now loop over the modules we found, "building" each one (just # Now loop over the modules we found, "building" each one (just
# copy it to self.build_lib). # copy it to self.build_lib).
for (package_, module, module_file) in modules: for (package_, module, module_file) in modules:
assert package == package_ assert package == package_
self.build_module (module, module_file, package) self.build_module(module, module_file, package)
# build_packages () # build_packages ()
......
...@@ -32,7 +32,7 @@ class build_scripts (Command): ...@@ -32,7 +32,7 @@ class build_scripts (Command):
self.outfiles = None self.outfiles = None
def finalize_options (self): def finalize_options (self):
self.set_undefined_options ('build', self.set_undefined_options('build',
('build_scripts', 'build_dir'), ('build_scripts', 'build_dir'),
('force', 'force')) ('force', 'force'))
self.scripts = self.distribution.scripts self.scripts = self.distribution.scripts
......
...@@ -50,10 +50,10 @@ class clean (Command): ...@@ -50,10 +50,10 @@ class clean (Command):
def run(self): def run(self):
# remove the build/temp.<plat> directory (unless it's already # remove the build/temp.<plat> directory (unless it's already
# gone) # gone)
if os.path.exists (self.build_temp): if os.path.exists(self.build_temp):
remove_tree (self.build_temp, self.verbose, self.dry_run) remove_tree(self.build_temp, self.verbose, self.dry_run)
else: else:
self.warn ("'%s' does not exist -- can't clean it" % self.warn("'%s' does not exist -- can't clean it" %
self.build_temp) self.build_temp)
if self.all: if self.all:
...@@ -61,18 +61,18 @@ class clean (Command): ...@@ -61,18 +61,18 @@ class clean (Command):
for directory in (self.build_lib, for directory in (self.build_lib,
self.bdist_base, self.bdist_base,
self.build_scripts): self.build_scripts):
if os.path.exists (directory): if os.path.exists(directory):
remove_tree (directory, self.verbose, self.dry_run) remove_tree(directory, self.verbose, self.dry_run)
else: else:
self.warn ("'%s' does not exist -- can't clean it" % self.warn("'%s' does not exist -- can't clean it" %
directory) directory)
# just for the heck of it, try to remove the base build directory: # just for the heck of it, try to remove the base build directory:
# we might have emptied it right now, but if not we don't care # we might have emptied it right now, but if not we don't care
if not self.dry_run: if not self.dry_run:
try: try:
os.rmdir (self.build_base) os.rmdir(self.build_base)
self.announce ("removing '%s'" % self.build_base) self.announce("removing '%s'" % self.build_base)
except OSError: except OSError:
pass pass
......
...@@ -87,7 +87,7 @@ class config (Command): ...@@ -87,7 +87,7 @@ class config (Command):
# import. # import.
from distutils.ccompiler import CCompiler, new_compiler from distutils.ccompiler import CCompiler, new_compiler
if not isinstance(self.compiler, CCompiler): if not isinstance(self.compiler, CCompiler):
self.compiler = new_compiler (compiler=self.compiler, self.compiler = new_compiler(compiler=self.compiler,
verbose=self.noisy, verbose=self.noisy,
dry_run=self.dry_run, dry_run=self.dry_run,
force=1) force=1)
......
...@@ -210,10 +210,10 @@ class install (Command): ...@@ -210,10 +210,10 @@ class install (Command):
"not both") "not both")
else: else:
if self.exec_prefix: if self.exec_prefix:
self.warn ("exec-prefix option ignored on this platform") self.warn("exec-prefix option ignored on this platform")
self.exec_prefix = None self.exec_prefix = None
if self.home: if self.home:
self.warn ("home option ignored on this platform") self.warn("home option ignored on this platform")
self.home = None self.home = None
# Now the interesting logic -- so interesting that we farm it out # Now the interesting logic -- so interesting that we farm it out
...@@ -224,14 +224,14 @@ class install (Command): ...@@ -224,14 +224,14 @@ class install (Command):
# install_{purelib,platlib,lib,scripts,data,...}, and the # install_{purelib,platlib,lib,scripts,data,...}, and the
# INSTALL_SCHEME dictionary above. Phew! # INSTALL_SCHEME dictionary above. Phew!
self.dump_dirs ("pre-finalize_{unix,other}") self.dump_dirs("pre-finalize_{unix,other}")
if os.name == 'posix': if os.name == 'posix':
self.finalize_unix () self.finalize_unix()
else: else:
self.finalize_other () self.finalize_other()
self.dump_dirs ("post-finalize_{unix,other}()") self.dump_dirs("post-finalize_{unix,other}()")
# Expand configuration variables, tilde, etc. in self.install_base # Expand configuration variables, tilde, etc. in self.install_base
# and self.install_platbase -- that way, we can use $base or # and self.install_platbase -- that way, we can use $base or
...@@ -250,9 +250,9 @@ class install (Command): ...@@ -250,9 +250,9 @@ class install (Command):
'sys_exec_prefix': exec_prefix, 'sys_exec_prefix': exec_prefix,
'exec_prefix': exec_prefix, 'exec_prefix': exec_prefix,
} }
self.expand_basedirs () self.expand_basedirs()
self.dump_dirs ("post-expand_basedirs()") self.dump_dirs("post-expand_basedirs()")
# Now define config vars for the base directories so we can expand # Now define config vars for the base directories so we can expand
# everything else. # everything else.
...@@ -262,13 +262,13 @@ class install (Command): ...@@ -262,13 +262,13 @@ class install (Command):
if DEBUG: if DEBUG:
from pprint import pprint from pprint import pprint
print "config vars:" print "config vars:"
pprint (self.config_vars) pprint(self.config_vars)
# Expand "~" and configuration variables in the installation # Expand "~" and configuration variables in the installation
# directories. # directories.
self.expand_dirs () self.expand_dirs()
self.dump_dirs ("post-expand_dirs()") self.dump_dirs("post-expand_dirs()")
# Pick the actual directory to install all modules to: either # Pick the actual directory to install all modules to: either
# install_purelib or install_platlib, depending on whether this # install_purelib or install_platlib, depending on whether this
...@@ -290,9 +290,9 @@ class install (Command): ...@@ -290,9 +290,9 @@ class install (Command):
# have to deal with 'extra_path', which is the hack for allowing # have to deal with 'extra_path', which is the hack for allowing
# non-packagized module distributions (hello, Numerical Python!) to # non-packagized module distributions (hello, Numerical Python!) to
# get their own directories. # get their own directories.
self.handle_extra_path () self.handle_extra_path()
self.install_libbase = self.install_lib # needed for .pth file self.install_libbase = self.install_lib # needed for .pth file
self.install_lib = os.path.join (self.install_lib, self.extra_dirs) self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
# If a new root directory was supplied, make all the installation # If a new root directory was supplied, make all the installation
# dirs relative to it. # dirs relative to it.
...@@ -300,10 +300,10 @@ class install (Command): ...@@ -300,10 +300,10 @@ class install (Command):
self.change_roots('libbase', 'lib', 'purelib', 'platlib', self.change_roots('libbase', 'lib', 'purelib', 'platlib',
'scripts', 'data', 'headers') 'scripts', 'data', 'headers')
self.dump_dirs ("after prepending root") self.dump_dirs("after prepending root")
# Find out the build directories, ie. where to install from. # Find out the build directories, ie. where to install from.
self.set_undefined_options ('build', self.set_undefined_options('build',
('build_base', 'build_base'), ('build_base', 'build_base'),
('build_lib', 'build_lib')) ('build_lib', 'build_lib'))
...@@ -321,8 +321,8 @@ class install (Command): ...@@ -321,8 +321,8 @@ class install (Command):
opt_name = opt[0] opt_name = opt[0]
if opt_name[-1] == "=": if opt_name[-1] == "=":
opt_name = opt_name[0:-1] opt_name = opt_name[0:-1]
opt_name = string.translate (opt_name, longopt_xlate) opt_name = string.translate(opt_name, longopt_xlate)
val = getattr (self, opt_name) val = getattr(self, opt_name)
print " %s: %s" % (opt_name, val) print " %s: %s" % (opt_name, val)
...@@ -342,15 +342,15 @@ class install (Command): ...@@ -342,15 +342,15 @@ class install (Command):
if self.home is not None: if self.home is not None:
self.install_base = self.install_platbase = self.home self.install_base = self.install_platbase = self.home
self.select_scheme ("unix_home") self.select_scheme("unix_home")
else: else:
if self.prefix is None: if self.prefix is None:
if self.exec_prefix is not None: if self.exec_prefix is not None:
raise DistutilsOptionError, \ raise DistutilsOptionError, \
"must not supply exec-prefix without prefix" "must not supply exec-prefix without prefix"
self.prefix = os.path.normpath (sys.prefix) self.prefix = os.path.normpath(sys.prefix)
self.exec_prefix = os.path.normpath (sys.exec_prefix) self.exec_prefix = os.path.normpath(sys.exec_prefix)
else: else:
if self.exec_prefix is None: if self.exec_prefix is None:
...@@ -358,7 +358,7 @@ class install (Command): ...@@ -358,7 +358,7 @@ class install (Command):
self.install_base = self.prefix self.install_base = self.prefix
self.install_platbase = self.exec_prefix self.install_platbase = self.exec_prefix
self.select_scheme ("unix_prefix") self.select_scheme("unix_prefix")
# finalize_unix () # finalize_unix ()
...@@ -366,11 +366,11 @@ class install (Command): ...@@ -366,11 +366,11 @@ class install (Command):
def finalize_other (self): # Windows and Mac OS for now def finalize_other (self): # Windows and Mac OS for now
if self.prefix is None: if self.prefix is None:
self.prefix = os.path.normpath (sys.prefix) self.prefix = os.path.normpath(sys.prefix)
self.install_base = self.install_platbase = self.prefix self.install_base = self.install_platbase = self.prefix
try: try:
self.select_scheme (os.name) self.select_scheme(os.name)
except KeyError: except KeyError:
raise DistutilsPlatformError, \ raise DistutilsPlatformError, \
"I don't know how to install stuff on '%s'" % os.name "I don't know how to install stuff on '%s'" % os.name
...@@ -389,21 +389,21 @@ class install (Command): ...@@ -389,21 +389,21 @@ class install (Command):
def _expand_attrs (self, attrs): def _expand_attrs (self, attrs):
for attr in attrs: for attr in attrs:
val = getattr (self, attr) val = getattr(self, attr)
if val is not None: if val is not None:
if os.name == 'posix': if os.name == 'posix':
val = os.path.expanduser (val) val = os.path.expanduser(val)
val = subst_vars (val, self.config_vars) val = subst_vars(val, self.config_vars)
setattr (self, attr, val) setattr(self, attr, val)
def expand_basedirs (self): def expand_basedirs (self):
self._expand_attrs (['install_base', self._expand_attrs(['install_base',
'install_platbase', 'install_platbase',
'root']) 'root'])
def expand_dirs (self): def expand_dirs (self):
self._expand_attrs (['install_purelib', self._expand_attrs(['install_purelib',
'install_platlib', 'install_platlib',
'install_lib', 'install_lib',
'install_headers', 'install_headers',
...@@ -423,12 +423,12 @@ class install (Command): ...@@ -423,12 +423,12 @@ class install (Command):
self.extra_path = self.distribution.extra_path self.extra_path = self.distribution.extra_path
if self.extra_path is not None: if self.extra_path is not None:
if type (self.extra_path) is StringType: if type(self.extra_path) is StringType:
self.extra_path = string.split (self.extra_path, ',') self.extra_path = string.split(self.extra_path, ',')
if len (self.extra_path) == 1: if len(self.extra_path) == 1:
path_file = extra_dirs = self.extra_path[0] path_file = extra_dirs = self.extra_path[0]
elif len (self.extra_path) == 2: elif len(self.extra_path) == 2:
(path_file, extra_dirs) = self.extra_path (path_file, extra_dirs) = self.extra_path
else: else:
raise DistutilsOptionError, \ raise DistutilsOptionError, \
...@@ -437,7 +437,7 @@ class install (Command): ...@@ -437,7 +437,7 @@ class install (Command):
# convert to local form in case Unix notation used (as it # convert to local form in case Unix notation used (as it
# should be in setup scripts) # should be in setup scripts)
extra_dirs = convert_path (extra_dirs) extra_dirs = convert_path(extra_dirs)
else: else:
path_file = None path_file = None
...@@ -463,21 +463,21 @@ class install (Command): ...@@ -463,21 +463,21 @@ class install (Command):
# Obviously have to build before we can install # Obviously have to build before we can install
if not self.skip_build: if not self.skip_build:
self.run_command ('build') self.run_command('build')
# Run all sub-commands (at least those that need to be run) # Run all sub-commands (at least those that need to be run)
for cmd_name in self.get_sub_commands(): for cmd_name in self.get_sub_commands():
self.run_command (cmd_name) self.run_command(cmd_name)
if self.path_file: if self.path_file:
self.create_path_file () self.create_path_file()
# write list of installed files, if requested. # write list of installed files, if requested.
if self.record: if self.record:
outputs = self.get_outputs() outputs = self.get_outputs()
if self.root: # strip any package prefix if self.root: # strip any package prefix
root_len = len(self.root) root_len = len(self.root)
for counter in xrange (len (outputs)): for counter in xrange(len(outputs)):
outputs[counter] = outputs[counter][root_len:] outputs[counter] = outputs[counter][root_len:]
self.execute(write_file, self.execute(write_file,
(self.record, outputs), (self.record, outputs),
...@@ -496,10 +496,10 @@ class install (Command): ...@@ -496,10 +496,10 @@ class install (Command):
# run () # run ()
def create_path_file (self): def create_path_file (self):
filename = os.path.join (self.install_libbase, filename = os.path.join(self.install_libbase,
self.path_file + ".pth") self.path_file + ".pth")
if self.install_path_file: if self.install_path_file:
self.execute (write_file, self.execute(write_file,
(filename, [self.extra_dirs]), (filename, [self.extra_dirs]),
"creating %s" % filename) "creating %s" % filename)
else: else:
...@@ -513,8 +513,8 @@ class install (Command): ...@@ -513,8 +513,8 @@ class install (Command):
# get the outputs of all its sub-commands. # get the outputs of all its sub-commands.
outputs = [] outputs = []
for cmd_name in self.get_sub_commands(): for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command (cmd_name) cmd = self.get_finalized_command(cmd_name)
outputs.extend (cmd.get_outputs()) outputs.extend(cmd.get_outputs())
return outputs return outputs
...@@ -522,8 +522,8 @@ class install (Command): ...@@ -522,8 +522,8 @@ class install (Command):
# XXX gee, this looks familiar ;-( # XXX gee, this looks familiar ;-(
inputs = [] inputs = []
for cmd_name in self.get_sub_commands(): for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command (cmd_name) cmd = self.get_finalized_command(cmd_name)
inputs.extend (cmd.get_inputs()) inputs.extend(cmd.get_inputs())
return inputs return inputs
......
...@@ -33,7 +33,7 @@ class install_scripts (Command): ...@@ -33,7 +33,7 @@ class install_scripts (Command):
def finalize_options (self): def finalize_options (self):
self.set_undefined_options('build', ('build_scripts', 'build_dir')) self.set_undefined_options('build', ('build_scripts', 'build_dir'))
self.set_undefined_options ('install', self.set_undefined_options('install',
('install_scripts', 'install_dir'), ('install_scripts', 'install_dir'),
('force', 'force'), ('force', 'force'),
('skip_build', 'skip_build'), ('skip_build', 'skip_build'),
......
...@@ -118,7 +118,7 @@ class sdist (Command): ...@@ -118,7 +118,7 @@ class sdist (Command):
"don't know how to create source distributions " + \ "don't know how to create source distributions " + \
"on platform %s" % os.name "on platform %s" % os.name
bad_format = archive_util.check_archive_formats (self.formats) bad_format = archive_util.check_archive_formats(self.formats)
if bad_format: if bad_format:
raise DistutilsOptionError, \ raise DistutilsOptionError, \
"unknown archive format '%s'" % bad_format "unknown archive format '%s'" % bad_format
...@@ -135,12 +135,12 @@ class sdist (Command): ...@@ -135,12 +135,12 @@ class sdist (Command):
# Ensure that all required meta-data is given; warn if not (but # Ensure that all required meta-data is given; warn if not (but
# don't die, it's not *that* serious!) # don't die, it's not *that* serious!)
self.check_metadata () self.check_metadata()
# Do whatever it takes to get the list of files to process # Do whatever it takes to get the list of files to process
# (process the manifest template, read an existing manifest, # (process the manifest template, read an existing manifest,
# whatever). File list is accumulated in 'self.filelist'. # whatever). File list is accumulated in 'self.filelist'.
self.get_file_list () self.get_file_list()
# If user just wanted us to regenerate the manifest, stop now. # If user just wanted us to regenerate the manifest, stop now.
if self.manifest_only: if self.manifest_only:
...@@ -148,7 +148,7 @@ class sdist (Command): ...@@ -148,7 +148,7 @@ class sdist (Command):
# Otherwise, go ahead and create the source distribution tarball, # Otherwise, go ahead and create the source distribution tarball,
# or zipfile, or whatever. # or zipfile, or whatever.
self.make_distribution () self.make_distribution()
def check_metadata (self): def check_metadata (self):
...@@ -161,23 +161,23 @@ class sdist (Command): ...@@ -161,23 +161,23 @@ class sdist (Command):
missing = [] missing = []
for attr in ('name', 'version', 'url'): for attr in ('name', 'version', 'url'):
if not (hasattr (metadata, attr) and getattr (metadata, attr)): if not (hasattr(metadata, attr) and getattr(metadata, attr)):
missing.append (attr) missing.append(attr)
if missing: if missing:
self.warn ("missing required meta-data: " + self.warn("missing required meta-data: " +
string.join (missing, ", ")) string.join(missing, ", "))
if metadata.author: if metadata.author:
if not metadata.author_email: if not metadata.author_email:
self.warn ("missing meta-data: if 'author' supplied, " + self.warn("missing meta-data: if 'author' supplied, " +
"'author_email' must be supplied too") "'author_email' must be supplied too")
elif metadata.maintainer: elif metadata.maintainer:
if not metadata.maintainer_email: if not metadata.maintainer_email:
self.warn ("missing meta-data: if 'maintainer' supplied, " + self.warn("missing meta-data: if 'maintainer' supplied, " +
"'maintainer_email' must be supplied too") "'maintainer_email' must be supplied too")
else: else:
self.warn ("missing meta-data: either (author and author_email) " + self.warn("missing meta-data: either (author and author_email) " +
"or (maintainer and maintainer_email) " + "or (maintainer and maintainer_email) " +
"must be supplied") "must be supplied")
...@@ -282,41 +282,41 @@ class sdist (Command): ...@@ -282,41 +282,41 @@ class sdist (Command):
standards = [('README', 'README.txt'), self.distribution.script_name] standards = [('README', 'README.txt'), self.distribution.script_name]
for fn in standards: for fn in standards:
if type (fn) is TupleType: if type(fn) is TupleType:
alts = fn alts = fn
got_it = 0 got_it = 0
for fn in alts: for fn in alts:
if os.path.exists (fn): if os.path.exists(fn):
got_it = 1 got_it = 1
self.filelist.append (fn) self.filelist.append(fn)
break break
if not got_it: if not got_it:
self.warn ("standard file not found: should have one of " + self.warn("standard file not found: should have one of " +
string.join (alts, ', ')) string.join(alts, ', '))
else: else:
if os.path.exists (fn): if os.path.exists(fn):
self.filelist.append (fn) self.filelist.append(fn)
else: else:
self.warn ("standard file '%s' not found" % fn) self.warn("standard file '%s' not found" % fn)
optional = ['test/test*.py', 'setup.cfg'] optional = ['test/test*.py', 'setup.cfg']
for pattern in optional: for pattern in optional:
files = filter (os.path.isfile, glob (pattern)) files = filter(os.path.isfile, glob(pattern))
if files: if files:
self.filelist.extend (files) self.filelist.extend(files)
if self.distribution.has_pure_modules(): if self.distribution.has_pure_modules():
build_py = self.get_finalized_command ('build_py') build_py = self.get_finalized_command('build_py')
self.filelist.extend (build_py.get_source_files ()) self.filelist.extend(build_py.get_source_files())
if self.distribution.has_ext_modules(): if self.distribution.has_ext_modules():
build_ext = self.get_finalized_command ('build_ext') build_ext = self.get_finalized_command('build_ext')
self.filelist.extend (build_ext.get_source_files ()) self.filelist.extend(build_ext.get_source_files())
if self.distribution.has_c_libraries(): if self.distribution.has_c_libraries():
build_clib = self.get_finalized_command ('build_clib') build_clib = self.get_finalized_command('build_clib')
self.filelist.extend (build_clib.get_source_files ()) self.filelist.extend(build_clib.get_source_files())
# add_defaults () # add_defaults ()
...@@ -329,7 +329,7 @@ class sdist (Command): ...@@ -329,7 +329,7 @@ class sdist (Command):
accordingly. accordingly.
""" """
self.announce("reading manifest template '%s'" % self.template) self.announce("reading manifest template '%s'" % self.template)
template = TextFile (self.template, template = TextFile(self.template,
strip_comments=1, strip_comments=1,
skip_blanks=1, skip_blanks=1,
join_lines=1, join_lines=1,
...@@ -386,14 +386,14 @@ class sdist (Command): ...@@ -386,14 +386,14 @@ class sdist (Command):
distribution. distribution.
""" """
self.announce("reading manifest file '%s'" % self.manifest) self.announce("reading manifest file '%s'" % self.manifest)
manifest = open (self.manifest) manifest = open(self.manifest)
while 1: while 1:
line = manifest.readline () line = manifest.readline()
if line == '': # end of file if line == '': # end of file
break break
if line[-1] == '\n': if line[-1] == '\n':
line = line[0:-1] line = line[0:-1]
self.filelist.append (line) self.filelist.append(line)
# read_manifest () # read_manifest ()
...@@ -421,7 +421,7 @@ class sdist (Command): ...@@ -421,7 +421,7 @@ class sdist (Command):
# out-of-date, because by default we blow away 'base_dir' when # out-of-date, because by default we blow away 'base_dir' when
# we're done making the distribution archives.) # we're done making the distribution archives.)
if hasattr (os, 'link'): # can make hard links on this system if hasattr(os, 'link'): # can make hard links on this system
link = 'hard' link = 'hard'
msg = "making hard links in %s..." % base_dir msg = "making hard links in %s..." % base_dir
else: # nope, have to copy else: # nope, have to copy
...@@ -431,13 +431,13 @@ class sdist (Command): ...@@ -431,13 +431,13 @@ class sdist (Command):
if not files: if not files:
self.warn("no files to distribute -- empty manifest?") self.warn("no files to distribute -- empty manifest?")
else: else:
self.announce (msg) self.announce(msg)
for file in files: for file in files:
if not os.path.isfile(file): if not os.path.isfile(file):
self.warn("'%s' not a regular file -- skipping" % file) self.warn("'%s' not a regular file -- skipping" % file)
else: else:
dest = os.path.join (base_dir, file) dest = os.path.join(base_dir, file)
self.copy_file (file, dest, link=link) self.copy_file(file, dest, link=link)
# make_release_tree () # make_release_tree ()
...@@ -455,16 +455,16 @@ class sdist (Command): ...@@ -455,16 +455,16 @@ class sdist (Command):
base_dir = self.distribution.get_fullname() base_dir = self.distribution.get_fullname()
base_name = os.path.join(self.dist_dir, base_dir) base_name = os.path.join(self.dist_dir, base_dir)
self.make_release_tree (base_dir, self.filelist.files) self.make_release_tree(base_dir, self.filelist.files)
archive_files = [] # remember names of files we create archive_files = [] # remember names of files we create
for fmt in self.formats: for fmt in self.formats:
file = self.make_archive (base_name, fmt, base_dir=base_dir) file = self.make_archive(base_name, fmt, base_dir=base_dir)
archive_files.append(file) archive_files.append(file)
self.archive_files = archive_files self.archive_files = archive_files
if not self.keep_temp: if not self.keep_temp:
dir_util.remove_tree (base_dir, self.verbose, self.dry_run) dir_util.remove_tree(base_dir, self.verbose, self.dry_run)
def get_archive_files (self): def get_archive_files (self):
"""Return the list of archive files created when the command """Return the list of archive files created when the command
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment