General cleanup, raise normalization in Lib/distutils.
This commit is contained in:
parent
a73bfee73d
commit
5b7e9d76f3
@ -8,8 +8,6 @@ used from a setup script as
|
|||||||
setup (...)
|
setup (...)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
# Distutils version
|
# Distutils version
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
Utility functions for creating archive files (tarballs, zip files,
|
Utility functions for creating archive files (tarballs, zip files,
|
||||||
that sort of thing)."""
|
that sort of thing)."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -39,8 +37,8 @@ def make_tarball (base_name, base_dir, compress="gzip",
|
|||||||
'bzip2': ['-f9']}
|
'bzip2': ['-f9']}
|
||||||
|
|
||||||
if compress is not None and compress not in compress_ext.keys():
|
if compress is not None and compress not in compress_ext.keys():
|
||||||
raise ValueError, \
|
raise ValueError(
|
||||||
"bad value for 'compress': must be None, 'gzip', or 'compress'"
|
"bad value for 'compress': must be None, 'gzip', or 'compress'")
|
||||||
|
|
||||||
archive_name = base_name + ".tar"
|
archive_name = base_name + ".tar"
|
||||||
mkpath(os.path.dirname(archive_name), dry_run=dry_run)
|
mkpath(os.path.dirname(archive_name), dry_run=dry_run)
|
||||||
@ -86,10 +84,9 @@ def make_zipfile (base_name, base_dir, verbose=0, dry_run=0):
|
|||||||
except DistutilsExecError:
|
except DistutilsExecError:
|
||||||
# XXX really should distinguish between "couldn't find
|
# XXX really should distinguish between "couldn't find
|
||||||
# external 'zip' command" and "zip failed".
|
# external 'zip' command" and "zip failed".
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(("unable to create zip file '%s': "
|
||||||
("unable to create zip file '%s': "
|
|
||||||
"could neither import the 'zipfile' module nor "
|
"could neither import the 'zipfile' module nor "
|
||||||
"find a standalone zip utility") % zip_filename
|
"find a standalone zip utility") % zip_filename)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.info("creating '%s' and adding '%s' to it",
|
log.info("creating '%s' and adding '%s' to it",
|
||||||
@ -157,7 +154,7 @@ def make_archive (base_name, format,
|
|||||||
try:
|
try:
|
||||||
format_info = ARCHIVE_FORMATS[format]
|
format_info = ARCHIVE_FORMATS[format]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError, "unknown archive format '%s'" % format
|
raise ValueError("unknown archive format '%s'" % format)
|
||||||
|
|
||||||
func = format_info[0]
|
func = format_info[0]
|
||||||
for (arg,val) in format_info[1]:
|
for (arg,val) in format_info[1]:
|
||||||
|
@ -11,8 +11,6 @@ for the Borland C++ compiler.
|
|||||||
# someone should sit down and factor out the common code as
|
# someone should sit down and factor out the common code as
|
||||||
# WindowsCCompiler! --GPW
|
# WindowsCCompiler! --GPW
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +114,7 @@ class BCPPCompiler(CCompiler) :
|
|||||||
try:
|
try:
|
||||||
self.spawn (["brcc32", "-fo", obj, src])
|
self.spawn (["brcc32", "-fo", obj, src])
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
continue # the 'for' loop
|
continue # the 'for' loop
|
||||||
|
|
||||||
# The next two are both for the real compiler.
|
# The next two are both for the real compiler.
|
||||||
@ -140,7 +138,7 @@ class BCPPCompiler(CCompiler) :
|
|||||||
[input_opt, output_opt] +
|
[input_opt, output_opt] +
|
||||||
extra_postargs + [src])
|
extra_postargs + [src])
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
@ -165,7 +163,7 @@ class BCPPCompiler(CCompiler) :
|
|||||||
try:
|
try:
|
||||||
self.spawn ([self.lib] + lib_args)
|
self.spawn ([self.lib] + lib_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise LibError, msg
|
raise LibError(msg)
|
||||||
else:
|
else:
|
||||||
log.debug("skipping %s (up-to-date)", output_filename)
|
log.debug("skipping %s (up-to-date)", output_filename)
|
||||||
|
|
||||||
@ -299,7 +297,7 @@ class BCPPCompiler(CCompiler) :
|
|||||||
try:
|
try:
|
||||||
self.spawn ([self.linker] + ld_args)
|
self.spawn ([self.linker] + ld_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise LinkError, msg
|
raise LinkError(msg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.debug("skipping %s (up-to-date)", output_filename)
|
log.debug("skipping %s (up-to-date)", output_filename)
|
||||||
@ -345,9 +343,8 @@ class BCPPCompiler(CCompiler) :
|
|||||||
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
|
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
|
||||||
(base, ext) = os.path.splitext (os.path.normcase(src_name))
|
(base, ext) = os.path.splitext (os.path.normcase(src_name))
|
||||||
if ext not in (self.src_extensions + ['.rc','.res']):
|
if ext not in (self.src_extensions + ['.rc','.res']):
|
||||||
raise UnknownFileError, \
|
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
|
||||||
"unknown file type '%s' (from '%s')" % \
|
(ext, src_name))
|
||||||
(ext, src_name)
|
|
||||||
if strip_dir:
|
if strip_dir:
|
||||||
base = os.path.basename (base)
|
base = os.path.basename (base)
|
||||||
if ext == '.res':
|
if ext == '.res':
|
||||||
@ -393,6 +390,6 @@ class BCPPCompiler(CCompiler) :
|
|||||||
self.spawn(pp_args)
|
self.spawn(pp_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
print(msg)
|
print(msg)
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
# preprocess()
|
# preprocess()
|
||||||
|
@ -3,12 +3,9 @@
|
|||||||
Contains CCompiler, an abstract base class that defines the interface
|
Contains CCompiler, an abstract base class that defines the interface
|
||||||
for the Distutils compiler abstraction model."""
|
for the Distutils compiler abstraction model."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
from types import *
|
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.spawn import spawn
|
from distutils.spawn import spawn
|
||||||
@ -88,11 +85,7 @@ class CCompiler:
|
|||||||
}
|
}
|
||||||
language_order = ["c++", "objc", "c"]
|
language_order = ["c++", "objc", "c"]
|
||||||
|
|
||||||
def __init__ (self,
|
def __init__(self, verbose=0, dry_run=0, force=0):
|
||||||
verbose=0,
|
|
||||||
dry_run=0,
|
|
||||||
force=0):
|
|
||||||
|
|
||||||
self.dry_run = dry_run
|
self.dry_run = dry_run
|
||||||
self.force = force
|
self.force = force
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
@ -128,11 +121,7 @@ class CCompiler:
|
|||||||
for key in self.executables.keys():
|
for key in self.executables.keys():
|
||||||
self.set_executable(key, self.executables[key])
|
self.set_executable(key, self.executables[key])
|
||||||
|
|
||||||
# __init__ ()
|
def set_executables(self, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def set_executables (self, **args):
|
|
||||||
|
|
||||||
"""Define the executables (and options for them) that will be run
|
"""Define the executables (and options for them) that will be run
|
||||||
to perform the various stages of compilation. The exact set of
|
to perform the various stages of compilation. The exact set of
|
||||||
executables that may be specified here depends on the compiler
|
executables that may be specified here depends on the compiler
|
||||||
@ -158,14 +147,11 @@ class CCompiler:
|
|||||||
# discovered at run-time, since there are many different ways to do
|
# discovered at run-time, since there are many different ways to do
|
||||||
# basically the same things with Unix C compilers.
|
# basically the same things with Unix C compilers.
|
||||||
|
|
||||||
for key in args.keys():
|
for key, value in kwargs.items():
|
||||||
if key not in self.executables:
|
if key not in self.executables:
|
||||||
raise ValueError, \
|
raise ValueError("unknown executable '%s' for class %s" % \
|
||||||
"unknown executable '%s' for class %s" % \
|
(key, self.__class__.__name__))
|
||||||
(key, self.__class__.__name__)
|
self.set_executable(key, value)
|
||||||
self.set_executable(key, args[key])
|
|
||||||
|
|
||||||
# set_executables ()
|
|
||||||
|
|
||||||
def set_executable(self, key, value):
|
def set_executable(self, key, value):
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
@ -173,32 +159,27 @@ class CCompiler:
|
|||||||
else:
|
else:
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
|
||||||
|
|
||||||
def _find_macro(self, name):
|
def _find_macro(self, name):
|
||||||
i = 0
|
i = 0
|
||||||
for defn in self.macros:
|
for defn in self.macros:
|
||||||
if defn[0] == name:
|
if defn[0] == name:
|
||||||
return i
|
return i
|
||||||
i = i + 1
|
i += 1
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _check_macro_definitions(self, definitions):
|
def _check_macro_definitions(self, definitions):
|
||||||
"""Ensures that every element of 'definitions' is a valid macro
|
"""Ensures that every element of 'definitions' is a valid macro
|
||||||
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
|
definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do
|
||||||
nothing if all definitions are OK, raise TypeError otherwise.
|
nothing if all definitions are OK, raise TypeError otherwise.
|
||||||
"""
|
"""
|
||||||
for defn in definitions:
|
for defn in definitions:
|
||||||
if not (type (defn) is TupleType and
|
if not (isinstance(defn, tuple) and
|
||||||
(len (defn) == 1 or
|
(len(defn) in (1, 2) and
|
||||||
(len (defn) == 2 and
|
(isinstance (defn[1], basestring) or defn[1] is None)) and
|
||||||
(isinstance (defn[1], basestring) or defn[1] is None))) and
|
|
||||||
isinstance (defn[0], basestring)):
|
isinstance (defn[0], basestring)):
|
||||||
raise TypeError, \
|
raise TypeError(("invalid macro definition '%s': " % defn) + \
|
||||||
("invalid macro definition '%s': " % defn) + \
|
|
||||||
"must be tuple (string,), (string, string), or " + \
|
"must be tuple (string,), (string, string), or " + \
|
||||||
"(string, None)"
|
"(string, None)")
|
||||||
|
|
||||||
|
|
||||||
# -- Bookkeeping methods -------------------------------------------
|
# -- Bookkeeping methods -------------------------------------------
|
||||||
@ -216,9 +197,7 @@ class CCompiler:
|
|||||||
if i is not None:
|
if i is not None:
|
||||||
del self.macros[i]
|
del self.macros[i]
|
||||||
|
|
||||||
defn = (name, value)
|
self.macros.append((name, value))
|
||||||
self.macros.append (defn)
|
|
||||||
|
|
||||||
|
|
||||||
def undefine_macro(self, name):
|
def undefine_macro(self, name):
|
||||||
"""Undefine a preprocessor macro for all compilations driven by
|
"""Undefine a preprocessor macro for all compilations driven by
|
||||||
@ -238,7 +217,6 @@ class CCompiler:
|
|||||||
undefn = (name,)
|
undefn = (name,)
|
||||||
self.macros.append(undefn)
|
self.macros.append(undefn)
|
||||||
|
|
||||||
|
|
||||||
def add_include_dir(self, dir):
|
def add_include_dir(self, dir):
|
||||||
"""Add 'dir' to the list of directories that will be searched for
|
"""Add 'dir' to the list of directories that will be searched for
|
||||||
header files. The compiler is instructed to search directories in
|
header files. The compiler is instructed to search directories in
|
||||||
@ -257,7 +235,6 @@ class CCompiler:
|
|||||||
"""
|
"""
|
||||||
self.include_dirs = copy(dirs)
|
self.include_dirs = copy(dirs)
|
||||||
|
|
||||||
|
|
||||||
def add_library(self, libname):
|
def add_library(self, libname):
|
||||||
"""Add 'libname' to the list of libraries that will be included in
|
"""Add 'libname' to the list of libraries that will be included in
|
||||||
all links driven by this compiler object. Note that 'libname'
|
all links driven by this compiler object. Note that 'libname'
|
||||||
@ -282,7 +259,6 @@ class CCompiler:
|
|||||||
"""
|
"""
|
||||||
self.libraries = copy(libnames)
|
self.libraries = copy(libnames)
|
||||||
|
|
||||||
|
|
||||||
def add_library_dir(self, dir):
|
def add_library_dir(self, dir):
|
||||||
"""Add 'dir' to the list of directories that will be searched for
|
"""Add 'dir' to the list of directories that will be searched for
|
||||||
libraries specified to 'add_library()' and 'set_libraries()'. The
|
libraries specified to 'add_library()' and 'set_libraries()'. The
|
||||||
@ -298,7 +274,6 @@ class CCompiler:
|
|||||||
"""
|
"""
|
||||||
self.library_dirs = copy(dirs)
|
self.library_dirs = copy(dirs)
|
||||||
|
|
||||||
|
|
||||||
def add_runtime_library_dir(self, dir):
|
def add_runtime_library_dir(self, dir):
|
||||||
"""Add 'dir' to the list of directories that will be searched for
|
"""Add 'dir' to the list of directories that will be searched for
|
||||||
shared libraries at runtime.
|
shared libraries at runtime.
|
||||||
@ -313,7 +288,6 @@ class CCompiler:
|
|||||||
"""
|
"""
|
||||||
self.runtime_library_dirs = copy(dirs)
|
self.runtime_library_dirs = copy(dirs)
|
||||||
|
|
||||||
|
|
||||||
def add_link_object(self, object):
|
def add_link_object(self, object):
|
||||||
"""Add 'object' to the list of object files (or analogues, such as
|
"""Add 'object' to the list of object files (or analogues, such as
|
||||||
explicitly named library files or the output of "resource
|
explicitly named library files or the output of "resource
|
||||||
@ -345,29 +319,28 @@ class CCompiler:
|
|||||||
if outdir is None:
|
if outdir is None:
|
||||||
outdir = self.output_dir
|
outdir = self.output_dir
|
||||||
elif not isinstance(outdir, basestring):
|
elif not isinstance(outdir, basestring):
|
||||||
raise TypeError, "'output_dir' must be a string or None"
|
raise TypeError("'output_dir' must be a string or None")
|
||||||
|
|
||||||
if macros is None:
|
if macros is None:
|
||||||
macros = self.macros
|
macros = self.macros
|
||||||
elif type(macros) is ListType:
|
elif isinstance(macros, list):
|
||||||
macros = macros + (self.macros or [])
|
macros = macros + (self.macros or [])
|
||||||
else:
|
else:
|
||||||
raise TypeError, "'macros' (if supplied) must be a list of tuples"
|
raise TypeError("'macros' (if supplied) must be a list of tuples")
|
||||||
|
|
||||||
if incdirs is None:
|
if incdirs is None:
|
||||||
incdirs = self.include_dirs
|
incdirs = self.include_dirs
|
||||||
elif type(incdirs) in (ListType, TupleType):
|
elif isinstance(incdirs, (list, tuple)):
|
||||||
incdirs = list(incdirs) + (self.include_dirs or [])
|
incdirs = list(incdirs) + (self.include_dirs or [])
|
||||||
else:
|
else:
|
||||||
raise TypeError, \
|
raise TypeError(
|
||||||
"'include_dirs' (if supplied) must be a list of strings"
|
"'include_dirs' (if supplied) must be a list of strings")
|
||||||
|
|
||||||
if extra is None:
|
if extra is None:
|
||||||
extra = []
|
extra = []
|
||||||
|
|
||||||
# Get the list of expected output (object) files
|
# Get the list of expected output (object) files
|
||||||
objects = self.object_filenames(sources,
|
objects = self.object_filenames(sources, strip_dir=0,
|
||||||
strip_dir=0,
|
|
||||||
output_dir=outdir)
|
output_dir=outdir)
|
||||||
assert len(objects) == len(sources)
|
assert len(objects) == len(sources)
|
||||||
|
|
||||||
@ -443,28 +416,25 @@ class CCompiler:
|
|||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
output_dir = self.output_dir
|
output_dir = self.output_dir
|
||||||
elif not isinstance(output_dir, basestring):
|
elif not isinstance(output_dir, basestring):
|
||||||
raise TypeError, "'output_dir' must be a string or None"
|
raise TypeError("'output_dir' must be a string or None")
|
||||||
|
|
||||||
if macros is None:
|
if macros is None:
|
||||||
macros = self.macros
|
macros = self.macros
|
||||||
elif type (macros) is ListType:
|
elif isinstance(macros, list):
|
||||||
macros = macros + (self.macros or [])
|
macros = macros + (self.macros or [])
|
||||||
else:
|
else:
|
||||||
raise TypeError, "'macros' (if supplied) must be a list of tuples"
|
raise TypeError("'macros' (if supplied) must be a list of tuples")
|
||||||
|
|
||||||
if include_dirs is None:
|
if include_dirs is None:
|
||||||
include_dirs = self.include_dirs
|
include_dirs = self.include_dirs
|
||||||
elif type (include_dirs) in (ListType, TupleType):
|
elif isinstance(include_dirs, (list, tuple)):
|
||||||
include_dirs = list(include_dirs) + (self.include_dirs or [])
|
include_dirs = list(include_dirs) + (self.include_dirs or [])
|
||||||
else:
|
else:
|
||||||
raise TypeError, \
|
raise TypeError(
|
||||||
"'include_dirs' (if supplied) must be a list of strings"
|
"'include_dirs' (if supplied) must be a list of strings")
|
||||||
|
|
||||||
return output_dir, macros, include_dirs
|
return output_dir, macros, include_dirs
|
||||||
|
|
||||||
# _fix_compile_args ()
|
|
||||||
|
|
||||||
|
|
||||||
def _prep_compile(self, sources, output_dir, depends=None):
|
def _prep_compile(self, sources, output_dir, depends=None):
|
||||||
"""Decide which souce files must be recompiled.
|
"""Decide which souce files must be recompiled.
|
||||||
|
|
||||||
@ -511,8 +481,6 @@ class CCompiler:
|
|||||||
|
|
||||||
return objects, skip_source
|
return objects, skip_source
|
||||||
|
|
||||||
# _prep_compile ()
|
|
||||||
|
|
||||||
|
|
||||||
def _fix_object_args(self, objects, output_dir):
|
def _fix_object_args(self, objects, output_dir):
|
||||||
"""Typecheck and fix up some arguments supplied to various methods.
|
"""Typecheck and fix up some arguments supplied to various methods.
|
||||||
@ -520,19 +488,17 @@ class CCompiler:
|
|||||||
None, replace with self.output_dir. Return fixed versions of
|
None, replace with self.output_dir. Return fixed versions of
|
||||||
'objects' and 'output_dir'.
|
'objects' and 'output_dir'.
|
||||||
"""
|
"""
|
||||||
if type (objects) not in (ListType, TupleType):
|
if not isinstance(objects, (list, tuple)):
|
||||||
raise TypeError, \
|
raise TypeError("'objects' must be a list or tuple of strings")
|
||||||
"'objects' must be a list or tuple of strings"
|
|
||||||
objects = list(objects)
|
objects = list(objects)
|
||||||
|
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
output_dir = self.output_dir
|
output_dir = self.output_dir
|
||||||
elif not isinstance(output_dir, basestring):
|
elif not isinstance(output_dir, basestring):
|
||||||
raise TypeError, "'output_dir' must be a string or None"
|
raise TypeError("'output_dir' must be a string or None")
|
||||||
|
|
||||||
return (objects, output_dir)
|
return (objects, output_dir)
|
||||||
|
|
||||||
|
|
||||||
def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
|
def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs):
|
||||||
"""Typecheck and fix up some of the arguments supplied to the
|
"""Typecheck and fix up some of the arguments supplied to the
|
||||||
'link_*' methods. Specifically: ensure that all arguments are
|
'link_*' methods. Specifically: ensure that all arguments are
|
||||||
@ -542,41 +508,37 @@ class CCompiler:
|
|||||||
"""
|
"""
|
||||||
if libraries is None:
|
if libraries is None:
|
||||||
libraries = self.libraries
|
libraries = self.libraries
|
||||||
elif type (libraries) in (ListType, TupleType):
|
elif isinstance(libraries, (list, tuple)):
|
||||||
libraries = list (libraries) + (self.libraries or [])
|
libraries = list (libraries) + (self.libraries or [])
|
||||||
else:
|
else:
|
||||||
raise TypeError, \
|
raise TypeError(
|
||||||
"'libraries' (if supplied) must be a list of strings"
|
"'libraries' (if supplied) must be a list of strings")
|
||||||
|
|
||||||
if library_dirs is None:
|
if library_dirs is None:
|
||||||
library_dirs = self.library_dirs
|
library_dirs = self.library_dirs
|
||||||
elif type (library_dirs) in (ListType, TupleType):
|
elif isinstance(library_dirs, (list, tuple)):
|
||||||
library_dirs = list (library_dirs) + (self.library_dirs or [])
|
library_dirs = list (library_dirs) + (self.library_dirs or [])
|
||||||
else:
|
else:
|
||||||
raise TypeError, \
|
raise TypeError(
|
||||||
"'library_dirs' (if supplied) must be a list of strings"
|
"'library_dirs' (if supplied) must be a list of strings")
|
||||||
|
|
||||||
if runtime_library_dirs is None:
|
if runtime_library_dirs is None:
|
||||||
runtime_library_dirs = self.runtime_library_dirs
|
runtime_library_dirs = self.runtime_library_dirs
|
||||||
elif type (runtime_library_dirs) in (ListType, TupleType):
|
elif isinstance(runtime_library_dirs, (list, tuple)):
|
||||||
runtime_library_dirs = (list(runtime_library_dirs) +
|
runtime_library_dirs = (list(runtime_library_dirs) +
|
||||||
(self.runtime_library_dirs or []))
|
(self.runtime_library_dirs or []))
|
||||||
else:
|
else:
|
||||||
raise TypeError, \
|
raise TypeError("'runtime_library_dirs' (if supplied) "
|
||||||
"'runtime_library_dirs' (if supplied) " + \
|
"must be a list of strings")
|
||||||
"must be a list of strings"
|
|
||||||
|
|
||||||
return (libraries, library_dirs, runtime_library_dirs)
|
return (libraries, library_dirs, runtime_library_dirs)
|
||||||
|
|
||||||
# _fix_lib_args ()
|
|
||||||
|
|
||||||
|
|
||||||
def _need_link(self, objects, output_file):
|
def _need_link(self, objects, output_file):
|
||||||
"""Return true if we need to relink the files listed in 'objects'
|
"""Return true if we need to relink the files listed in 'objects'
|
||||||
to recreate 'output_file'.
|
to recreate 'output_file'.
|
||||||
"""
|
"""
|
||||||
if self.force:
|
if self.force:
|
||||||
return 1
|
return True
|
||||||
else:
|
else:
|
||||||
if self.dry_run:
|
if self.dry_run:
|
||||||
newer = newer_group (objects, output_file, missing='newer')
|
newer = newer_group (objects, output_file, missing='newer')
|
||||||
@ -584,13 +546,11 @@ class CCompiler:
|
|||||||
newer = newer_group (objects, output_file)
|
newer = newer_group (objects, output_file)
|
||||||
return newer
|
return newer
|
||||||
|
|
||||||
# _need_link ()
|
|
||||||
|
|
||||||
def detect_language(self, sources):
|
def detect_language(self, sources):
|
||||||
"""Detect the language of a given file, or list of files. Uses
|
"""Detect the language of a given file, or list of files. Uses
|
||||||
language_map, and language_order to do the job.
|
language_map, and language_order to do the job.
|
||||||
"""
|
"""
|
||||||
if type(sources) is not ListType:
|
if not isinstance(sources, list):
|
||||||
sources = [sources]
|
sources = [sources]
|
||||||
lang = None
|
lang = None
|
||||||
index = len(self.language_order)
|
index = len(self.language_order)
|
||||||
@ -606,18 +566,12 @@ class CCompiler:
|
|||||||
pass
|
pass
|
||||||
return lang
|
return lang
|
||||||
|
|
||||||
# detect_language ()
|
|
||||||
|
|
||||||
# -- Worker methods ------------------------------------------------
|
# -- Worker methods ------------------------------------------------
|
||||||
# (must be implemented by subclasses)
|
# (must be implemented by subclasses)
|
||||||
|
|
||||||
def preprocess (self,
|
def preprocess(self, source, output_file=None, macros=None,
|
||||||
source,
|
include_dirs=None, extra_preargs=None, extra_postargs=None):
|
||||||
output_file=None,
|
|
||||||
macros=None,
|
|
||||||
include_dirs=None,
|
|
||||||
extra_preargs=None,
|
|
||||||
extra_postargs=None):
|
|
||||||
"""Preprocess a single C/C++ source file, named in 'source'.
|
"""Preprocess a single C/C++ source file, named in 'source'.
|
||||||
Output will be written to file named 'output_file', or stdout if
|
Output will be written to file named 'output_file', or stdout if
|
||||||
'output_file' not supplied. 'macros' is a list of macro
|
'output_file' not supplied. 'macros' is a list of macro
|
||||||
@ -680,10 +634,8 @@ class CCompiler:
|
|||||||
|
|
||||||
Raises CompileError on failure.
|
Raises CompileError on failure.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# A concrete compiler class can either override this method
|
# A concrete compiler class can either override this method
|
||||||
# entirely or implement _compile().
|
# entirely or implement _compile().
|
||||||
|
|
||||||
macros, objects, extra_postargs, pp_opts, build = \
|
macros, objects, extra_postargs, pp_opts, build = \
|
||||||
self._setup_compile(output_dir, macros, include_dirs, sources,
|
self._setup_compile(output_dir, macros, include_dirs, sources,
|
||||||
depends, extra_postargs)
|
depends, extra_postargs)
|
||||||
@ -701,17 +653,12 @@ class CCompiler:
|
|||||||
|
|
||||||
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||||
"""Compile 'src' to product 'obj'."""
|
"""Compile 'src' to product 'obj'."""
|
||||||
|
|
||||||
# A concrete compiler class that does not override compile()
|
# A concrete compiler class that does not override compile()
|
||||||
# should implement _compile().
|
# should implement _compile().
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_static_lib (self,
|
def create_static_lib(self, objects, output_libname, output_dir=None,
|
||||||
objects,
|
debug=0, target_lang=None):
|
||||||
output_libname,
|
|
||||||
output_dir=None,
|
|
||||||
debug=0,
|
|
||||||
target_lang=None):
|
|
||||||
"""Link a bunch of stuff together to create a static library file.
|
"""Link a bunch of stuff together to create a static library file.
|
||||||
The "bunch of stuff" consists of the list of object files supplied
|
The "bunch of stuff" consists of the list of object files supplied
|
||||||
as 'objects', the extra object files supplied to
|
as 'objects', the extra object files supplied to
|
||||||
@ -885,16 +832,12 @@ class CCompiler:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def has_function(self, funcname,
|
def has_function(self, funcname, includes=None, include_dirs=None,
|
||||||
includes=None,
|
libraries=None, library_dirs=None):
|
||||||
include_dirs=None,
|
|
||||||
libraries=None,
|
|
||||||
library_dirs=None):
|
|
||||||
"""Return a boolean indicating whether funcname is supported on
|
"""Return a boolean indicating whether funcname is supported on
|
||||||
the current platform. The optional arguments can be used to
|
the current platform. The optional arguments can be used to
|
||||||
augment the compilation environment.
|
augment the compilation environment.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# this can't be included at module scope because it tries to
|
# this can't be included at module scope because it tries to
|
||||||
# import math which might not be available at that point - maybe
|
# import math which might not be available at that point - maybe
|
||||||
# the necessary logic should just be inlined?
|
# the necessary logic should just be inlined?
|
||||||
@ -982,8 +925,8 @@ main (int argc, char **argv) {
|
|||||||
base = os.path.splitdrive(base)[1] # Chop off the drive
|
base = os.path.splitdrive(base)[1] # Chop off the drive
|
||||||
base = base[os.path.isabs(base):] # If abs, chop off leading /
|
base = base[os.path.isabs(base):] # If abs, chop off leading /
|
||||||
if ext not in self.src_extensions:
|
if ext not in self.src_extensions:
|
||||||
raise UnknownFileError, \
|
raise UnknownFileError(
|
||||||
"unknown file type '%s' (from '%s')" % (ext, src_name)
|
"unknown file type '%s' (from '%s')" % (ext, src_name))
|
||||||
if strip_dir:
|
if strip_dir:
|
||||||
base = os.path.basename(base)
|
base = os.path.basename(base)
|
||||||
obj_names.append(os.path.join(output_dir,
|
obj_names.append(os.path.join(output_dir,
|
||||||
@ -1006,7 +949,8 @@ main (int argc, char **argv) {
|
|||||||
strip_dir=0, output_dir=''):
|
strip_dir=0, output_dir=''):
|
||||||
assert output_dir is not None
|
assert output_dir is not None
|
||||||
if lib_type not in ("static", "shared", "dylib"):
|
if lib_type not in ("static", "shared", "dylib"):
|
||||||
raise ValueError, "'lib_type' must be \"static\", \"shared\" or \"dylib\""
|
raise ValueError(
|
||||||
|
"'lib_type' must be \"static\", \"shared\" or \"dylib\"")
|
||||||
fmt = getattr(self, lib_type + "_lib_format")
|
fmt = getattr(self, lib_type + "_lib_format")
|
||||||
ext = getattr(self, lib_type + "_lib_extension")
|
ext = getattr(self, lib_type + "_lib_extension")
|
||||||
|
|
||||||
@ -1044,9 +988,6 @@ main (int argc, char **argv) {
|
|||||||
mkpath(name, mode, self.dry_run)
|
mkpath(name, mode, self.dry_run)
|
||||||
|
|
||||||
|
|
||||||
# class CCompiler
|
|
||||||
|
|
||||||
|
|
||||||
# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
|
# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
|
||||||
# type for that platform. Keys are interpreted as re match
|
# type for that platform. Keys are interpreted as re match
|
||||||
# patterns. Order is important; platform mappings are preferred over
|
# patterns. Order is important; platform mappings are preferred over
|
||||||
@ -1068,7 +1009,6 @@ _default_compilers = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_default_compiler(osname=None, platform=None):
|
def get_default_compiler(osname=None, platform=None):
|
||||||
|
|
||||||
"""Determine the default compiler to use for the given platform.
|
"""Determine the default compiler to use for the given platform.
|
||||||
|
|
||||||
osname should be one of the standard Python OS names (i.e. the
|
osname should be one of the standard Python OS names (i.e. the
|
||||||
@ -1077,7 +1017,6 @@ def get_default_compiler(osname=None, platform=None):
|
|||||||
|
|
||||||
The default values are os.name and sys.platform in case the
|
The default values are os.name and sys.platform in case the
|
||||||
parameters are not given.
|
parameters are not given.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if osname is None:
|
if osname is None:
|
||||||
osname = os.name
|
osname = os.name
|
||||||
@ -1126,11 +1065,7 @@ def show_compilers():
|
|||||||
pretty_printer.print_help("List of available compilers:")
|
pretty_printer.print_help("List of available compilers:")
|
||||||
|
|
||||||
|
|
||||||
def new_compiler (plat=None,
|
def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
|
||||||
compiler=None,
|
|
||||||
verbose=0,
|
|
||||||
dry_run=0,
|
|
||||||
force=0):
|
|
||||||
"""Generate an instance of some CCompiler subclass for the supplied
|
"""Generate an instance of some CCompiler subclass for the supplied
|
||||||
platform/compiler combination. 'plat' defaults to 'os.name'
|
platform/compiler combination. 'plat' defaults to 'os.name'
|
||||||
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
|
(eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler
|
||||||
@ -1153,7 +1088,7 @@ def new_compiler (plat=None,
|
|||||||
msg = "don't know how to compile C/C++ code on platform '%s'" % plat
|
msg = "don't know how to compile C/C++ code on platform '%s'" % plat
|
||||||
if compiler is not None:
|
if compiler is not None:
|
||||||
msg = msg + " with '%s' compiler" % compiler
|
msg = msg + " with '%s' compiler" % compiler
|
||||||
raise DistutilsPlatformError, msg
|
raise DistutilsPlatformError(msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
module_name = "distutils." + module_name
|
module_name = "distutils." + module_name
|
||||||
@ -1161,13 +1096,13 @@ def new_compiler (plat=None,
|
|||||||
module = sys.modules[module_name]
|
module = sys.modules[module_name]
|
||||||
klass = vars(module)[class_name]
|
klass = vars(module)[class_name]
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise DistutilsModuleError, \
|
raise DistutilsModuleError(
|
||||||
"can't compile C/C++ code: unable to load module '%s'" % \
|
"can't compile C/C++ code: unable to load module '%s'" % \
|
||||||
module_name
|
module_name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise DistutilsModuleError, \
|
raise DistutilsModuleError(
|
||||||
("can't compile C/C++ code: unable to find class '%s' " +
|
"can't compile C/C++ code: unable to find class '%s' "
|
||||||
"in module '%s'") % (class_name, module_name)
|
"in module '%s'" % (class_name, module_name))
|
||||||
|
|
||||||
# XXX The None is necessary to preserve backwards compatibility
|
# XXX The None is necessary to preserve backwards compatibility
|
||||||
# with classes that expect verbose to be the first positional
|
# with classes that expect verbose to be the first positional
|
||||||
@ -1196,16 +1131,13 @@ def gen_preprocess_options (macros, include_dirs):
|
|||||||
# redundancies like this should probably be the province of
|
# redundancies like this should probably be the province of
|
||||||
# CCompiler, since the data structures used are inherited from it
|
# CCompiler, since the data structures used are inherited from it
|
||||||
# and therefore common to all CCompiler classes.
|
# and therefore common to all CCompiler classes.
|
||||||
|
|
||||||
pp_opts = []
|
pp_opts = []
|
||||||
for macro in macros:
|
for macro in macros:
|
||||||
|
if not (isinstance(macro, tuple) and 1 <= len(macro) <= 2):
|
||||||
if not (type (macro) is TupleType and
|
raise TypeError(
|
||||||
1 <= len (macro) <= 2):
|
"bad macro definition '%s': "
|
||||||
raise TypeError, \
|
"each element of 'macros' list must be a 1- or 2-tuple"
|
||||||
("bad macro definition '%s': " +
|
% macro)
|
||||||
"each element of 'macros' list must be a 1- or 2-tuple") % \
|
|
||||||
macro
|
|
||||||
|
|
||||||
if len(macro) == 1: # undefine this macro
|
if len(macro) == 1: # undefine this macro
|
||||||
pp_opts.append("-U%s" % macro[0])
|
pp_opts.append("-U%s" % macro[0])
|
||||||
@ -1220,11 +1152,8 @@ def gen_preprocess_options (macros, include_dirs):
|
|||||||
|
|
||||||
for dir in include_dirs:
|
for dir in include_dirs:
|
||||||
pp_opts.append("-I%s" % dir)
|
pp_opts.append("-I%s" % dir)
|
||||||
|
|
||||||
return pp_opts
|
return pp_opts
|
||||||
|
|
||||||
# gen_preprocess_options ()
|
|
||||||
|
|
||||||
|
|
||||||
def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
|
def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
|
||||||
"""Generate linker options for searching library directories and
|
"""Generate linker options for searching library directories and
|
||||||
@ -1240,7 +1169,7 @@ def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
|
|||||||
|
|
||||||
for dir in runtime_library_dirs:
|
for dir in runtime_library_dirs:
|
||||||
opt = compiler.runtime_library_dir_option(dir)
|
opt = compiler.runtime_library_dir_option(dir)
|
||||||
if type(opt) is ListType:
|
if isinstance(opt, list):
|
||||||
lib_opts = lib_opts + opt
|
lib_opts = lib_opts + opt
|
||||||
else:
|
else:
|
||||||
lib_opts.append(opt)
|
lib_opts.append(opt)
|
||||||
@ -1262,7 +1191,4 @@ def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
|
|||||||
"'%s' found (skipping)" % lib)
|
"'%s' found (skipping)" % lib)
|
||||||
else:
|
else:
|
||||||
lib_opts.append(compiler.library_option (lib))
|
lib_opts.append(compiler.library_option (lib))
|
||||||
|
|
||||||
return lib_opts
|
return lib_opts
|
||||||
|
|
||||||
# gen_lib_options ()
|
|
||||||
|
@ -4,8 +4,6 @@ Provides the Command class, the base class for the command classes
|
|||||||
in the distutils.command package.
|
in the distutils.command package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
@ -58,9 +56,9 @@ class Command:
|
|||||||
from distutils.dist import Distribution
|
from distutils.dist import Distribution
|
||||||
|
|
||||||
if not isinstance(dist, Distribution):
|
if not isinstance(dist, Distribution):
|
||||||
raise TypeError, "dist must be a Distribution instance"
|
raise TypeError("dist must be a Distribution instance")
|
||||||
if self.__class__ is Command:
|
if self.__class__ is Command:
|
||||||
raise RuntimeError, "Command is an abstract class"
|
raise RuntimeError("Command is an abstract class")
|
||||||
|
|
||||||
self.distribution = dist
|
self.distribution = dist
|
||||||
self.initialize_options()
|
self.initialize_options()
|
||||||
@ -95,11 +93,8 @@ class Command:
|
|||||||
# always calls 'finalize_options()', to respect/update it.
|
# always calls 'finalize_options()', to respect/update it.
|
||||||
self.finalized = 0
|
self.finalized = 0
|
||||||
|
|
||||||
# __init__ ()
|
|
||||||
|
|
||||||
|
|
||||||
# XXX A more explicit way to customize dry_run would be better.
|
# XXX A more explicit way to customize dry_run would be better.
|
||||||
|
|
||||||
def __getattr__ (self, attr):
|
def __getattr__ (self, attr):
|
||||||
if attr == 'dry_run':
|
if attr == 'dry_run':
|
||||||
myval = getattr(self, "_" + attr)
|
myval = getattr(self, "_" + attr)
|
||||||
@ -108,15 +103,13 @@ class Command:
|
|||||||
else:
|
else:
|
||||||
return myval
|
return myval
|
||||||
else:
|
else:
|
||||||
raise AttributeError, attr
|
raise AttributeError(attr)
|
||||||
|
|
||||||
|
|
||||||
def ensure_finalized (self):
|
def ensure_finalized (self):
|
||||||
if not self.finalized:
|
if not self.finalized:
|
||||||
self.finalize_options()
|
self.finalize_options()
|
||||||
self.finalized = 1
|
self.finalized = 1
|
||||||
|
|
||||||
|
|
||||||
# Subclasses must define:
|
# Subclasses must define:
|
||||||
# initialize_options()
|
# initialize_options()
|
||||||
# provide default values for all options; may be customized by
|
# provide default values for all options; may be customized by
|
||||||
@ -140,8 +133,8 @@ class Command:
|
|||||||
|
|
||||||
This method must be implemented by all command classes.
|
This method must be implemented by all command classes.
|
||||||
"""
|
"""
|
||||||
raise RuntimeError, \
|
raise RuntimeError("abstract method -- subclass %s must override"
|
||||||
"abstract method -- subclass %s must override" % self.__class__
|
% self.__class__)
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
"""Set final values for all the options that this command supports.
|
"""Set final values for all the options that this command supports.
|
||||||
@ -154,8 +147,8 @@ class Command:
|
|||||||
|
|
||||||
This method must be implemented by all command classes.
|
This method must be implemented by all command classes.
|
||||||
"""
|
"""
|
||||||
raise RuntimeError, \
|
raise RuntimeError("abstract method -- subclass %s must override"
|
||||||
"abstract method -- subclass %s must override" % self.__class__
|
% self.__class__)
|
||||||
|
|
||||||
|
|
||||||
def dump_options(self, header=None, indent=""):
|
def dump_options(self, header=None, indent=""):
|
||||||
@ -183,8 +176,8 @@ class Command:
|
|||||||
This method must be implemented by all command classes.
|
This method must be implemented by all command classes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raise RuntimeError, \
|
raise RuntimeError("abstract method -- subclass %s must override"
|
||||||
"abstract method -- subclass %s must override" % self.__class__
|
% self.__class__)
|
||||||
|
|
||||||
def announce(self, msg, level=1):
|
def announce(self, msg, level=1):
|
||||||
"""If the current verbosity level is of greater than or equal to
|
"""If the current verbosity level is of greater than or equal to
|
||||||
@ -202,7 +195,6 @@ class Command:
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -- Option validation methods -------------------------------------
|
# -- Option validation methods -------------------------------------
|
||||||
# (these are very handy in writing the 'finalize_options()' method)
|
# (these are very handy in writing the 'finalize_options()' method)
|
||||||
#
|
#
|
||||||
@ -222,8 +214,8 @@ class Command:
|
|||||||
setattr(self, option, default)
|
setattr(self, option, default)
|
||||||
return default
|
return default
|
||||||
elif not isinstance(val, basestring):
|
elif not isinstance(val, basestring):
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError("'%s' must be a %s (got `%s`)"
|
||||||
"'%s' must be a %s (got `%s`)" % (option, what, val)
|
% (option, what, val))
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def ensure_string(self, option, default=None):
|
def ensure_string(self, option, default=None):
|
||||||
@ -247,19 +239,18 @@ class Command:
|
|||||||
if isinstance(val, list):
|
if isinstance(val, list):
|
||||||
ok = all(isinstance(v, basestring) for v in val)
|
ok = all(isinstance(v, basestring) for v in val)
|
||||||
else:
|
else:
|
||||||
ok = 0
|
ok = False
|
||||||
|
|
||||||
if not ok:
|
if not ok:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"'%s' must be a list of strings (got %r)" % \
|
"'%s' must be a list of strings (got %r)"
|
||||||
(option, val)
|
% (option, val))
|
||||||
|
|
||||||
def _ensure_tested_string (self, option, tester,
|
def _ensure_tested_string(self, option, tester, what, error_fmt,
|
||||||
what, error_fmt, default=None):
|
default=None):
|
||||||
val = self._ensure_stringlike(option, what, default)
|
val = self._ensure_stringlike(option, what, default)
|
||||||
if val is not None and not tester(val):
|
if val is not None and not tester(val):
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(("error in '%s' option: " + error_fmt)
|
||||||
("error in '%s' option: " + error_fmt) % (option, val)
|
% (option, val))
|
||||||
|
|
||||||
def ensure_filename(self, option):
|
def ensure_filename(self, option):
|
||||||
"""Ensure that 'option' is the name of an existing file."""
|
"""Ensure that 'option' is the name of an existing file."""
|
||||||
@ -281,7 +272,6 @@ class Command:
|
|||||||
else:
|
else:
|
||||||
return self.__class__.__name__
|
return self.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
def set_undefined_options(self, src_cmd, *option_pairs):
|
def set_undefined_options(self, src_cmd, *option_pairs):
|
||||||
"""Set the values of any "undefined" options from corresponding
|
"""Set the values of any "undefined" options from corresponding
|
||||||
option values in some other command object. "Undefined" here means
|
option values in some other command object. "Undefined" here means
|
||||||
@ -296,16 +286,12 @@ class Command:
|
|||||||
'src_option' in the 'src_cmd' command object, and copy it to
|
'src_option' in the 'src_cmd' command object, and copy it to
|
||||||
'dst_option' in the current command object".
|
'dst_option' in the current command object".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Option_pairs: list of (src_option, dst_option) tuples
|
# Option_pairs: list of (src_option, dst_option) tuples
|
||||||
|
|
||||||
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
|
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
|
||||||
src_cmd_obj.ensure_finalized()
|
src_cmd_obj.ensure_finalized()
|
||||||
for (src_option, dst_option) in option_pairs:
|
for (src_option, dst_option) in option_pairs:
|
||||||
if getattr(self, dst_option) is None:
|
if getattr(self, dst_option) is None:
|
||||||
setattr(self, dst_option,
|
setattr(self, dst_option, getattr(src_cmd_obj, src_option))
|
||||||
getattr(src_cmd_obj, src_option))
|
|
||||||
|
|
||||||
|
|
||||||
def get_finalized_command(self, command, create=1):
|
def get_finalized_command(self, command, create=1):
|
||||||
"""Wrapper around Distribution's 'get_command_obj()' method: find
|
"""Wrapper around Distribution's 'get_command_obj()' method: find
|
||||||
@ -320,8 +306,8 @@ class Command:
|
|||||||
# XXX rename to 'get_reinitialized_command()'? (should do the
|
# XXX rename to 'get_reinitialized_command()'? (should do the
|
||||||
# same in dist.py, if so)
|
# same in dist.py, if so)
|
||||||
def reinitialize_command(self, command, reinit_subcommands=0):
|
def reinitialize_command(self, command, reinit_subcommands=0):
|
||||||
return self.distribution.reinitialize_command(
|
return self.distribution.reinitialize_command(command,
|
||||||
command, reinit_subcommands)
|
reinit_subcommands)
|
||||||
|
|
||||||
def run_command(self, command):
|
def run_command(self, command):
|
||||||
"""Run some other command: uses the 'run_command()' method of
|
"""Run some other command: uses the 'run_command()' method of
|
||||||
@ -330,7 +316,6 @@ class Command:
|
|||||||
"""
|
"""
|
||||||
self.distribution.run_command(command)
|
self.distribution.run_command(command)
|
||||||
|
|
||||||
|
|
||||||
def get_sub_commands(self):
|
def get_sub_commands(self):
|
||||||
"""Determine the sub-commands that are relevant in the current
|
"""Determine the sub-commands that are relevant in the current
|
||||||
distribution (ie., that need to be run). This is based on the
|
distribution (ie., that need to be run). This is based on the
|
||||||
@ -348,43 +333,31 @@ class Command:
|
|||||||
# -- External world manipulation -----------------------------------
|
# -- External world manipulation -----------------------------------
|
||||||
|
|
||||||
def warn(self, msg):
|
def warn(self, msg):
|
||||||
sys.stderr.write("warning: %s: %s\n" %
|
sys.stderr.write("warning: %s: %s\n" % (self.get_command_name(), msg))
|
||||||
(self.get_command_name(), msg))
|
|
||||||
|
|
||||||
|
|
||||||
def execute(self, func, args, msg=None, level=1):
|
def execute(self, func, args, msg=None, level=1):
|
||||||
util.execute(func, args, msg, dry_run=self.dry_run)
|
util.execute(func, args, msg, dry_run=self.dry_run)
|
||||||
|
|
||||||
|
|
||||||
def mkpath(self, name, mode=0o777):
|
def mkpath(self, name, mode=0o777):
|
||||||
dir_util.mkpath(name, mode, dry_run=self.dry_run)
|
dir_util.mkpath(name, mode, dry_run=self.dry_run)
|
||||||
|
|
||||||
|
def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1,
|
||||||
def copy_file (self, infile, outfile,
|
link=None, level=1):
|
||||||
preserve_mode=1, preserve_times=1, link=None, level=1):
|
|
||||||
"""Copy a file respecting verbose, dry-run and force flags. (The
|
"""Copy a file respecting verbose, dry-run and force flags. (The
|
||||||
former two default to whatever is in the Distribution object, and
|
former two default to whatever is in the Distribution object, and
|
||||||
the latter defaults to false for commands that don't define it.)"""
|
the latter defaults to false for commands that don't define it.)"""
|
||||||
|
return file_util.copy_file(infile, outfile, preserve_mode,
|
||||||
return file_util.copy_file(
|
preserve_times, not self.force, link,
|
||||||
infile, outfile,
|
|
||||||
preserve_mode, preserve_times,
|
|
||||||
not self.force,
|
|
||||||
link,
|
|
||||||
dry_run=self.dry_run)
|
dry_run=self.dry_run)
|
||||||
|
|
||||||
|
def copy_tree (self, infile, outfile, preserve_mode=1, preserve_times=1,
|
||||||
def copy_tree (self, infile, outfile,
|
preserve_symlinks=0, level=1):
|
||||||
preserve_mode=1, preserve_times=1, preserve_symlinks=0,
|
|
||||||
level=1):
|
|
||||||
"""Copy an entire directory tree respecting verbose, dry-run,
|
"""Copy an entire directory tree respecting verbose, dry-run,
|
||||||
and force flags.
|
and force flags.
|
||||||
"""
|
"""
|
||||||
return dir_util.copy_tree(
|
return dir_util.copy_tree(infile, outfile, preserve_mode,
|
||||||
infile, outfile,
|
preserve_times, preserve_symlinks,
|
||||||
preserve_mode,preserve_times,preserve_symlinks,
|
not self.force, dry_run=self.dry_run)
|
||||||
not self.force,
|
|
||||||
dry_run=self.dry_run)
|
|
||||||
|
|
||||||
def move_file (self, src, dst, level=1):
|
def move_file (self, src, dst, level=1):
|
||||||
"""Move a file respectin dry-run flag."""
|
"""Move a file respectin dry-run flag."""
|
||||||
@ -395,10 +368,9 @@ class Command:
|
|||||||
from distutils.spawn import spawn
|
from distutils.spawn import spawn
|
||||||
spawn(cmd, search_path, dry_run=self.dry_run)
|
spawn(cmd, search_path, dry_run=self.dry_run)
|
||||||
|
|
||||||
def make_archive (self, base_name, format,
|
def make_archive(self, base_name, format, root_dir=None, base_dir=None):
|
||||||
root_dir=None, base_dir=None):
|
return archive_util.make_archive(base_name, format, root_dir, base_dir,
|
||||||
return archive_util.make_archive(
|
dry_run=self.dry_run)
|
||||||
base_name, format, root_dir, base_dir, dry_run=self.dry_run)
|
|
||||||
|
|
||||||
|
|
||||||
def make_file(self, infiles, outfile, func, args,
|
def make_file(self, infiles, outfile, func, args,
|
||||||
@ -412,8 +384,7 @@ class Command:
|
|||||||
timestamp checks.
|
timestamp checks.
|
||||||
"""
|
"""
|
||||||
if exec_msg is None:
|
if exec_msg is None:
|
||||||
exec_msg = "generating %s from %s" % \
|
exec_msg = "generating %s from %s" % (outfile, ', '.join(infiles))
|
||||||
(outfile, ', '.join(infiles))
|
|
||||||
if skip_msg is None:
|
if skip_msg is None:
|
||||||
skip_msg = "skipping %s (inputs unchanged)" % outfile
|
skip_msg = "skipping %s (inputs unchanged)" % outfile
|
||||||
|
|
||||||
@ -422,23 +393,18 @@ class Command:
|
|||||||
if isinstance(infiles, basestring):
|
if isinstance(infiles, basestring):
|
||||||
infiles = (infiles,)
|
infiles = (infiles,)
|
||||||
elif not isinstance(infiles, (list, tuple)):
|
elif not isinstance(infiles, (list, tuple)):
|
||||||
raise TypeError, \
|
raise TypeError(
|
||||||
"'infiles' must be a string, or a list or tuple of strings"
|
"'infiles' must be a string, or a list or tuple of strings")
|
||||||
|
|
||||||
# If 'outfile' must be regenerated (either because it doesn't
|
# If 'outfile' must be regenerated (either because it doesn't
|
||||||
# exist, is out-of-date, or the 'force' flag is true) then
|
# exist, is out-of-date, or the 'force' flag is true) then
|
||||||
# perform the action that presumably regenerates it
|
# perform the action that presumably regenerates it
|
||||||
if self.force or dep_util.newer_group (infiles, outfile):
|
if self.force or dep_util.newer_group (infiles, outfile):
|
||||||
self.execute(func, args, exec_msg, level)
|
self.execute(func, args, exec_msg, level)
|
||||||
|
|
||||||
# Otherwise, print the "skip" message
|
# Otherwise, print the "skip" message
|
||||||
else:
|
else:
|
||||||
log.debug(skip_msg)
|
log.debug(skip_msg)
|
||||||
|
|
||||||
# make_file ()
|
|
||||||
|
|
||||||
# class Command
|
|
||||||
|
|
||||||
|
|
||||||
# XXX 'install_misc' class not currently used -- it was the base class for
|
# XXX 'install_misc' class not currently used -- it was the base class for
|
||||||
# both 'install_scripts' and 'install_data', but they outgrew it. It might
|
# both 'install_scripts' and 'install_data', but they outgrew it. It might
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
Package containing implementation of all the standard Distutils
|
Package containing implementation of all the standard Distutils
|
||||||
commands."""
|
commands."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
__all__ = ['build',
|
__all__ = ['build',
|
||||||
|
@ -3,12 +3,9 @@
|
|||||||
Implements the Distutils 'bdist' command (create a built [binary]
|
Implements the Distutils 'bdist' command (create a built [binary]
|
||||||
distribution)."""
|
distribution)."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from types import *
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.util import get_platform
|
from distutils.util import get_platform
|
||||||
@ -91,9 +88,6 @@ class bdist (Command):
|
|||||||
self.dist_dir = None
|
self.dist_dir = None
|
||||||
self.skip_build = 0
|
self.skip_build = 0
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
# have to finalize 'plat_name' before 'bdist_base'
|
# have to finalize 'plat_name' before 'bdist_base'
|
||||||
if self.plat_name is None:
|
if self.plat_name is None:
|
||||||
@ -112,25 +106,21 @@ class bdist (Command):
|
|||||||
try:
|
try:
|
||||||
self.formats = [self.default_format[os.name]]
|
self.formats = [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)
|
||||||
|
|
||||||
if self.dist_dir is None:
|
if self.dist_dir is None:
|
||||||
self.dist_dir = "dist"
|
self.dist_dir = "dist"
|
||||||
|
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# Figure out which sub-commands we need to run.
|
# Figure out which sub-commands we need to run.
|
||||||
commands = []
|
commands = []
|
||||||
for format in self.formats:
|
for format in self.formats:
|
||||||
try:
|
try:
|
||||||
commands.append(self.format_command[format][0])
|
commands.append(self.format_command[format][0])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise DistutilsOptionError, "invalid format '%s'" % format
|
raise DistutilsOptionError("invalid format '%s'" % format)
|
||||||
|
|
||||||
# Reinitialize and run each command.
|
# Reinitialize and run each command.
|
||||||
for i in range(len(self.formats)):
|
for i in range(len(self.formats)):
|
||||||
@ -144,7 +134,3 @@ class bdist (Command):
|
|||||||
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()
|
|
||||||
|
|
||||||
# class bdist
|
|
||||||
|
@ -4,8 +4,6 @@ Implements the Distutils 'bdist_dumb' command (create a "dumb" built
|
|||||||
distribution -- i.e., just an archive to be unpacked under $prefix or
|
distribution -- i.e., just an archive to be unpacked under $prefix or
|
||||||
$exec_prefix)."""
|
$exec_prefix)."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -45,7 +43,6 @@ class bdist_dumb (Command):
|
|||||||
'nt': 'zip',
|
'nt': 'zip',
|
||||||
'os2': 'zip' }
|
'os2': 'zip' }
|
||||||
|
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
self.bdist_dir = None
|
self.bdist_dir = None
|
||||||
self.plat_name = None
|
self.plat_name = None
|
||||||
@ -55,11 +52,7 @@ class bdist_dumb (Command):
|
|||||||
self.skip_build = 0
|
self.skip_build = 0
|
||||||
self.relative = 0
|
self.relative = 0
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
|
||||||
if self.bdist_dir is None:
|
if self.bdist_dir is None:
|
||||||
bdist_base = self.get_finalized_command('bdist').bdist_base
|
bdist_base = self.get_finalized_command('bdist').bdist_base
|
||||||
self.bdist_dir = os.path.join(bdist_base, 'dumb')
|
self.bdist_dir = os.path.join(bdist_base, 'dumb')
|
||||||
@ -68,19 +61,15 @@ class bdist_dumb (Command):
|
|||||||
try:
|
try:
|
||||||
self.format = 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 dumb built distributions " +
|
"don't know how to create dumb built distributions "
|
||||||
"on platform %s") % os.name
|
"on platform %s" % os.name)
|
||||||
|
|
||||||
self.set_undefined_options('bdist',
|
self.set_undefined_options('bdist',
|
||||||
('dist_dir', 'dist_dir'),
|
('dist_dir', 'dist_dir'),
|
||||||
('plat_name', 'plat_name'))
|
('plat_name', 'plat_name'))
|
||||||
|
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
if not self.skip_build:
|
if not self.skip_build:
|
||||||
self.run_command('build')
|
self.run_command('build')
|
||||||
|
|
||||||
@ -108,8 +97,8 @@ class bdist_dumb (Command):
|
|||||||
else:
|
else:
|
||||||
if (self.distribution.has_ext_modules() and
|
if (self.distribution.has_ext_modules() and
|
||||||
(install.install_base != install.install_platbase)):
|
(install.install_base != install.install_platbase)):
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError(
|
||||||
("can't make a dumb built distribution where "
|
"can't make a dumb built distribution where "
|
||||||
"base and platbase are different (%s, %s)"
|
"base and platbase are different (%s, %s)"
|
||||||
% (repr(install.install_base),
|
% (repr(install.install_base),
|
||||||
repr(install.install_platbase)))
|
repr(install.install_platbase)))
|
||||||
@ -129,7 +118,3 @@ class bdist_dumb (Command):
|
|||||||
|
|
||||||
if not self.keep_temp:
|
if not self.keep_temp:
|
||||||
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
||||||
|
|
||||||
# run()
|
|
||||||
|
|
||||||
# class bdist_dumb
|
|
||||||
|
@ -133,28 +133,27 @@ class bdist_msi (Command):
|
|||||||
if self.target_version:
|
if self.target_version:
|
||||||
if not self.skip_build and self.distribution.has_ext_modules()\
|
if not self.skip_build and self.distribution.has_ext_modules()\
|
||||||
and self.target_version != short_version:
|
and self.target_version != short_version:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"target version can only be %s, or the '--skip_build'" \
|
"target version can only be %s, or the '--skip_build'"
|
||||||
" option must be specified" % (short_version,)
|
" option must be specified" % (short_version,))
|
||||||
else:
|
else:
|
||||||
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'))
|
||||||
|
|
||||||
if self.pre_install_script:
|
if self.pre_install_script:
|
||||||
raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"
|
raise DistutilsOptionError(
|
||||||
|
"the pre-install-script feature is not yet implemented")
|
||||||
|
|
||||||
if self.install_script:
|
if self.install_script:
|
||||||
for script in self.distribution.scripts:
|
for script in self.distribution.scripts:
|
||||||
if self.install_script == os.path.basename(script):
|
if self.install_script == os.path.basename(script):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"install_script '%s' not found in scripts" % \
|
"install_script '%s' not found in scripts"
|
||||||
self.install_script
|
% self.install_script)
|
||||||
self.install_script_key = None
|
self.install_script_key = None
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if not self.skip_build:
|
if not self.skip_build:
|
||||||
@ -263,7 +262,8 @@ class bdist_msi (Command):
|
|||||||
key = dir.add_file(file)
|
key = dir.add_file(file)
|
||||||
if file==self.install_script:
|
if file==self.install_script:
|
||||||
if self.install_script_key:
|
if self.install_script_key:
|
||||||
raise DistutilsOptionError, "Multiple files with name %s" % file
|
raise DistutilsOptionError(
|
||||||
|
"Multiple files with name %s" % file)
|
||||||
self.install_script_key = '[#%s]' % key
|
self.install_script_key = '[#%s]' % key
|
||||||
|
|
||||||
cab.commit(db)
|
cab.commit(db)
|
||||||
|
@ -3,13 +3,10 @@
|
|||||||
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
|
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
|
||||||
distributions)."""
|
distributions)."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
import glob
|
import glob
|
||||||
from types import *
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.debug import DEBUG
|
from distutils.debug import DEBUG
|
||||||
from distutils.util import get_platform
|
from distutils.util import get_platform
|
||||||
@ -180,15 +177,12 @@ class bdist_rpm (Command):
|
|||||||
|
|
||||||
self.force_arch = None
|
self.force_arch = None
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
|
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
|
||||||
if self.rpm_base is None:
|
if self.rpm_base is None:
|
||||||
if not self.rpm3_mode:
|
if not self.rpm3_mode:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"you must specify --rpm-base in RPM 2 mode"
|
"you must specify --rpm-base in RPM 2 mode")
|
||||||
self.rpm_base = os.path.join(self.bdist_base, "rpm")
|
self.rpm_base = os.path.join(self.bdist_base, "rpm")
|
||||||
|
|
||||||
if self.python is None:
|
if self.python is None:
|
||||||
@ -197,16 +191,15 @@ class bdist_rpm (Command):
|
|||||||
else:
|
else:
|
||||||
self.python = "python"
|
self.python = "python"
|
||||||
elif self.fix_python:
|
elif self.fix_python:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"--python and --fix-python are mutually exclusive options"
|
"--python and --fix-python are mutually exclusive options")
|
||||||
|
|
||||||
if os.name != 'posix':
|
if os.name != 'posix':
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError("don't know how to create RPM "
|
||||||
("don't know how to create RPM "
|
|
||||||
"distributions on platform %s" % os.name)
|
"distributions on platform %s" % os.name)
|
||||||
if self.binary_only and self.source_only:
|
if self.binary_only and self.source_only:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"cannot supply both '--source-only' and '--binary-only'"
|
"cannot supply both '--source-only' and '--binary-only'")
|
||||||
|
|
||||||
# don't pass CFLAGS to pure python distributions
|
# don't pass CFLAGS to pure python distributions
|
||||||
if not self.distribution.has_ext_modules():
|
if not self.distribution.has_ext_modules():
|
||||||
@ -215,8 +208,6 @@ class bdist_rpm (Command):
|
|||||||
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
|
||||||
self.finalize_package_data()
|
self.finalize_package_data()
|
||||||
|
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
def finalize_package_data(self):
|
def finalize_package_data(self):
|
||||||
self.ensure_string('group', "Development/Libraries")
|
self.ensure_string('group', "Development/Libraries")
|
||||||
self.ensure_string('vendor',
|
self.ensure_string('vendor',
|
||||||
@ -224,7 +215,7 @@ class bdist_rpm (Command):
|
|||||||
self.distribution.get_contact_email()))
|
self.distribution.get_contact_email()))
|
||||||
self.ensure_string('packager')
|
self.ensure_string('packager')
|
||||||
self.ensure_string_list('doc_files')
|
self.ensure_string_list('doc_files')
|
||||||
if type(self.doc_files) is ListType:
|
if isinstance(self.doc_files, list):
|
||||||
for readme in ('README', 'README.txt'):
|
for readme in ('README', 'README.txt'):
|
||||||
if os.path.exists(readme) and readme not in self.doc_files:
|
if os.path.exists(readme) and readme not in self.doc_files:
|
||||||
self.doc_files.append(readme)
|
self.doc_files.append(readme)
|
||||||
@ -261,11 +252,8 @@ class bdist_rpm (Command):
|
|||||||
self.ensure_string_list('obsoletes')
|
self.ensure_string_list('obsoletes')
|
||||||
|
|
||||||
self.ensure_string('force_arch')
|
self.ensure_string('force_arch')
|
||||||
# finalize_package_data ()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print("before _get_package_data():")
|
print("before _get_package_data():")
|
||||||
print("vendor =", self.vendor)
|
print("vendor =", self.vendor)
|
||||||
@ -315,9 +303,8 @@ class bdist_rpm (Command):
|
|||||||
if os.path.exists(self.icon):
|
if os.path.exists(self.icon):
|
||||||
self.copy_file(self.icon, source_dir)
|
self.copy_file(self.icon, source_dir)
|
||||||
else:
|
else:
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"icon file '%s' does not exist" % self.icon
|
"icon file '%s' does not exist" % self.icon)
|
||||||
|
|
||||||
|
|
||||||
# build package
|
# build package
|
||||||
log.info("building RPMs")
|
log.info("building RPMs")
|
||||||
@ -350,7 +337,7 @@ class bdist_rpm (Command):
|
|||||||
out = os.popen(q_cmd)
|
out = os.popen(q_cmd)
|
||||||
binary_rpms = []
|
binary_rpms = []
|
||||||
source_rpm = None
|
source_rpm = None
|
||||||
while 1:
|
while True:
|
||||||
line = out.readline()
|
line = out.readline()
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
@ -378,7 +365,6 @@ class bdist_rpm (Command):
|
|||||||
rpm = os.path.join(rpm_dir['RPMS'], rpm)
|
rpm = os.path.join(rpm_dir['RPMS'], rpm)
|
||||||
if os.path.exists(rpm):
|
if os.path.exists(rpm):
|
||||||
self.move_file(rpm, self.dist_dir)
|
self.move_file(rpm, self.dist_dir)
|
||||||
# run()
|
|
||||||
|
|
||||||
def _dist_path(self, path):
|
def _dist_path(self, path):
|
||||||
return os.path.join(self.dist_dir, os.path.basename(path))
|
return os.path.join(self.dist_dir, os.path.basename(path))
|
||||||
@ -438,7 +424,7 @@ class bdist_rpm (Command):
|
|||||||
'Obsoletes',
|
'Obsoletes',
|
||||||
):
|
):
|
||||||
val = getattr(self, field.lower())
|
val = getattr(self, field.lower())
|
||||||
if type(val) is ListType:
|
if isinstance(val, list):
|
||||||
spec_file.append('%s: %s' % (field, ' '.join(val)))
|
spec_file.append('%s: %s' % (field, ' '.join(val)))
|
||||||
elif val is not None:
|
elif val is not None:
|
||||||
spec_file.append('%s: %s' % (field, val))
|
spec_file.append('%s: %s' % (field, val))
|
||||||
@ -536,8 +522,6 @@ class bdist_rpm (Command):
|
|||||||
|
|
||||||
return spec_file
|
return spec_file
|
||||||
|
|
||||||
# _make_spec_file ()
|
|
||||||
|
|
||||||
def _format_changelog(self, changelog):
|
def _format_changelog(self, changelog):
|
||||||
"""Format the changelog correctly and convert it to a list of strings
|
"""Format the changelog correctly and convert it to a list of strings
|
||||||
"""
|
"""
|
||||||
@ -558,7 +542,3 @@ class bdist_rpm (Command):
|
|||||||
del new_changelog[0]
|
del new_changelog[0]
|
||||||
|
|
||||||
return new_changelog
|
return new_changelog
|
||||||
|
|
||||||
# _format_changelog()
|
|
||||||
|
|
||||||
# class bdist_rpm
|
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
Implements the Distutils 'bdist_wininst' command: create a windows installer
|
Implements the Distutils 'bdist_wininst' command: create a windows installer
|
||||||
exe-program."""
|
exe-program."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
@ -65,8 +63,6 @@ class bdist_wininst (Command):
|
|||||||
self.install_script = None
|
self.install_script = None
|
||||||
self.pre_install_script = None
|
self.pre_install_script = None
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
if self.bdist_dir is None:
|
if self.bdist_dir is None:
|
||||||
@ -77,9 +73,9 @@ class bdist_wininst (Command):
|
|||||||
if not self.skip_build and self.distribution.has_ext_modules():
|
if not self.skip_build and self.distribution.has_ext_modules():
|
||||||
short_version = get_python_version()
|
short_version = get_python_version()
|
||||||
if self.target_version and self.target_version != short_version:
|
if self.target_version and self.target_version != short_version:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"target version can only be %s, or the '--skip_build'" \
|
"target version can only be %s, or the '--skip_build'" \
|
||||||
" option must be specified" % (short_version,)
|
" option must be specified" % (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'))
|
||||||
@ -89,11 +85,9 @@ class bdist_wininst (Command):
|
|||||||
if self.install_script == os.path.basename(script):
|
if self.install_script == os.path.basename(script):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"install_script '%s' not found in scripts" % \
|
"install_script '%s' not found in scripts"
|
||||||
self.install_script
|
% self.install_script)
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if (sys.platform != "win32" and
|
if (sys.platform != "win32" and
|
||||||
@ -175,11 +169,8 @@ class bdist_wininst (Command):
|
|||||||
if not self.keep_temp:
|
if not self.keep_temp:
|
||||||
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
remove_tree(self.bdist_dir, dry_run=self.dry_run)
|
||||||
|
|
||||||
# run()
|
|
||||||
|
|
||||||
def get_inidata(self):
|
def get_inidata(self):
|
||||||
# Return data describing the installation.
|
# Return data describing the installation.
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
metadata = self.distribution.metadata
|
metadata = self.distribution.metadata
|
||||||
|
|
||||||
@ -222,8 +213,6 @@ class bdist_wininst (Command):
|
|||||||
lines.append("build_info=%s" % build_info)
|
lines.append("build_info=%s" % build_info)
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
# get_inidata()
|
|
||||||
|
|
||||||
def create_exe(self, arcname, fullname, bitmap=None):
|
def create_exe(self, arcname, fullname, bitmap=None):
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
@ -272,8 +261,6 @@ class bdist_wininst (Command):
|
|||||||
file.write(header)
|
file.write(header)
|
||||||
file.write(open(arcname, "rb").read())
|
file.write(open(arcname, "rb").read())
|
||||||
|
|
||||||
# create_exe()
|
|
||||||
|
|
||||||
def get_installer_filename(self, fullname):
|
def get_installer_filename(self, fullname):
|
||||||
# Factored out to allow overriding in subclasses
|
# Factored out to allow overriding in subclasses
|
||||||
if self.target_version:
|
if self.target_version:
|
||||||
@ -286,7 +273,6 @@ class bdist_wininst (Command):
|
|||||||
installer_name = os.path.join(self.dist_dir,
|
installer_name = os.path.join(self.dist_dir,
|
||||||
"%s.win32.exe" % fullname)
|
"%s.win32.exe" % fullname)
|
||||||
return installer_name
|
return installer_name
|
||||||
# get_installer_filename()
|
|
||||||
|
|
||||||
def get_exe_bytes(self):
|
def get_exe_bytes(self):
|
||||||
from distutils.msvccompiler import get_build_version
|
from distutils.msvccompiler import get_build_version
|
||||||
@ -320,4 +306,3 @@ class bdist_wininst (Command):
|
|||||||
# used for python. XXX What about mingw, borland, and so on?
|
# used for python. XXX What about mingw, borland, and so on?
|
||||||
filename = os.path.join(directory, "wininst-%s.exe" % bv)
|
filename = os.path.join(directory, "wininst-%s.exe" % bv)
|
||||||
return open(filename, "rb").read()
|
return open(filename, "rb").read()
|
||||||
# class bdist_wininst
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Implements the Distutils 'build' command."""
|
Implements the Distutils 'build' command."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
@ -66,7 +64,6 @@ class build (Command):
|
|||||||
self.executable = None
|
self.executable = None
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
|
||||||
plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
|
plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
|
||||||
|
|
||||||
# 'build_purelib' and 'build_platlib' just default to 'lib' and
|
# 'build_purelib' and 'build_platlib' just default to 'lib' and
|
||||||
@ -98,11 +95,8 @@ class build (Command):
|
|||||||
|
|
||||||
if self.executable is None:
|
if self.executable is None:
|
||||||
self.executable = os.path.normpath(sys.executable)
|
self.executable = os.path.normpath(sys.executable)
|
||||||
# finalize_options ()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# Run all relevant sub-commands. This will be some subset of:
|
# Run all relevant sub-commands. This will be some subset of:
|
||||||
# - build_py - pure Python modules
|
# - build_py - pure Python modules
|
||||||
# - build_clib - standalone C libraries
|
# - build_clib - standalone C libraries
|
||||||
@ -132,5 +126,3 @@ class build (Command):
|
|||||||
('build_ext', has_ext_modules),
|
('build_ext', has_ext_modules),
|
||||||
('build_scripts', has_scripts),
|
('build_scripts', has_scripts),
|
||||||
]
|
]
|
||||||
|
|
||||||
# class build
|
|
||||||
|
@ -4,8 +4,6 @@ Implements the Distutils 'build_clib' command, to build a C/C++ library
|
|||||||
that is included in the module distribution and needed by an extension
|
that is included in the module distribution and needed by an extension
|
||||||
module."""
|
module."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +17,6 @@ __revision__ = "$Id$"
|
|||||||
# cut 'n paste. Sigh.
|
# cut 'n paste. Sigh.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from types import *
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.sysconfig import customize_compiler
|
from distutils.sysconfig import customize_compiler
|
||||||
@ -69,11 +66,8 @@ class build_clib (Command):
|
|||||||
self.force = 0
|
self.force = 0
|
||||||
self.compiler = None
|
self.compiler = None
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
|
||||||
# This might be confusing: both build-clib and build-temp default
|
# This might be confusing: both build-clib and build-temp default
|
||||||
# to build-temp as defined by the "build" command. This is because
|
# to build-temp as defined by the "build" command. This is because
|
||||||
# I think that C libraries are really just temporary build
|
# I think that C libraries are really just temporary build
|
||||||
@ -98,11 +92,8 @@ class build_clib (Command):
|
|||||||
# XXX same as for build_ext -- what about 'self.define' and
|
# XXX same as for build_ext -- what about 'self.define' and
|
||||||
# 'self.undef' ?
|
# 'self.undef' ?
|
||||||
|
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
if not self.libraries:
|
if not self.libraries:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -125,8 +116,6 @@ class build_clib (Command):
|
|||||||
|
|
||||||
self.build_libraries(self.libraries)
|
self.build_libraries(self.libraries)
|
||||||
|
|
||||||
# run()
|
|
||||||
|
|
||||||
|
|
||||||
def check_library_list(self, libraries):
|
def check_library_list(self, libraries):
|
||||||
"""Ensure that the list of libraries (presumably provided as a
|
"""Ensure that the list of libraries (presumably provided as a
|
||||||
@ -134,42 +123,34 @@ class build_clib (Command):
|
|||||||
2-tuples, where the tuples are (library_name, build_info_dict).
|
2-tuples, where the tuples are (library_name, build_info_dict).
|
||||||
Raise DistutilsSetupError if the structure is invalid anywhere;
|
Raise DistutilsSetupError if the structure is invalid anywhere;
|
||||||
just returns otherwise."""
|
just returns otherwise."""
|
||||||
|
|
||||||
# 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 not isinstance(libraries, list):
|
||||||
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 not isinstance(lib, tuple) 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 isinstance(lib[0], basestring):
|
if isinstance(lib[0], basestring):
|
||||||
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)")
|
||||||
if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):
|
if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):
|
||||||
raise DistutilsSetupError, \
|
raise DistutilsSetupError("bad library name '%s': "
|
||||||
("bad library name '%s': " +
|
"may not contain directory separators" % lib[0])
|
||||||
"may not contain directory separators") % \
|
|
||||||
lib[0]
|
|
||||||
|
|
||||||
if type(lib[1]) is not DictionaryType:
|
if not isinstance(lib[1], dict):
|
||||||
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)")
|
||||||
# for lib
|
|
||||||
|
|
||||||
# check_library_list ()
|
|
||||||
|
|
||||||
|
|
||||||
def get_library_names(self):
|
def get_library_names(self):
|
||||||
# Assume the library list is valid -- 'check_library_list()' is
|
# Assume the library list is valid -- 'check_library_list()' is
|
||||||
# called from 'finalize_options()', so it should be!
|
# called from 'finalize_options()', so it should be!
|
||||||
|
|
||||||
if not self.libraries:
|
if not self.libraries:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -178,36 +159,30 @@ class build_clib (Command):
|
|||||||
lib_names.append(lib_name)
|
lib_names.append(lib_name)
|
||||||
return lib_names
|
return lib_names
|
||||||
|
|
||||||
# get_library_names ()
|
|
||||||
|
|
||||||
|
|
||||||
def get_source_files(self):
|
def get_source_files(self):
|
||||||
self.check_library_list(self.libraries)
|
self.check_library_list(self.libraries)
|
||||||
filenames = []
|
filenames = []
|
||||||
for (lib_name, build_info) in self.libraries:
|
for (lib_name, build_info) in self.libraries:
|
||||||
sources = build_info.get('sources')
|
sources = build_info.get('sources')
|
||||||
if (sources is None or
|
if sources is None or not isinstance(sources, (list, tuple)):
|
||||||
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)
|
||||||
|
|
||||||
filenames.extend(sources)
|
filenames.extend(sources)
|
||||||
|
|
||||||
return filenames
|
return filenames
|
||||||
# get_source_files ()
|
|
||||||
|
|
||||||
|
|
||||||
def build_libraries(self, libraries):
|
def build_libraries(self, libraries):
|
||||||
|
|
||||||
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 not isinstance(sources, (list, tuple)):
|
||||||
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)
|
||||||
|
|
||||||
log.info("building '%s' library", lib_name)
|
log.info("building '%s' library", lib_name)
|
||||||
@ -229,9 +204,3 @@ class build_clib (Command):
|
|||||||
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)
|
||||||
|
|
||||||
# for libraries
|
|
||||||
|
|
||||||
# build_libraries ()
|
|
||||||
|
|
||||||
# class build_lib
|
|
||||||
|
@ -4,12 +4,9 @@ Implements the Distutils 'build_ext' command, for building extension
|
|||||||
modules (currently limited to C extensions, should accommodate C++
|
modules (currently limited to C extensions, should accommodate C++
|
||||||
extensions ASAP)."""
|
extensions ASAP)."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
from types import *
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils.sysconfig import customize_compiler, get_python_version
|
from distutils.sysconfig import customize_compiler, get_python_version
|
||||||
@ -130,7 +127,6 @@ class build_ext (Command):
|
|||||||
|
|
||||||
self.extensions = self.distribution.ext_modules
|
self.extensions = self.distribution.ext_modules
|
||||||
|
|
||||||
|
|
||||||
# Make sure Python's include directories (for Python.h, pyconfig.h,
|
# Make sure Python's include directories (for Python.h, pyconfig.h,
|
||||||
# etc.) are in the include search path.
|
# etc.) are in the include search path.
|
||||||
py_include = sysconfig.get_python_inc()
|
py_include = sysconfig.get_python_inc()
|
||||||
@ -226,11 +222,7 @@ class build_ext (Command):
|
|||||||
else:
|
else:
|
||||||
self.swig_opts = self.swig_opts.split(' ')
|
self.swig_opts = self.swig_opts.split(' ')
|
||||||
|
|
||||||
# finalize_options ()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
from distutils.ccompiler import new_compiler
|
from distutils.ccompiler import new_compiler
|
||||||
|
|
||||||
# 'self.extensions', as supplied by setup.py, is a list of
|
# 'self.extensions', as supplied by setup.py, is a list of
|
||||||
@ -289,9 +281,6 @@ class build_ext (Command):
|
|||||||
# Now actually compile and link everything.
|
# Now actually compile and link everything.
|
||||||
self.build_extensions()
|
self.build_extensions()
|
||||||
|
|
||||||
# run ()
|
|
||||||
|
|
||||||
|
|
||||||
def check_extensions_list(self, extensions):
|
def check_extensions_list(self, extensions):
|
||||||
"""Ensure that the list of extensions (presumably provided as a
|
"""Ensure that the list of extensions (presumably provided as a
|
||||||
command option 'extensions') is valid, i.e. it is a list of
|
command option 'extensions') is valid, i.e. it is a list of
|
||||||
@ -302,34 +291,33 @@ class build_ext (Command):
|
|||||||
Raise DistutilsSetupError if the structure is invalid anywhere;
|
Raise DistutilsSetupError if the structure is invalid anywhere;
|
||||||
just returns otherwise.
|
just returns otherwise.
|
||||||
"""
|
"""
|
||||||
if type(extensions) is not ListType:
|
if not isinstance(extensions, list):
|
||||||
raise DistutilsSetupError, \
|
raise DistutilsSetupError(
|
||||||
"'ext_modules' option must be a list of Extension instances"
|
"'ext_modules' option must be a list of Extension instances")
|
||||||
|
|
||||||
for i in range(len(extensions)):
|
for i, ext in enumerate(extensions):
|
||||||
ext = extensions[i]
|
|
||||||
if isinstance(ext, Extension):
|
if isinstance(ext, Extension):
|
||||||
continue # OK! (assume type-checking done
|
continue # OK! (assume type-checking done
|
||||||
# by Extension constructor)
|
# by Extension constructor)
|
||||||
|
|
||||||
(ext_name, build_info) = ext
|
(ext_name, build_info) = ext
|
||||||
log.warn(("old-style (ext_name, build_info) tuple found in "
|
log.warn("old-style (ext_name, build_info) tuple found in "
|
||||||
"ext_modules for extension '%s'"
|
"ext_modules for extension '%s'"
|
||||||
"-- please convert to Extension instance" % ext_name))
|
"-- please convert to Extension instance" % ext_name)
|
||||||
if type(ext) is not TupleType and len(ext) != 2:
|
if not isinstance(ext, tuple) and len(ext) != 2:
|
||||||
raise DistutilsSetupError, \
|
raise DistutilsSetupError(
|
||||||
("each element of 'ext_modules' option must be an "
|
"each element of 'ext_modules' option must be an "
|
||||||
"Extension instance or 2-tuple")
|
"Extension instance or 2-tuple")
|
||||||
|
|
||||||
if not (isinstance(ext_name, basestring) and
|
if not (isinstance(ext_name, basestring) and
|
||||||
extension_name_re.match(ext_name)):
|
extension_name_re.match(ext_name)):
|
||||||
raise DistutilsSetupError, \
|
raise DistutilsSetupError(
|
||||||
("first element of each tuple in 'ext_modules' "
|
"first element of each tuple in 'ext_modules' "
|
||||||
"must be the extension name (a string)")
|
"must be the extension name (a string)")
|
||||||
|
|
||||||
if type(build_info) is not DictionaryType:
|
if not instance(build_info, DictionaryType):
|
||||||
raise DistutilsSetupError, \
|
raise DistutilsSetupError(
|
||||||
("second element of each tuple in 'ext_modules' "
|
"second element of each tuple in 'ext_modules' "
|
||||||
"must be a dictionary (build info)")
|
"must be a dictionary (build info)")
|
||||||
|
|
||||||
# OK, the (ext_name, build_info) dict is type-safe: convert it
|
# OK, the (ext_name, build_info) dict is type-safe: convert it
|
||||||
@ -361,10 +349,9 @@ class build_ext (Command):
|
|||||||
ext.define_macros = []
|
ext.define_macros = []
|
||||||
ext.undef_macros = []
|
ext.undef_macros = []
|
||||||
for macro in macros:
|
for macro in macros:
|
||||||
if not (type(macro) is TupleType and
|
if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
|
||||||
1 <= len(macro) <= 2):
|
raise DistutilsSetupError(
|
||||||
raise DistutilsSetupError, \
|
"'macros' element of build info dict "
|
||||||
("'macros' element of build info dict "
|
|
||||||
"must be 1- or 2-tuple")
|
"must be 1- or 2-tuple")
|
||||||
if len(macro) == 1:
|
if len(macro) == 1:
|
||||||
ext.undef_macros.append(macro[0])
|
ext.undef_macros.append(macro[0])
|
||||||
@ -373,11 +360,6 @@ class build_ext (Command):
|
|||||||
|
|
||||||
extensions[i] = ext
|
extensions[i] = ext
|
||||||
|
|
||||||
# for extensions
|
|
||||||
|
|
||||||
# check_extensions_list ()
|
|
||||||
|
|
||||||
|
|
||||||
def get_source_files(self):
|
def get_source_files(self):
|
||||||
self.check_extensions_list(self.extensions)
|
self.check_extensions_list(self.extensions)
|
||||||
filenames = []
|
filenames = []
|
||||||
@ -385,12 +367,9 @@ 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
|
||||||
|
|
||||||
|
|
||||||
def get_outputs(self):
|
def get_outputs(self):
|
||||||
|
|
||||||
# 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*!).
|
||||||
@ -406,8 +385,6 @@ class build_ext (Command):
|
|||||||
self.get_ext_filename(fullname)))
|
self.get_ext_filename(fullname)))
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
# get_outputs ()
|
|
||||||
|
|
||||||
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)
|
||||||
@ -417,11 +394,11 @@ class build_ext (Command):
|
|||||||
|
|
||||||
def build_extension(self, ext):
|
def build_extension(self, ext):
|
||||||
sources = ext.sources
|
sources = ext.sources
|
||||||
if sources is None or type(sources) not in (ListType, TupleType):
|
if sources is None or not isinstance(sources, (list, tuple)):
|
||||||
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)
|
||||||
@ -512,15 +489,12 @@ class build_ext (Command):
|
|||||||
build_temp=self.build_temp,
|
build_temp=self.build_temp,
|
||||||
target_lang=language)
|
target_lang=language)
|
||||||
|
|
||||||
|
|
||||||
def swig_sources(self, sources, extension):
|
def swig_sources(self, sources, extension):
|
||||||
|
|
||||||
"""Walk the list of source files in 'sources', looking for SWIG
|
"""Walk the list of source files in 'sources', looking for SWIG
|
||||||
interface (.i) files. Run SWIG on all that are found, and
|
interface (.i) files. Run SWIG on all that are found, and
|
||||||
return a modified 'sources' list with SWIG source files replaced
|
return a modified 'sources' list with SWIG source files replaced
|
||||||
by the generated C (or C++) files.
|
by the generated C (or C++) files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
new_sources = []
|
new_sources = []
|
||||||
swig_sources = []
|
swig_sources = []
|
||||||
swig_targets = {}
|
swig_targets = {}
|
||||||
@ -569,18 +543,14 @@ class build_ext (Command):
|
|||||||
|
|
||||||
return new_sources
|
return new_sources
|
||||||
|
|
||||||
# swig_sources ()
|
|
||||||
|
|
||||||
def find_swig(self):
|
def find_swig(self):
|
||||||
"""Return the name of the SWIG executable. On Unix, this is
|
"""Return the name of the SWIG executable. On Unix, this is
|
||||||
just "swig" -- it should be in the PATH. Tries a bit harder on
|
just "swig" -- it should be in the PATH. Tries a bit harder on
|
||||||
Windows.
|
Windows.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
return "swig"
|
return "swig"
|
||||||
elif os.name == "nt":
|
elif os.name == "nt":
|
||||||
|
|
||||||
# Look for SWIG in its standard installation directory on
|
# Look for SWIG in its standard installation directory on
|
||||||
# Windows (or so I presume!). If we find it there, great;
|
# Windows (or so I presume!). If we find it there, great;
|
||||||
# if not, act like Unix and assume it's in the PATH.
|
# if not, act like Unix and assume it's in the PATH.
|
||||||
@ -590,17 +560,13 @@ class build_ext (Command):
|
|||||||
return fn
|
return fn
|
||||||
else:
|
else:
|
||||||
return "swig.exe"
|
return "swig.exe"
|
||||||
|
|
||||||
elif os.name == "os2":
|
elif os.name == "os2":
|
||||||
# assume swig available in the PATH.
|
# assume swig available in the PATH.
|
||||||
return "swig.exe"
|
return "swig.exe"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError(
|
||||||
("I don't know how to find (much less run) SWIG "
|
"I don't know how to find (much less run) SWIG "
|
||||||
"on platform '%s'") % os.name
|
"on platform '%s'" % os.name)
|
||||||
|
|
||||||
# find_swig ()
|
|
||||||
|
|
||||||
# -- Name generators -----------------------------------------------
|
# -- Name generators -----------------------------------------------
|
||||||
# (extension names, filenames, whatever)
|
# (extension names, filenames, whatever)
|
||||||
@ -616,7 +582,6 @@ class build_ext (Command):
|
|||||||
of the file from which it will be loaded (eg. "foo/bar.so", or
|
of the file from which it will be loaded (eg. "foo/bar.so", or
|
||||||
"foo\bar.pyd").
|
"foo\bar.pyd").
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from distutils.sysconfig import get_config_var
|
from distutils.sysconfig import get_config_var
|
||||||
ext_path = ext_name.split('.')
|
ext_path = ext_name.split('.')
|
||||||
# OS/2 has an 8 character module (extension) limit :-(
|
# OS/2 has an 8 character module (extension) limit :-(
|
||||||
@ -634,7 +599,6 @@ class build_ext (Command):
|
|||||||
provided, "init" + module_name. Only relevant on Windows, where
|
provided, "init" + module_name. Only relevant on Windows, where
|
||||||
the .pyd file (DLL) must export the module "init" function.
|
the .pyd file (DLL) must export the module "init" function.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
initfunc_name = "init" + ext.name.split('.')[-1]
|
initfunc_name = "init" + ext.name.split('.')[-1]
|
||||||
if initfunc_name not in ext.export_symbols:
|
if initfunc_name not in ext.export_symbols:
|
||||||
ext.export_symbols.append(initfunc_name)
|
ext.export_symbols.append(initfunc_name)
|
||||||
@ -699,11 +663,9 @@ class build_ext (Command):
|
|||||||
# don't extend ext.libraries, it may be shared with other
|
# don't extend ext.libraries, it may be shared with other
|
||||||
# extensions, it is a reference to the original list
|
# extensions, it is a reference to the original list
|
||||||
return ext.libraries + [pythonlib, "m"] + extra
|
return ext.libraries + [pythonlib, "m"] + extra
|
||||||
|
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
# Don't use the default code below
|
# Don't use the default code below
|
||||||
return ext.libraries
|
return ext.libraries
|
||||||
|
|
||||||
else:
|
else:
|
||||||
from distutils import sysconfig
|
from distutils import sysconfig
|
||||||
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
|
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
|
||||||
@ -713,5 +675,3 @@ class build_ext (Command):
|
|||||||
return ext.libraries + [pythonlib]
|
return ext.libraries + [pythonlib]
|
||||||
else:
|
else:
|
||||||
return ext.libraries
|
return ext.libraries
|
||||||
|
|
||||||
# class build_ext
|
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
Implements the Distutils 'build_py' command."""
|
Implements the Distutils 'build_py' command."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from types import *
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
@ -32,7 +29,6 @@ class build_py (Command):
|
|||||||
boolean_options = ['compile', 'force']
|
boolean_options = ['compile', 'force']
|
||||||
negative_opt = {'no-compile' : 'compile'}
|
negative_opt = {'no-compile' : 'compile'}
|
||||||
|
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
self.build_lib = None
|
self.build_lib = None
|
||||||
self.py_modules = None
|
self.py_modules = None
|
||||||
@ -61,15 +57,14 @@ class build_py (Command):
|
|||||||
|
|
||||||
# Ick, copied straight from install_lib.py (fancy_getopt needs a
|
# Ick, copied straight from install_lib.py (fancy_getopt needs a
|
||||||
# type system! Hell, *everything* needs a type system!!!)
|
# type system! Hell, *everything* needs a type system!!!)
|
||||||
if type(self.optimize) is not IntType:
|
if not isinstance(self.optimize, int):
|
||||||
try:
|
try:
|
||||||
self.optimize = int(self.optimize)
|
self.optimize = int(self.optimize)
|
||||||
assert 0 <= self.optimize <= 2
|
assert 0 <= self.optimize <= 2
|
||||||
except (ValueError, AssertionError):
|
except (ValueError, AssertionError):
|
||||||
raise DistutilsOptionError, "optimize must be 0, 1, or 2"
|
raise DistutilsOptionError("optimize must be 0, 1, or 2")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# XXX copy_file by default preserves atime and mtime. IMHO this is
|
# XXX copy_file by default preserves atime and mtime. IMHO this is
|
||||||
# the right thing to do, but perhaps it should be an option -- in
|
# the right thing to do, but perhaps it should be an option -- in
|
||||||
# particular, a site administrator might want installed files to
|
# particular, a site administrator might want installed files to
|
||||||
@ -99,8 +94,6 @@ class build_py (Command):
|
|||||||
|
|
||||||
self.byte_compile(self.get_outputs(include_bytecode=0))
|
self.byte_compile(self.get_outputs(include_bytecode=0))
|
||||||
|
|
||||||
# run ()
|
|
||||||
|
|
||||||
def get_data_files(self):
|
def get_data_files(self):
|
||||||
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
|
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
|
||||||
data = []
|
data = []
|
||||||
@ -151,7 +144,6 @@ class build_py (Command):
|
|||||||
"""Return the directory, relative to the top of the source
|
"""Return the directory, relative to the top of the source
|
||||||
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 = package.split('.')
|
path = package.split('.')
|
||||||
|
|
||||||
if not self.package_dir:
|
if not self.package_dir:
|
||||||
@ -187,23 +179,19 @@ class build_py (Command):
|
|||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# get_package_dir ()
|
|
||||||
|
|
||||||
|
|
||||||
def check_package(self, package, package_dir):
|
def check_package(self, package, package_dir):
|
||||||
|
|
||||||
# Empty dir name means current directory, which we can probably
|
# Empty dir name means current directory, which we can probably
|
||||||
# assume exists. Also, os.path.exists and isdir don't know about
|
# assume exists. Also, os.path.exists and isdir don't know about
|
||||||
# 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:
|
||||||
@ -218,18 +206,12 @@ class build_py (Command):
|
|||||||
# __init__.py doesn't exist -- so don't return the filename.
|
# __init__.py doesn't exist -- so don't return the filename.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# check_package ()
|
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
log.warn("file %s (for module %s) not found", module_file, module)
|
log.warn("file %s (for module %s) not found", module_file, module)
|
||||||
return 0
|
return False
|
||||||
else:
|
else:
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
# check_module ()
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
@ -246,7 +228,6 @@ class build_py (Command):
|
|||||||
self.debug_print("excluding %s" % setup_script)
|
self.debug_print("excluding %s" % setup_script)
|
||||||
return modules
|
return modules
|
||||||
|
|
||||||
|
|
||||||
def find_modules(self):
|
def find_modules(self):
|
||||||
"""Finds individually-specified Python modules, ie. those listed by
|
"""Finds individually-specified Python modules, ie. those listed by
|
||||||
module name in 'self.py_modules'. Returns a list of tuples (package,
|
module name in 'self.py_modules'. Returns a list of tuples (package,
|
||||||
@ -256,7 +237,6 @@ class build_py (Command):
|
|||||||
".py" file (relative to the distribution root) that implements the
|
".py" file (relative to the distribution root) that implements the
|
||||||
module.
|
module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Map package names to tuples of useful info about the package:
|
# Map package names to tuples of useful info about the package:
|
||||||
# (package_dir, checked)
|
# (package_dir, checked)
|
||||||
# package_dir - the directory where we'll find source files for
|
# package_dir - the directory where we'll find source files for
|
||||||
@ -272,7 +252,6 @@ class build_py (Command):
|
|||||||
# just the "package" for a toplevel is empty (either an empty
|
# just the "package" for a toplevel is empty (either an empty
|
||||||
# string or empty list, depending on context). Differences:
|
# string or empty list, depending on context). Differences:
|
||||||
# - 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 = module.split('.')
|
path = module.split('.')
|
||||||
package = '.'.join(path[0:-1])
|
package = '.'.join(path[0:-1])
|
||||||
@ -301,16 +280,12 @@ class build_py (Command):
|
|||||||
|
|
||||||
return modules
|
return modules
|
||||||
|
|
||||||
# find_modules ()
|
|
||||||
|
|
||||||
|
|
||||||
def find_all_modules(self):
|
def find_all_modules(self):
|
||||||
"""Compute the list of all modules that will be built, whether
|
"""Compute the list of all modules that will be built, whether
|
||||||
they are specified one-module-at-a-time ('self.py_modules') or
|
they are specified one-module-at-a-time ('self.py_modules') or
|
||||||
by whole packages ('self.packages'). Return a list of tuples
|
by whole packages ('self.packages'). Return a list of tuples
|
||||||
(package, module, module_file), just like 'find_modules()' and
|
(package, module, module_file), just like 'find_modules()' and
|
||||||
'find_package_modules()' do."""
|
'find_package_modules()' do."""
|
||||||
|
|
||||||
modules = []
|
modules = []
|
||||||
if self.py_modules:
|
if self.py_modules:
|
||||||
modules.extend(self.find_modules())
|
modules.extend(self.find_modules())
|
||||||
@ -319,27 +294,15 @@ class build_py (Command):
|
|||||||
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
|
||||||
|
|
||||||
# find_all_modules ()
|
|
||||||
|
|
||||||
|
|
||||||
def get_source_files(self):
|
def get_source_files(self):
|
||||||
|
return [module[-1] for module in self.find_all_modules()]
|
||||||
modules = self.find_all_modules()
|
|
||||||
filenames = []
|
|
||||||
for module in modules:
|
|
||||||
filenames.append(module[-1])
|
|
||||||
|
|
||||||
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 os.path.join(*outfile_path)
|
return os.path.join(*outfile_path)
|
||||||
|
|
||||||
|
|
||||||
def get_outputs(self, include_bytecode=1):
|
def get_outputs(self, include_bytecode=1):
|
||||||
modules = self.find_all_modules()
|
modules = self.find_all_modules()
|
||||||
outputs = []
|
outputs = []
|
||||||
@ -361,13 +324,12 @@ class build_py (Command):
|
|||||||
|
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
|
|
||||||
def build_module(self, module, module_file, package):
|
def build_module(self, module, module_file, package):
|
||||||
if isinstance(package, basestring):
|
if isinstance(package, basestring):
|
||||||
package = package.split('.')
|
package = package.split('.')
|
||||||
elif type(package) not in (ListType, TupleType):
|
elif not isinstance(package, (list, tuple)):
|
||||||
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
|
||||||
@ -377,25 +339,17 @@ class build_py (Command):
|
|||||||
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):
|
||||||
|
|
||||||
modules = self.find_modules()
|
modules = self.find_modules()
|
||||||
for (package, module, module_file) in modules:
|
for (package, module, module_file) in modules:
|
||||||
|
|
||||||
# Now "build" the module -- ie. copy the source file to
|
# Now "build" the module -- ie. copy the source file to
|
||||||
# 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 ()
|
|
||||||
|
|
||||||
|
|
||||||
def build_packages(self):
|
def build_packages(self):
|
||||||
|
|
||||||
for package in self.packages:
|
for package in self.packages:
|
||||||
|
|
||||||
# Get list of (package, module, module_file) tuples based on
|
# Get list of (package, module, module_file) tuples based on
|
||||||
# scanning the package directory. 'package' is only included
|
# scanning the package directory. 'package' is only included
|
||||||
# in the tuple so that 'find_modules()' and
|
# in the tuple so that 'find_modules()' and
|
||||||
@ -414,9 +368,6 @@ class build_py (Command):
|
|||||||
assert package == package_
|
assert package == package_
|
||||||
self.build_module(module, module_file, package)
|
self.build_module(module, module_file, package)
|
||||||
|
|
||||||
# build_packages ()
|
|
||||||
|
|
||||||
|
|
||||||
def byte_compile(self, files):
|
def byte_compile(self, files):
|
||||||
from distutils.util import byte_compile
|
from distutils.util import byte_compile
|
||||||
prefix = self.build_lib
|
prefix = self.build_lib
|
||||||
@ -426,12 +377,9 @@ class build_py (Command):
|
|||||||
# XXX this code is essentially the same as the 'byte_compile()
|
# XXX this code is essentially the same as the 'byte_compile()
|
||||||
# method of the "install_lib" command, except for the determination
|
# method of the "install_lib" command, except for the determination
|
||||||
# of the 'prefix' string. Hmmm.
|
# of the 'prefix' string. Hmmm.
|
||||||
|
|
||||||
if self.compile:
|
if self.compile:
|
||||||
byte_compile(files, optimize=0,
|
byte_compile(files, optimize=0,
|
||||||
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
||||||
if self.optimize > 0:
|
if self.optimize > 0:
|
||||||
byte_compile(files, optimize=self.optimize,
|
byte_compile(files, optimize=self.optimize,
|
||||||
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
force=self.force, prefix=prefix, dry_run=self.dry_run)
|
||||||
|
|
||||||
# class build_py
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
Implements the Distutils 'build_scripts' command."""
|
Implements the Distutils 'build_scripts' command."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
@ -62,7 +60,7 @@ class build_scripts (Command):
|
|||||||
self.mkpath(self.build_dir)
|
self.mkpath(self.build_dir)
|
||||||
outfiles = []
|
outfiles = []
|
||||||
for script in self.scripts:
|
for script in self.scripts:
|
||||||
adjust = 0
|
adjust = False
|
||||||
script = convert_path(script)
|
script = convert_path(script)
|
||||||
outfile = os.path.join(self.build_dir, os.path.basename(script))
|
outfile = os.path.join(self.build_dir, os.path.basename(script))
|
||||||
outfiles.append(outfile)
|
outfiles.append(outfile)
|
||||||
@ -88,7 +86,7 @@ class build_scripts (Command):
|
|||||||
|
|
||||||
match = first_line_re.match(first_line)
|
match = first_line_re.match(first_line)
|
||||||
if match:
|
if match:
|
||||||
adjust = 1
|
adjust = True
|
||||||
post_interp = match.group(1) or ''
|
post_interp = match.group(1) or ''
|
||||||
|
|
||||||
if adjust:
|
if adjust:
|
||||||
@ -125,7 +123,3 @@ class build_scripts (Command):
|
|||||||
log.info("changing mode of %s from %o to %o",
|
log.info("changing mode of %s from %o to %o",
|
||||||
file, oldmode, newmode)
|
file, oldmode, newmode)
|
||||||
os.chmod(file, newmode)
|
os.chmod(file, newmode)
|
||||||
|
|
||||||
# copy_scripts ()
|
|
||||||
|
|
||||||
# class build_scripts
|
|
||||||
|
@ -4,8 +4,6 @@ Implements the Distutils 'clean' command."""
|
|||||||
|
|
||||||
# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
|
# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -78,5 +76,3 @@ class clean (Command):
|
|||||||
log.info("removing '%s'", self.build_base)
|
log.info("removing '%s'", self.build_base)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# class clean
|
|
||||||
|
@ -21,25 +21,13 @@ class x (Command):
|
|||||||
""),
|
""),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
self. = None
|
self. = None
|
||||||
self. = None
|
self. = None
|
||||||
self. = None
|
self. = None
|
||||||
|
|
||||||
# initialize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
if self.x is None:
|
if self.x is None:
|
||||||
self.x =
|
self.x =
|
||||||
|
|
||||||
# finalize_options()
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
|
|
||||||
# run()
|
|
||||||
|
|
||||||
# class x
|
|
||||||
|
@ -9,19 +9,15 @@ configure-like tasks: "try to compile this C code", or "figure out where
|
|||||||
this header file lives".
|
this header file lives".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
from types import *
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import DistutilsExecError
|
from distutils.errors import DistutilsExecError
|
||||||
from distutils.sysconfig import customize_compiler
|
from distutils.sysconfig import customize_compiler
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
||||||
LANG_EXT = {'c': '.c',
|
LANG_EXT = {"c": ".c", "c++": ".cxx"}
|
||||||
'c++': '.cxx'}
|
|
||||||
|
|
||||||
class config(Command):
|
class config(Command):
|
||||||
|
|
||||||
@ -86,11 +82,9 @@ class config (Command):
|
|||||||
elif isinstance(self.library_dirs, basestring):
|
elif isinstance(self.library_dirs, basestring):
|
||||||
self.library_dirs = self.library_dirs.split(os.pathsep)
|
self.library_dirs = self.library_dirs.split(os.pathsep)
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Utility methods for actual "config" commands. The interfaces are
|
# Utility methods for actual "config" commands. The interfaces are
|
||||||
# loosely based on Autoconf macros of similar names. Sub-classes
|
# loosely based on Autoconf macros of similar names. Sub-classes
|
||||||
# may use these freely.
|
# may use these freely.
|
||||||
@ -113,7 +107,6 @@ class config (Command):
|
|||||||
if self.library_dirs:
|
if self.library_dirs:
|
||||||
self.compiler.set_library_dirs(self.library_dirs)
|
self.compiler.set_library_dirs(self.library_dirs)
|
||||||
|
|
||||||
|
|
||||||
def _gen_temp_sourcefile(self, body, headers, lang):
|
def _gen_temp_sourcefile(self, body, headers, lang):
|
||||||
filename = "_configtest" + LANG_EXT[lang]
|
filename = "_configtest" + LANG_EXT[lang]
|
||||||
file = open(filename, "w")
|
file = open(filename, "w")
|
||||||
@ -143,9 +136,8 @@ class config (Command):
|
|||||||
self.compiler.compile([src], include_dirs=include_dirs)
|
self.compiler.compile([src], include_dirs=include_dirs)
|
||||||
return (src, obj)
|
return (src, obj)
|
||||||
|
|
||||||
def _link (self, body,
|
def _link(self, body, headers, include_dirs, libraries,
|
||||||
headers, include_dirs,
|
library_dirs, lang):
|
||||||
libraries, library_dirs, lang):
|
|
||||||
(src, obj) = self._compile(body, headers, include_dirs, lang)
|
(src, obj) = self._compile(body, headers, include_dirs, lang)
|
||||||
prog = os.path.splitext(os.path.basename(src))[0]
|
prog = os.path.splitext(os.path.basename(src))[0]
|
||||||
self.compiler.link_executable([obj], prog,
|
self.compiler.link_executable([obj], prog,
|
||||||
@ -190,17 +182,17 @@ class config (Command):
|
|||||||
"""
|
"""
|
||||||
from distutils.ccompiler import CompileError
|
from distutils.ccompiler import CompileError
|
||||||
self._check_compiler()
|
self._check_compiler()
|
||||||
ok = 1
|
ok = True
|
||||||
try:
|
try:
|
||||||
self._preprocess(body, headers, include_dirs, lang)
|
self._preprocess(body, headers, include_dirs, lang)
|
||||||
except CompileError:
|
except CompileError:
|
||||||
ok = 0
|
ok = False
|
||||||
|
|
||||||
self._clean()
|
self._clean()
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def search_cpp (self, pattern, body=None,
|
def search_cpp(self, pattern, body=None, headers=None,
|
||||||
headers=None, include_dirs=None, lang="c"):
|
include_dirs=None, lang="c"):
|
||||||
"""Construct a source file (just like 'try_cpp()'), run it through
|
"""Construct a source file (just like 'try_cpp()'), run it through
|
||||||
the preprocessor, and return true if any line of the output matches
|
the preprocessor, and return true if any line of the output matches
|
||||||
'pattern'. 'pattern' should either be a compiled regex object or a
|
'pattern'. 'pattern' should either be a compiled regex object or a
|
||||||
@ -216,13 +208,13 @@ class config (Command):
|
|||||||
pattern = re.compile(pattern)
|
pattern = re.compile(pattern)
|
||||||
|
|
||||||
file = open(out)
|
file = open(out)
|
||||||
match = 0
|
match = False
|
||||||
while 1:
|
while True:
|
||||||
line = file.readline()
|
line = file.readline()
|
||||||
if line == '':
|
if line == '':
|
||||||
break
|
break
|
||||||
if pattern.search(line):
|
if pattern.search(line):
|
||||||
match = 1
|
match = True
|
||||||
break
|
break
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
@ -237,18 +229,16 @@ class config (Command):
|
|||||||
self._check_compiler()
|
self._check_compiler()
|
||||||
try:
|
try:
|
||||||
self._compile(body, headers, include_dirs, lang)
|
self._compile(body, headers, include_dirs, lang)
|
||||||
ok = 1
|
ok = True
|
||||||
except CompileError:
|
except CompileError:
|
||||||
ok = 0
|
ok = False
|
||||||
|
|
||||||
log.info(ok and "success!" or "failure.")
|
log.info(ok and "success!" or "failure.")
|
||||||
self._clean()
|
self._clean()
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def try_link (self, body,
|
def try_link(self, body, headers=None, include_dirs=None,
|
||||||
headers=None, include_dirs=None,
|
libraries=None, library_dirs=None, lang="c"):
|
||||||
libraries=None, library_dirs=None,
|
|
||||||
lang="c"):
|
|
||||||
"""Try to compile and link a source file, built from 'body' and
|
"""Try to compile and link a source file, built from 'body' and
|
||||||
'headers', to executable form. Return true on success, false
|
'headers', to executable form. Return true on success, false
|
||||||
otherwise.
|
otherwise.
|
||||||
@ -258,18 +248,16 @@ class config (Command):
|
|||||||
try:
|
try:
|
||||||
self._link(body, headers, include_dirs,
|
self._link(body, headers, include_dirs,
|
||||||
libraries, library_dirs, lang)
|
libraries, library_dirs, lang)
|
||||||
ok = 1
|
ok = True
|
||||||
except (CompileError, LinkError):
|
except (CompileError, LinkError):
|
||||||
ok = 0
|
ok = False
|
||||||
|
|
||||||
log.info(ok and "success!" or "failure.")
|
log.info(ok and "success!" or "failure.")
|
||||||
self._clean()
|
self._clean()
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def try_run (self, body,
|
def try_run(self, body, headers=None, include_dirs=None,
|
||||||
headers=None, include_dirs=None,
|
libraries=None, library_dirs=None, lang="c"):
|
||||||
libraries=None, library_dirs=None,
|
|
||||||
lang="c"):
|
|
||||||
"""Try to compile, link to an executable, and run a program
|
"""Try to compile, link to an executable, and run a program
|
||||||
built from 'body' and 'headers'. Return true on success, false
|
built from 'body' and 'headers'. Return true on success, false
|
||||||
otherwise.
|
otherwise.
|
||||||
@ -280,9 +268,9 @@ class config (Command):
|
|||||||
src, obj, exe = self._link(body, headers, include_dirs,
|
src, obj, exe = self._link(body, headers, include_dirs,
|
||||||
libraries, library_dirs, lang)
|
libraries, library_dirs, lang)
|
||||||
self.spawn([exe])
|
self.spawn([exe])
|
||||||
ok = 1
|
ok = True
|
||||||
except (CompileError, LinkError, DistutilsExecError):
|
except (CompileError, LinkError, DistutilsExecError):
|
||||||
ok = 0
|
ok = False
|
||||||
|
|
||||||
log.info(ok and "success!" or "failure.")
|
log.info(ok and "success!" or "failure.")
|
||||||
self._clean()
|
self._clean()
|
||||||
@ -293,11 +281,8 @@ class config (Command):
|
|||||||
# (these are the ones that are actually likely to be useful
|
# (these are the ones that are actually likely to be useful
|
||||||
# when implementing a real-world config command!)
|
# when implementing a real-world config command!)
|
||||||
|
|
||||||
def check_func (self, func,
|
def check_func(self, func, headers=None, include_dirs=None,
|
||||||
headers=None, include_dirs=None,
|
libraries=None, library_dirs=None, decl=0, call=0):
|
||||||
libraries=None, library_dirs=None,
|
|
||||||
decl=0, call=0):
|
|
||||||
|
|
||||||
"""Determine if function 'func' is available by constructing a
|
"""Determine if function 'func' is available by constructing a
|
||||||
source file that refers to 'func', and compiles and links it.
|
source file that refers to 'func', and compiles and links it.
|
||||||
If everything succeeds, returns true; otherwise returns false.
|
If everything succeeds, returns true; otherwise returns false.
|
||||||
@ -311,7 +296,6 @@ class config (Command):
|
|||||||
calls it. 'libraries' and 'library_dirs' are used when
|
calls it. 'libraries' and 'library_dirs' are used when
|
||||||
linking.
|
linking.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._check_compiler()
|
self._check_compiler()
|
||||||
body = []
|
body = []
|
||||||
if decl:
|
if decl:
|
||||||
@ -327,10 +311,8 @@ class config (Command):
|
|||||||
return self.try_link(body, headers, include_dirs,
|
return self.try_link(body, headers, include_dirs,
|
||||||
libraries, library_dirs)
|
libraries, library_dirs)
|
||||||
|
|
||||||
# check_func ()
|
def check_lib(self, library, library_dirs=None, headers=None,
|
||||||
|
include_dirs=None, other_libraries=[]):
|
||||||
def check_lib (self, library, library_dirs=None,
|
|
||||||
headers=None, include_dirs=None, other_libraries=[]):
|
|
||||||
"""Determine if 'library' is available to be linked against,
|
"""Determine if 'library' is available to be linked against,
|
||||||
without actually checking that any particular symbols are provided
|
without actually checking that any particular symbols are provided
|
||||||
by it. 'headers' will be used in constructing the source file to
|
by it. 'headers' will be used in constructing the source file to
|
||||||
@ -340,12 +322,11 @@ class config (Command):
|
|||||||
has symbols that depend on other libraries.
|
has symbols that depend on other libraries.
|
||||||
"""
|
"""
|
||||||
self._check_compiler()
|
self._check_compiler()
|
||||||
return self.try_link("int main (void) { }",
|
return self.try_link("int main (void) { }", headers, include_dirs,
|
||||||
headers, include_dirs,
|
|
||||||
[library] + other_libraries, library_dirs)
|
[library] + other_libraries, library_dirs)
|
||||||
|
|
||||||
def check_header (self, header, include_dirs=None,
|
def check_header(self, header, include_dirs=None, library_dirs=None,
|
||||||
library_dirs=None, lang="c"):
|
lang="c"):
|
||||||
"""Determine if the system header file named by 'header_file'
|
"""Determine if the system header file named by 'header_file'
|
||||||
exists and can be found by the preprocessor; return true if so,
|
exists and can be found by the preprocessor; return true if so,
|
||||||
false otherwise.
|
false otherwise.
|
||||||
@ -354,9 +335,6 @@ class config (Command):
|
|||||||
include_dirs=include_dirs)
|
include_dirs=include_dirs)
|
||||||
|
|
||||||
|
|
||||||
# class config
|
|
||||||
|
|
||||||
|
|
||||||
def dump_file(filename, head=None):
|
def dump_file(filename, head=None):
|
||||||
if head is None:
|
if head is None:
|
||||||
print(filename + ":")
|
print(filename + ":")
|
||||||
|
@ -4,12 +4,9 @@ Implements the Distutils 'install' command."""
|
|||||||
|
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from types import *
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.debug import DEBUG
|
from distutils.debug import DEBUG
|
||||||
from distutils.sysconfig import get_config_vars
|
from distutils.sysconfig import get_config_vars
|
||||||
@ -233,13 +230,13 @@ class install (Command):
|
|||||||
|
|
||||||
if ((self.prefix or self.exec_prefix or self.home) and
|
if ((self.prefix or self.exec_prefix or self.home) and
|
||||||
(self.install_base or self.install_platbase)):
|
(self.install_base or self.install_platbase)):
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
("must supply either prefix/exec-prefix/home or " +
|
"must supply either prefix/exec-prefix/home or " +
|
||||||
"install-base/install-platbase -- not both")
|
"install-base/install-platbase -- not both")
|
||||||
|
|
||||||
if self.home and (self.prefix or self.exec_prefix):
|
if self.home and (self.prefix or self.exec_prefix):
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
"must supply either home or prefix/exec-prefix -- not both"
|
"must supply either home or prefix/exec-prefix -- not both")
|
||||||
|
|
||||||
# Next, stuff that's wrong (or dubious) only on certain platforms.
|
# Next, stuff that's wrong (or dubious) only on certain platforms.
|
||||||
if os.name != "posix":
|
if os.name != "posix":
|
||||||
@ -341,8 +338,6 @@ class install (Command):
|
|||||||
# Punt on doc directories for now -- after all, we're punting on
|
# Punt on doc directories for now -- after all, we're punting on
|
||||||
# documentation completely!
|
# documentation completely!
|
||||||
|
|
||||||
# finalize_options ()
|
|
||||||
|
|
||||||
|
|
||||||
def dump_dirs(self, msg):
|
def dump_dirs(self, msg):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@ -363,7 +358,6 @@ class install (Command):
|
|||||||
|
|
||||||
|
|
||||||
def finalize_unix(self):
|
def finalize_unix(self):
|
||||||
|
|
||||||
if self.install_base is not None or self.install_platbase is not None:
|
if self.install_base is not None or self.install_platbase is not None:
|
||||||
if ((self.install_lib is None and
|
if ((self.install_lib is None and
|
||||||
self.install_purelib is None and
|
self.install_purelib is None and
|
||||||
@ -371,8 +365,8 @@ class install (Command):
|
|||||||
self.install_headers is None or
|
self.install_headers is None or
|
||||||
self.install_scripts is None or
|
self.install_scripts is None or
|
||||||
self.install_data is None):
|
self.install_data is None):
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
("install-base or install-platbase supplied, but "
|
"install-base or install-platbase supplied, but "
|
||||||
"installation scheme is incomplete")
|
"installation scheme is incomplete")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -382,8 +376,8 @@ class install (Command):
|
|||||||
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)
|
||||||
@ -396,11 +390,8 @@ class install (Command):
|
|||||||
self.install_platbase = self.exec_prefix
|
self.install_platbase = self.exec_prefix
|
||||||
self.select_scheme("unix_prefix")
|
self.select_scheme("unix_prefix")
|
||||||
|
|
||||||
# finalize_unix ()
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_other(self): # Windows and Mac OS for now
|
def finalize_other(self): # Windows and Mac OS for now
|
||||||
|
|
||||||
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")
|
||||||
@ -412,10 +403,8 @@ class install (Command):
|
|||||||
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)
|
||||||
|
|
||||||
# finalize_other ()
|
|
||||||
|
|
||||||
|
|
||||||
def select_scheme(self, name):
|
def select_scheme(self, name):
|
||||||
@ -456,9 +445,7 @@ class install (Command):
|
|||||||
attr = "install_" + name
|
attr = "install_" + name
|
||||||
setattr(self, attr, convert_path(getattr(self, attr)))
|
setattr(self, attr, convert_path(getattr(self, attr)))
|
||||||
|
|
||||||
|
|
||||||
def handle_extra_path(self):
|
def handle_extra_path(self):
|
||||||
|
|
||||||
if self.extra_path is None:
|
if self.extra_path is None:
|
||||||
self.extra_path = self.distribution.extra_path
|
self.extra_path = self.distribution.extra_path
|
||||||
|
|
||||||
@ -471,8 +458,8 @@ class install (Command):
|
|||||||
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(
|
||||||
("'extra_path' option must be a list, tuple, or "
|
"'extra_path' option must be a list, tuple, or "
|
||||||
"comma-separated string with 1 or 2 elements")
|
"comma-separated string with 1 or 2 elements")
|
||||||
|
|
||||||
# convert to local form in case Unix notation used (as it
|
# convert to local form in case Unix notation used (as it
|
||||||
@ -488,9 +475,6 @@ class install (Command):
|
|||||||
self.path_file = path_file
|
self.path_file = path_file
|
||||||
self.extra_dirs = extra_dirs
|
self.extra_dirs = extra_dirs
|
||||||
|
|
||||||
# handle_extra_path ()
|
|
||||||
|
|
||||||
|
|
||||||
def change_roots(self, *names):
|
def change_roots(self, *names):
|
||||||
for name in names:
|
for name in names:
|
||||||
attr = "install_" + name
|
attr = "install_" + name
|
||||||
@ -500,7 +484,6 @@ class install (Command):
|
|||||||
# -- Command execution methods -------------------------------------
|
# -- Command execution methods -------------------------------------
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# 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')
|
||||||
@ -535,8 +518,6 @@ class install (Command):
|
|||||||
"you'll have to change the search path yourself"),
|
"you'll have to change the search path yourself"),
|
||||||
self.install_lib)
|
self.install_lib)
|
||||||
|
|
||||||
# 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")
|
||||||
@ -603,5 +584,3 @@ class install (Command):
|
|||||||
('install_data', has_data),
|
('install_data', has_data),
|
||||||
('install_egg_info', lambda self:True),
|
('install_egg_info', lambda self:True),
|
||||||
]
|
]
|
||||||
|
|
||||||
# class install
|
|
||||||
|
@ -5,8 +5,6 @@ platform-independent data files."""
|
|||||||
|
|
||||||
# contributed by Bastian Kleineidam
|
# contributed by Bastian Kleineidam
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
Implements the Distutils 'install_headers' command, to install C/C++ header
|
Implements the Distutils 'install_headers' command, to install C/C++ header
|
||||||
files to the Python include directory."""
|
files to the Python include directory."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -49,5 +47,3 @@ class install_headers (Command):
|
|||||||
|
|
||||||
def get_outputs(self):
|
def get_outputs(self):
|
||||||
return self.outfiles
|
return self.outfiles
|
||||||
|
|
||||||
# class install_headers
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from types import IntType
|
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils.errors import DistutilsOptionError
|
from distutils.errors import DistutilsOptionError
|
||||||
|
|
||||||
@ -45,7 +42,6 @@ class install_lib (Command):
|
|||||||
boolean_options = ['force', 'compile', 'skip-build']
|
boolean_options = ['force', 'compile', 'skip-build']
|
||||||
negative_opt = {'no-compile' : 'compile'}
|
negative_opt = {'no-compile' : 'compile'}
|
||||||
|
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
# let the 'install' command dictate our installation directory
|
# let the 'install' command dictate our installation directory
|
||||||
self.install_dir = None
|
self.install_dir = None
|
||||||
@ -70,19 +66,18 @@ class install_lib (Command):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self.compile is None:
|
if self.compile is None:
|
||||||
self.compile = 1
|
self.compile = True
|
||||||
if self.optimize is None:
|
if self.optimize is None:
|
||||||
self.optimize = 0
|
self.optimize = False
|
||||||
|
|
||||||
if type(self.optimize) is not IntType:
|
if not isinstance(self.optimize, int):
|
||||||
try:
|
try:
|
||||||
self.optimize = int(self.optimize)
|
self.optimize = int(self.optimize)
|
||||||
assert 0 <= self.optimize <= 2
|
assert 0 <= self.optimize <= 2
|
||||||
except (ValueError, AssertionError):
|
except (ValueError, AssertionError):
|
||||||
raise DistutilsOptionError, "optimize must be 0, 1, or 2"
|
raise DistutilsOptionError("optimize must be 0, 1, or 2")
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# Make sure we have built everything we need first
|
# Make sure we have built everything we need first
|
||||||
self.build()
|
self.build()
|
||||||
|
|
||||||
@ -95,8 +90,6 @@ class install_lib (Command):
|
|||||||
if outfiles is not None and self.distribution.has_pure_modules():
|
if outfiles is not None and self.distribution.has_pure_modules():
|
||||||
self.byte_compile(outfiles)
|
self.byte_compile(outfiles)
|
||||||
|
|
||||||
# run ()
|
|
||||||
|
|
||||||
|
|
||||||
# -- Top-level worker functions ------------------------------------
|
# -- Top-level worker functions ------------------------------------
|
||||||
# (called from 'run()')
|
# (called from 'run()')
|
||||||
@ -139,7 +132,6 @@ class install_lib (Command):
|
|||||||
# -- Utility methods -----------------------------------------------
|
# -- Utility methods -----------------------------------------------
|
||||||
|
|
||||||
def _mutate_outputs(self, has_any, build_cmd, cmd_option, output_dir):
|
def _mutate_outputs(self, has_any, build_cmd, cmd_option, output_dir):
|
||||||
|
|
||||||
if not has_any:
|
if not has_any:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -154,8 +146,6 @@ class install_lib (Command):
|
|||||||
|
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
# _mutate_outputs ()
|
|
||||||
|
|
||||||
def _bytecode_filenames(self, py_filenames):
|
def _bytecode_filenames(self, py_filenames):
|
||||||
bytecode_files = []
|
bytecode_files = []
|
||||||
for py_file in py_filenames:
|
for py_file in py_filenames:
|
||||||
@ -197,8 +187,6 @@ class install_lib (Command):
|
|||||||
|
|
||||||
return pure_outputs + bytecode_outputs + ext_outputs
|
return pure_outputs + bytecode_outputs + ext_outputs
|
||||||
|
|
||||||
# get_outputs ()
|
|
||||||
|
|
||||||
def get_inputs(self):
|
def get_inputs(self):
|
||||||
"""Get the list of files that are input to this command, ie. the
|
"""Get the list of files that are input to this command, ie. the
|
||||||
files that get installed as they are named in the build tree.
|
files that get installed as they are named in the build tree.
|
||||||
@ -216,5 +204,3 @@ class install_lib (Command):
|
|||||||
inputs.extend(build_ext.get_outputs())
|
inputs.extend(build_ext.get_outputs())
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
# class install_lib
|
|
||||||
|
@ -5,8 +5,6 @@ Python scripts."""
|
|||||||
|
|
||||||
# contributed by Bastian Kleineidam
|
# contributed by Bastian Kleineidam
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -14,6 +12,7 @@ from distutils.core import Command
|
|||||||
from distutils import log
|
from distutils import log
|
||||||
from stat import ST_MODE
|
from stat import ST_MODE
|
||||||
|
|
||||||
|
|
||||||
class install_scripts(Command):
|
class install_scripts(Command):
|
||||||
|
|
||||||
description = "install scripts (Python or otherwise)"
|
description = "install scripts (Python or otherwise)"
|
||||||
@ -27,7 +26,6 @@ class install_scripts (Command):
|
|||||||
|
|
||||||
boolean_options = ['force', 'skip-build']
|
boolean_options = ['force', 'skip-build']
|
||||||
|
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
self.install_dir = None
|
self.install_dir = None
|
||||||
self.force = 0
|
self.force = 0
|
||||||
@ -62,5 +60,3 @@ class install_scripts (Command):
|
|||||||
|
|
||||||
def get_outputs(self):
|
def get_outputs(self):
|
||||||
return self.outfiles or []
|
return self.outfiles or []
|
||||||
|
|
||||||
# class install_scripts
|
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
Implements the Distutils 'sdist' command (create a source distribution)."""
|
Implements the Distutils 'sdist' command (create a source distribution)."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from types import *
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils import dir_util, dep_util, file_util, archive_util
|
from distutils import dir_util, dep_util, file_util, archive_util
|
||||||
@ -114,21 +111,20 @@ class sdist (Command):
|
|||||||
try:
|
try:
|
||||||
self.formats = [self.default_format[os.name]]
|
self.formats = [self.default_format[os.name]]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError(
|
||||||
"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)
|
||||||
|
|
||||||
if self.dist_dir is None:
|
if self.dist_dir is None:
|
||||||
self.dist_dir = "dist"
|
self.dist_dir = "dist"
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# 'filelist' contains the list of files that will make up the
|
# 'filelist' contains the list of files that will make up the
|
||||||
# manifest
|
# manifest
|
||||||
self.filelist = FileList()
|
self.filelist = FileList()
|
||||||
@ -150,7 +146,6 @@ class sdist (Command):
|
|||||||
# or zipfile, or whatever.
|
# or zipfile, or whatever.
|
||||||
self.make_distribution()
|
self.make_distribution()
|
||||||
|
|
||||||
|
|
||||||
def check_metadata(self):
|
def check_metadata(self):
|
||||||
"""Ensure that all required elements of meta-data (name, version,
|
"""Ensure that all required elements of meta-data (name, version,
|
||||||
URL, (author and author_email) or (maintainer and
|
URL, (author and author_email) or (maintainer and
|
||||||
@ -181,9 +176,6 @@ class sdist (Command):
|
|||||||
"or (maintainer and maintainer_email) " +
|
"or (maintainer and maintainer_email) " +
|
||||||
"must be supplied")
|
"must be supplied")
|
||||||
|
|
||||||
# check_metadata ()
|
|
||||||
|
|
||||||
|
|
||||||
def get_file_list(self):
|
def get_file_list(self):
|
||||||
"""Figure out the list of files to include in the source
|
"""Figure out the list of files to include in the source
|
||||||
distribution, and put it in 'self.filelist'. This might involve
|
distribution, and put it in 'self.filelist'. This might involve
|
||||||
@ -191,7 +183,6 @@ class sdist (Command):
|
|||||||
reading the manifest, or just using the default file set -- it all
|
reading the manifest, or just using the default file set -- it all
|
||||||
depends on the user's options and the state of the filesystem.
|
depends on the user's options and the state of the filesystem.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If we have a manifest template, see if it's newer than the
|
# If we have a manifest template, see if it's newer than the
|
||||||
# manifest; if so, we'll regenerate the manifest.
|
# manifest; if so, we'll regenerate the manifest.
|
||||||
template_exists = os.path.isfile(self.template)
|
template_exists = os.path.isfile(self.template)
|
||||||
@ -231,9 +222,9 @@ class sdist (Command):
|
|||||||
# Regenerate the manifest if necessary (or if explicitly told to)
|
# Regenerate the manifest if necessary (or if explicitly told to)
|
||||||
if manifest_outofdate or neither_exists or force_regen:
|
if manifest_outofdate or neither_exists or force_regen:
|
||||||
if not template_exists:
|
if not template_exists:
|
||||||
self.warn(("manifest template '%s' does not exist " +
|
self.warn("manifest template '%s' does not exist "
|
||||||
"(using default file list)") %
|
"(using default file list)"
|
||||||
self.template)
|
% self.template)
|
||||||
self.filelist.findall()
|
self.filelist.findall()
|
||||||
|
|
||||||
if self.use_defaults:
|
if self.use_defaults:
|
||||||
@ -251,8 +242,6 @@ class sdist (Command):
|
|||||||
else:
|
else:
|
||||||
self.read_manifest()
|
self.read_manifest()
|
||||||
|
|
||||||
# get_file_list ()
|
|
||||||
|
|
||||||
|
|
||||||
def add_defaults(self):
|
def add_defaults(self):
|
||||||
"""Add all the default files to self.filelist:
|
"""Add all the default files to self.filelist:
|
||||||
@ -265,15 +254,14 @@ class sdist (Command):
|
|||||||
Warns if (README or README.txt) or setup.py are missing; everything
|
Warns if (README or README.txt) or setup.py are missing; everything
|
||||||
else is optional.
|
else is optional.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
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 isinstance(fn, tuple):
|
||||||
alts = fn
|
alts = fn
|
||||||
got_it = 0
|
got_it = False
|
||||||
for fn in alts:
|
for fn in alts:
|
||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
got_it = 1
|
got_it = True
|
||||||
self.filelist.append(fn)
|
self.filelist.append(fn)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -308,9 +296,6 @@ class sdist (Command):
|
|||||||
build_scripts = self.get_finalized_command('build_scripts')
|
build_scripts = self.get_finalized_command('build_scripts')
|
||||||
self.filelist.extend(build_scripts.get_source_files())
|
self.filelist.extend(build_scripts.get_source_files())
|
||||||
|
|
||||||
# add_defaults ()
|
|
||||||
|
|
||||||
|
|
||||||
def read_template(self):
|
def read_template(self):
|
||||||
"""Read and parse manifest template file named by self.template.
|
"""Read and parse manifest template file named by self.template.
|
||||||
|
|
||||||
@ -318,15 +303,11 @@ class sdist (Command):
|
|||||||
'self.filelist', which updates itself accordingly.
|
'self.filelist', which updates itself accordingly.
|
||||||
"""
|
"""
|
||||||
log.info("reading manifest template '%s'", self.template)
|
log.info("reading manifest template '%s'", self.template)
|
||||||
template = TextFile(self.template,
|
template = TextFile(self.template, strip_comments=1, skip_blanks=1,
|
||||||
strip_comments=1,
|
join_lines=1, lstrip_ws=1, rstrip_ws=1,
|
||||||
skip_blanks=1,
|
|
||||||
join_lines=1,
|
|
||||||
lstrip_ws=1,
|
|
||||||
rstrip_ws=1,
|
|
||||||
collapse_join=1)
|
collapse_join=1)
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
line = template.readline()
|
line = template.readline()
|
||||||
if line is None: # end of file
|
if line is None: # end of file
|
||||||
break
|
break
|
||||||
@ -338,9 +319,6 @@ class sdist (Command):
|
|||||||
template.current_line,
|
template.current_line,
|
||||||
msg))
|
msg))
|
||||||
|
|
||||||
# read_template ()
|
|
||||||
|
|
||||||
|
|
||||||
def prune_file_list(self):
|
def prune_file_list(self):
|
||||||
"""Prune off branches that might slip into the file list as created
|
"""Prune off branches that might slip into the file list as created
|
||||||
by 'read_template()', but really don't belong there:
|
by 'read_template()', but really don't belong there:
|
||||||
@ -356,7 +334,6 @@ class sdist (Command):
|
|||||||
self.filelist.exclude_pattern(None, prefix=base_dir)
|
self.filelist.exclude_pattern(None, prefix=base_dir)
|
||||||
self.filelist.exclude_pattern(r'/(RCS|CVS|\.svn)/.*', is_regex=1)
|
self.filelist.exclude_pattern(r'/(RCS|CVS|\.svn)/.*', is_regex=1)
|
||||||
|
|
||||||
|
|
||||||
def write_manifest(self):
|
def write_manifest(self):
|
||||||
"""Write the file list in 'self.filelist' (presumably as filled in
|
"""Write the file list in 'self.filelist' (presumably as filled in
|
||||||
by 'add_defaults()' and 'read_template()') to the manifest file
|
by 'add_defaults()' and 'read_template()') to the manifest file
|
||||||
@ -366,9 +343,6 @@ class sdist (Command):
|
|||||||
(self.manifest, self.filelist.files),
|
(self.manifest, self.filelist.files),
|
||||||
"writing manifest file '%s'" % self.manifest)
|
"writing manifest file '%s'" % self.manifest)
|
||||||
|
|
||||||
# write_manifest ()
|
|
||||||
|
|
||||||
|
|
||||||
def read_manifest(self):
|
def read_manifest(self):
|
||||||
"""Read the manifest file (named by 'self.manifest') and use it to
|
"""Read the manifest file (named by 'self.manifest') and use it to
|
||||||
fill in 'self.filelist', the list of files to include in the source
|
fill in 'self.filelist', the list of files to include in the source
|
||||||
@ -376,7 +350,7 @@ class sdist (Command):
|
|||||||
"""
|
"""
|
||||||
log.info("reading manifest file '%s'", self.manifest)
|
log.info("reading manifest file '%s'", self.manifest)
|
||||||
manifest = open(self.manifest)
|
manifest = open(self.manifest)
|
||||||
while 1:
|
while True:
|
||||||
line = manifest.readline()
|
line = manifest.readline()
|
||||||
if line == '': # end of file
|
if line == '': # end of file
|
||||||
break
|
break
|
||||||
@ -384,9 +358,6 @@ class sdist (Command):
|
|||||||
line = line[0:-1]
|
line = line[0:-1]
|
||||||
self.filelist.append(line)
|
self.filelist.append(line)
|
||||||
|
|
||||||
# read_manifest ()
|
|
||||||
|
|
||||||
|
|
||||||
def make_release_tree(self, base_dir, files):
|
def make_release_tree(self, base_dir, files):
|
||||||
"""Create the directory tree that will become the source
|
"""Create the directory tree that will become the source
|
||||||
distribution archive. All directories implied by the filenames in
|
distribution archive. All directories implied by the filenames in
|
||||||
@ -429,8 +400,6 @@ class sdist (Command):
|
|||||||
|
|
||||||
self.distribution.metadata.write_pkg_info(base_dir)
|
self.distribution.metadata.write_pkg_info(base_dir)
|
||||||
|
|
||||||
# make_release_tree ()
|
|
||||||
|
|
||||||
def make_distribution(self):
|
def make_distribution(self):
|
||||||
"""Create the source distribution(s). First, we create the release
|
"""Create the source distribution(s). First, we create the release
|
||||||
tree with 'make_release_tree()'; then, we create all required
|
tree with 'make_release_tree()'; then, we create all required
|
||||||
@ -461,5 +430,3 @@ class sdist (Command):
|
|||||||
was run, or None if the command hasn't run yet.
|
was run, or None if the command hasn't run yet.
|
||||||
"""
|
"""
|
||||||
return self.archive_files
|
return self.archive_files
|
||||||
|
|
||||||
# class sdist
|
|
||||||
|
@ -170,7 +170,7 @@ class upload(Command):
|
|||||||
elif schema == 'https':
|
elif schema == 'https':
|
||||||
http = httplib.HTTPSConnection(netloc)
|
http = httplib.HTTPSConnection(netloc)
|
||||||
else:
|
else:
|
||||||
raise AssertionError, "unsupported schema "+schema
|
raise AssertionError("unsupported schema "+schema)
|
||||||
|
|
||||||
data = ''
|
data = ''
|
||||||
loglevel = log.INFO
|
loglevel = log.INFO
|
||||||
|
@ -6,12 +6,9 @@ indirectly provides the Distribution and Command classes, although they are
|
|||||||
really defined in distutils.dist and distutils.cmd.
|
really defined in distutils.dist and distutils.cmd.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from types import *
|
|
||||||
|
|
||||||
from distutils.debug import DEBUG
|
from distutils.debug import DEBUG
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
@ -112,10 +109,10 @@ def setup (**attrs):
|
|||||||
_setup_distribution = dist = klass(attrs)
|
_setup_distribution = dist = klass(attrs)
|
||||||
except DistutilsSetupError as msg:
|
except DistutilsSetupError as msg:
|
||||||
if 'name' not in attrs:
|
if 'name' not in attrs:
|
||||||
raise SystemExit, "error in setup command: %s" % msg
|
raise SystemExit("error in setup command: %s" % msg)
|
||||||
else:
|
else:
|
||||||
raise SystemExit, "error in %s setup command: %s" % \
|
raise SystemExit("error in %s setup command: %s" % \
|
||||||
(attrs['name'], msg)
|
(attrs['name'], msg))
|
||||||
|
|
||||||
if _setup_stop_after == "init":
|
if _setup_stop_after == "init":
|
||||||
return dist
|
return dist
|
||||||
@ -136,7 +133,7 @@ def setup (**attrs):
|
|||||||
try:
|
try:
|
||||||
ok = dist.parse_command_line()
|
ok = dist.parse_command_line()
|
||||||
except DistutilsArgError as msg:
|
except DistutilsArgError as msg:
|
||||||
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
|
raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print("options (after parsing command line):")
|
print("options (after parsing command line):")
|
||||||
@ -150,7 +147,7 @@ def setup (**attrs):
|
|||||||
try:
|
try:
|
||||||
dist.run_commands()
|
dist.run_commands()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise SystemExit, "interrupted"
|
raise SystemExit("interrupted")
|
||||||
except (IOError, os.error) as exc:
|
except (IOError, os.error) as exc:
|
||||||
error = grok_environment_error(exc)
|
error = grok_environment_error(exc)
|
||||||
|
|
||||||
@ -158,14 +155,14 @@ def setup (**attrs):
|
|||||||
sys.stderr.write(error + "\n")
|
sys.stderr.write(error + "\n")
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
raise SystemExit, error
|
raise SystemExit(error)
|
||||||
|
|
||||||
except (DistutilsError,
|
except (DistutilsError,
|
||||||
CCompilerError) as msg:
|
CCompilerError) as msg:
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
raise SystemExit, "error: " + str(msg)
|
raise SystemExit("error: " + str(msg))
|
||||||
|
|
||||||
return dist
|
return dist
|
||||||
|
|
||||||
@ -204,7 +201,7 @@ def run_setup (script_name, script_args=None, stop_after="run"):
|
|||||||
used to drive the Distutils.
|
used to drive the Distutils.
|
||||||
"""
|
"""
|
||||||
if stop_after not in ('init', 'config', 'commandline', 'run'):
|
if stop_after not in ('init', 'config', 'commandline', 'run'):
|
||||||
raise ValueError, "invalid value for 'stop_after': %r" % (stop_after,)
|
raise ValueError("invalid value for 'stop_after': %r" % (stop_after,))
|
||||||
|
|
||||||
global _setup_stop_after, _setup_distribution
|
global _setup_stop_after, _setup_distribution
|
||||||
_setup_stop_after = stop_after
|
_setup_stop_after = stop_after
|
||||||
@ -229,10 +226,9 @@ def run_setup (script_name, script_args=None, stop_after="run"):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
if _setup_distribution is None:
|
if _setup_distribution is None:
|
||||||
raise RuntimeError, \
|
raise RuntimeError(("'distutils.core.setup()' was never called -- "
|
||||||
("'distutils.core.setup()' was never called -- "
|
|
||||||
"perhaps '%s' is not a Distutils setup script?") % \
|
"perhaps '%s' is not a Distutils setup script?") % \
|
||||||
script_name
|
script_name)
|
||||||
|
|
||||||
# I wonder if the setup script's namespace -- g and l -- would be of
|
# I wonder if the setup script's namespace -- g and l -- would be of
|
||||||
# any interest to callers?
|
# any interest to callers?
|
||||||
|
@ -45,8 +45,6 @@ cygwin in no-cygwin mode).
|
|||||||
# * mingw gcc 3.2/ld 2.13 works
|
# * mingw gcc 3.2/ld 2.13 works
|
||||||
# (ld supports -shared)
|
# (ld supports -shared)
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os,sys,copy
|
import os,sys,copy
|
||||||
@ -143,13 +141,13 @@ class CygwinCCompiler (UnixCCompiler):
|
|||||||
try:
|
try:
|
||||||
self.spawn(["windres", "-i", src, "-o", obj])
|
self.spawn(["windres", "-i", src, "-o", obj])
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
else: # for other files use the C-compiler
|
else: # for other files use the C-compiler
|
||||||
try:
|
try:
|
||||||
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||||
extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
def link (self,
|
def link (self,
|
||||||
target_desc,
|
target_desc,
|
||||||
@ -260,9 +258,8 @@ class CygwinCCompiler (UnixCCompiler):
|
|||||||
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
|
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
|
||||||
(base, ext) = os.path.splitext (os.path.normcase(src_name))
|
(base, ext) = os.path.splitext (os.path.normcase(src_name))
|
||||||
if ext not in (self.src_extensions + ['.rc','.res']):
|
if ext not in (self.src_extensions + ['.rc','.res']):
|
||||||
raise UnknownFileError, \
|
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
|
||||||
"unknown file type '%s' (from '%s')" % \
|
(ext, src_name))
|
||||||
(ext, src_name)
|
|
||||||
if strip_dir:
|
if strip_dir:
|
||||||
base = os.path.basename (base)
|
base = os.path.basename (base)
|
||||||
if ext == '.res' or ext == '.rc':
|
if ext == '.res' or ext == '.rc':
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
# If DISTUTILS_DEBUG is anything other than the empty string, we run in
|
# If DISTUTILS_DEBUG is anything other than the empty string, we run in
|
||||||
|
@ -4,8 +4,6 @@ Utility functions for simple, timestamp-based dependency of files
|
|||||||
and groups of files; also, function based entirely on such
|
and groups of files; also, function based entirely on such
|
||||||
timestamp dependency analysis."""
|
timestamp dependency analysis."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -19,7 +17,7 @@ def newer (source, target):
|
|||||||
Raise DistutilsFileError if 'source' does not exist.
|
Raise DistutilsFileError if 'source' does not exist.
|
||||||
"""
|
"""
|
||||||
if not os.path.exists(source):
|
if not os.path.exists(source):
|
||||||
raise DistutilsFileError, "file '%s' does not exist" % source
|
raise DistutilsFileError("file '%s' does not exist" % source)
|
||||||
if not os.path.exists(target):
|
if not os.path.exists(target):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -39,7 +37,7 @@ def newer_pairwise (sources, targets):
|
|||||||
of 'newer()'.
|
of 'newer()'.
|
||||||
"""
|
"""
|
||||||
if len(sources) != len(targets):
|
if len(sources) != len(targets):
|
||||||
raise ValueError, "'sources' and 'targets' must be same length"
|
raise ValueError("'sources' and 'targets' must be same length")
|
||||||
|
|
||||||
# build a pair of lists (sources, targets) where source is newer
|
# build a pair of lists (sources, targets) where source is newer
|
||||||
n_sources = []
|
n_sources = []
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
Utility functions for manipulating directories and directory trees."""
|
Utility functions for manipulating directories and directory trees."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
from types import *
|
|
||||||
from distutils.errors import DistutilsFileError, DistutilsInternalError
|
from distutils.errors import DistutilsFileError, DistutilsInternalError
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
||||||
@ -32,8 +29,8 @@ def mkpath (name, mode=0o777, verbose=0, dry_run=0):
|
|||||||
|
|
||||||
# Detect a common bug -- name is None
|
# Detect a common bug -- name is None
|
||||||
if not isinstance(name, basestring):
|
if not isinstance(name, basestring):
|
||||||
raise DistutilsInternalError, \
|
raise DistutilsInternalError(
|
||||||
"mkpath: 'name' must be a string (got %r)" % (name,)
|
"mkpath: 'name' must be a string (got %r)" % (name,))
|
||||||
|
|
||||||
# XXX what's the better way to handle verbosity? print as we create
|
# XXX what's the better way to handle verbosity? print as we create
|
||||||
# each directory in the path (the current behaviour), or only announce
|
# each directory in the path (the current behaviour), or only announce
|
||||||
@ -136,8 +133,8 @@ def copy_tree (src, dst,
|
|||||||
from distutils.file_util import copy_file
|
from distutils.file_util import copy_file
|
||||||
|
|
||||||
if not dry_run and not os.path.isdir(src):
|
if not dry_run and not os.path.isdir(src):
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"cannot copy tree '%s': not a directory" % src
|
"cannot copy tree '%s': not a directory" % src)
|
||||||
try:
|
try:
|
||||||
names = os.listdir(src)
|
names = os.listdir(src)
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
@ -145,8 +142,8 @@ def copy_tree (src, dst,
|
|||||||
if dry_run:
|
if dry_run:
|
||||||
names = []
|
names = []
|
||||||
else:
|
else:
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"error listing files in '%s': %s" % (src, errstr)
|
"error listing files in '%s': %s" % (src, errstr))
|
||||||
|
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
mkpath(dst)
|
mkpath(dst)
|
||||||
@ -176,8 +173,6 @@ def copy_tree (src, dst,
|
|||||||
|
|
||||||
return outputs
|
return outputs
|
||||||
|
|
||||||
# copy_tree ()
|
|
||||||
|
|
||||||
# Helper for remove_tree()
|
# Helper for remove_tree()
|
||||||
def _build_cmdtuple(path, cmdtuples):
|
def _build_cmdtuple(path, cmdtuples):
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
|
@ -4,8 +4,6 @@ Provides the Distribution class, which represents the module distribution
|
|||||||
being built/installed/distributed.
|
being built/installed/distributed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os, re
|
import sys, os, re
|
||||||
@ -264,8 +262,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
|
|
||||||
self.finalize_options()
|
self.finalize_options()
|
||||||
|
|
||||||
# __init__ ()
|
|
||||||
|
|
||||||
|
|
||||||
def get_option_dict (self, command):
|
def get_option_dict (self, command):
|
||||||
"""Get the option dictionary for a given command. If that
|
"""Get the option dictionary for a given command. If that
|
||||||
@ -305,8 +301,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
for line in out.split("\n"):
|
for line in out.split("\n"):
|
||||||
print(indent + " " + line)
|
print(indent + " " + line)
|
||||||
|
|
||||||
# dump_option_dicts ()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -- Config file finding/parsing methods ---------------------------
|
# -- Config file finding/parsing methods ---------------------------
|
||||||
@ -353,8 +347,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
# find_config_files ()
|
|
||||||
|
|
||||||
|
|
||||||
def parse_config_files (self, filenames=None):
|
def parse_config_files (self, filenames=None):
|
||||||
|
|
||||||
@ -397,9 +389,7 @@ Common commands: (see '--help-commands' for more)
|
|||||||
else:
|
else:
|
||||||
setattr(self, opt, val)
|
setattr(self, opt, val)
|
||||||
except ValueError as msg:
|
except ValueError as msg:
|
||||||
raise DistutilsOptionError, msg
|
raise DistutilsOptionError(msg)
|
||||||
|
|
||||||
# parse_config_files ()
|
|
||||||
|
|
||||||
|
|
||||||
# -- Command-line parsing methods ----------------------------------
|
# -- Command-line parsing methods ----------------------------------
|
||||||
@ -472,12 +462,10 @@ Common commands: (see '--help-commands' for more)
|
|||||||
|
|
||||||
# Oops, no commands found -- an end-user error
|
# Oops, no commands found -- an end-user error
|
||||||
if not self.commands:
|
if not self.commands:
|
||||||
raise DistutilsArgError, "no commands supplied"
|
raise DistutilsArgError("no commands supplied")
|
||||||
|
|
||||||
# All is well: return true
|
# All is well: return true
|
||||||
return 1
|
return True
|
||||||
|
|
||||||
# parse_command_line()
|
|
||||||
|
|
||||||
def _get_toplevel_options (self):
|
def _get_toplevel_options (self):
|
||||||
"""Return the non-display options recognized at the top level.
|
"""Return the non-display options recognized at the top level.
|
||||||
@ -505,7 +493,7 @@ Common commands: (see '--help-commands' for more)
|
|||||||
# Pull the current command from the head of the command line
|
# Pull the current command from the head of the command line
|
||||||
command = args[0]
|
command = args[0]
|
||||||
if not command_re.match(command):
|
if not command_re.match(command):
|
||||||
raise SystemExit, "invalid command name '%s'" % command
|
raise SystemExit("invalid command name '%s'" % command)
|
||||||
self.commands.append(command)
|
self.commands.append(command)
|
||||||
|
|
||||||
# Dig up the command class that implements this command, so we
|
# Dig up the command class that implements this command, so we
|
||||||
@ -514,22 +502,21 @@ Common commands: (see '--help-commands' for more)
|
|||||||
try:
|
try:
|
||||||
cmd_class = self.get_command_class(command)
|
cmd_class = self.get_command_class(command)
|
||||||
except DistutilsModuleError as msg:
|
except DistutilsModuleError as msg:
|
||||||
raise DistutilsArgError, msg
|
raise DistutilsArgError(msg)
|
||||||
|
|
||||||
# Require that the command class be derived from Command -- want
|
# Require that the command class be derived from Command -- want
|
||||||
# to be sure that the basic "command" interface is implemented.
|
# to be sure that the basic "command" interface is implemented.
|
||||||
if not issubclass(cmd_class, Command):
|
if not issubclass(cmd_class, Command):
|
||||||
raise DistutilsClassError, \
|
raise DistutilsClassError(
|
||||||
"command class %s must subclass Command" % cmd_class
|
"command class %s must subclass Command" % cmd_class)
|
||||||
|
|
||||||
# Also make sure that the command object provides a list of its
|
# Also make sure that the command object provides a list of its
|
||||||
# known options.
|
# known options.
|
||||||
if not (hasattr(cmd_class, 'user_options') and
|
if not (hasattr(cmd_class, 'user_options') and
|
||||||
isinstance(cmd_class.user_options, list)):
|
isinstance(cmd_class.user_options, list)):
|
||||||
raise DistutilsClassError, \
|
raise DistutilsClassError(("command class %s must provide " +
|
||||||
("command class %s must provide " +
|
|
||||||
"'user_options' attribute (a list of tuples)") % \
|
"'user_options' attribute (a list of tuples)") % \
|
||||||
cmd_class
|
cmd_class)
|
||||||
|
|
||||||
# If the command class has a list of negative alias options,
|
# If the command class has a list of negative alias options,
|
||||||
# merge it in with the global negative aliases.
|
# merge it in with the global negative aliases.
|
||||||
@ -586,8 +573,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
# _parse_command_opts ()
|
|
||||||
|
|
||||||
def finalize_options (self):
|
def finalize_options (self):
|
||||||
"""Set final values for all the options on the Distribution
|
"""Set final values for all the options on the Distribution
|
||||||
instance, analogous to the .finalize_options() method of Command
|
instance, analogous to the .finalize_options() method of Command
|
||||||
@ -660,8 +645,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
print(gen_usage(self.script_name))
|
print(gen_usage(self.script_name))
|
||||||
return
|
return
|
||||||
|
|
||||||
# _show_help ()
|
|
||||||
|
|
||||||
|
|
||||||
def handle_display_options (self, option_order):
|
def handle_display_options (self, option_order):
|
||||||
"""If there were any non-global "display-only" options
|
"""If there were any non-global "display-only" options
|
||||||
@ -703,13 +686,10 @@ Common commands: (see '--help-commands' for more)
|
|||||||
|
|
||||||
return any_display_options
|
return any_display_options
|
||||||
|
|
||||||
# handle_display_options()
|
|
||||||
|
|
||||||
def print_command_list (self, commands, header, max_length):
|
def print_command_list (self, commands, header, max_length):
|
||||||
"""Print a subset of the list of all commands -- used by
|
"""Print a subset of the list of all commands -- used by
|
||||||
'print_commands()'.
|
'print_commands()'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print(header + ":")
|
print(header + ":")
|
||||||
|
|
||||||
for cmd in commands:
|
for cmd in commands:
|
||||||
@ -723,8 +703,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
|
|
||||||
print(" %-*s %s" % (max_length, cmd, description))
|
print(" %-*s %s" % (max_length, cmd, description))
|
||||||
|
|
||||||
# print_command_list ()
|
|
||||||
|
|
||||||
|
|
||||||
def print_commands (self):
|
def print_commands (self):
|
||||||
"""Print out a help message listing all available commands with a
|
"""Print out a help message listing all available commands with a
|
||||||
@ -734,7 +712,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
descriptions come from the command class attribute
|
descriptions come from the command class attribute
|
||||||
'description'.
|
'description'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import distutils.command
|
import distutils.command
|
||||||
std_commands = distutils.command.__all__
|
std_commands = distutils.command.__all__
|
||||||
is_std = {}
|
is_std = {}
|
||||||
@ -760,8 +737,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
"Extra commands",
|
"Extra commands",
|
||||||
max_length)
|
max_length)
|
||||||
|
|
||||||
# print_commands ()
|
|
||||||
|
|
||||||
def get_command_list (self):
|
def get_command_list (self):
|
||||||
"""Get a list of (command, description) tuples.
|
"""Get a list of (command, description) tuples.
|
||||||
The list is divided into "standard commands" (listed in
|
The list is divided into "standard commands" (listed in
|
||||||
@ -771,7 +746,6 @@ Common commands: (see '--help-commands' for more)
|
|||||||
"""
|
"""
|
||||||
# Currently this is only used on Mac OS, for the Mac-only GUI
|
# Currently this is only used on Mac OS, for the Mac-only GUI
|
||||||
# Distutils interface (by Jack Jansen)
|
# Distutils interface (by Jack Jansen)
|
||||||
|
|
||||||
import distutils.command
|
import distutils.command
|
||||||
std_commands = distutils.command.__all__
|
std_commands = distutils.command.__all__
|
||||||
is_std = {}
|
is_std = {}
|
||||||
@ -839,18 +813,15 @@ Common commands: (see '--help-commands' for more)
|
|||||||
try:
|
try:
|
||||||
klass = getattr(module, klass_name)
|
klass = getattr(module, klass_name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise DistutilsModuleError, \
|
raise DistutilsModuleError(
|
||||||
"invalid command '%s' (no class '%s' in module '%s')" \
|
"invalid command '%s' (no class '%s' in module '%s')"
|
||||||
% (command, klass_name, module_name)
|
% (command, klass_name, module_name))
|
||||||
|
|
||||||
self.cmdclass[command] = klass
|
self.cmdclass[command] = klass
|
||||||
return klass
|
return klass
|
||||||
|
|
||||||
raise DistutilsModuleError("invalid command '%s'" % command)
|
raise DistutilsModuleError("invalid command '%s'" % command)
|
||||||
|
|
||||||
|
|
||||||
# get_command_class ()
|
|
||||||
|
|
||||||
def get_command_obj (self, command, create=1):
|
def get_command_obj (self, command, create=1):
|
||||||
"""Return the command object for 'command'. Normally this object
|
"""Return the command object for 'command'. Normally this object
|
||||||
is cached on a previous call to 'get_command_obj()'; if no command
|
is cached on a previous call to 'get_command_obj()'; if no command
|
||||||
@ -912,11 +883,11 @@ Common commands: (see '--help-commands' for more)
|
|||||||
elif hasattr(command_obj, option):
|
elif hasattr(command_obj, option):
|
||||||
setattr(command_obj, option, value)
|
setattr(command_obj, option, value)
|
||||||
else:
|
else:
|
||||||
raise DistutilsOptionError, \
|
raise DistutilsOptionError(
|
||||||
("error in %s: command '%s' has no such option '%s'"
|
"error in %s: command '%s' has no such option '%s'"
|
||||||
% (source, command_name, option))
|
% (source, command_name, option))
|
||||||
except ValueError as msg:
|
except ValueError as msg:
|
||||||
raise DistutilsOptionError, msg
|
raise DistutilsOptionError(msg)
|
||||||
|
|
||||||
def reinitialize_command (self, command, reinit_subcommands=0):
|
def reinitialize_command (self, command, reinit_subcommands=0):
|
||||||
"""Reinitializes a command to the state it was in when first
|
"""Reinitializes a command to the state it was in when first
|
||||||
@ -1075,8 +1046,6 @@ class DistributionMetadata:
|
|||||||
|
|
||||||
pkg_info.close()
|
pkg_info.close()
|
||||||
|
|
||||||
# write_pkg_info ()
|
|
||||||
|
|
||||||
def write_pkg_file (self, file):
|
def write_pkg_file (self, file):
|
||||||
"""Write the PKG-INFO format data to a file object.
|
"""Write the PKG-INFO format data to a file object.
|
||||||
"""
|
"""
|
||||||
@ -1202,8 +1171,6 @@ class DistributionMetadata:
|
|||||||
distutils.versionpredicate.VersionPredicate(v)
|
distutils.versionpredicate.VersionPredicate(v)
|
||||||
self.obsoletes = value
|
self.obsoletes = value
|
||||||
|
|
||||||
# class DistributionMetadata
|
|
||||||
|
|
||||||
|
|
||||||
def fix_help_options (options):
|
def fix_help_options (options):
|
||||||
"""Convert a 4-tuple 'help_options' list as found in various command
|
"""Convert a 4-tuple 'help_options' list as found in various command
|
||||||
|
@ -80,13 +80,13 @@ class EMXCCompiler (UnixCCompiler):
|
|||||||
try:
|
try:
|
||||||
self.spawn(["rc", "-r", src])
|
self.spawn(["rc", "-r", src])
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
else: # for other files use the C-compiler
|
else: # for other files use the C-compiler
|
||||||
try:
|
try:
|
||||||
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||||
extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
def link (self,
|
def link (self,
|
||||||
target_desc,
|
target_desc,
|
||||||
@ -189,9 +189,8 @@ class EMXCCompiler (UnixCCompiler):
|
|||||||
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
|
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
|
||||||
(base, ext) = os.path.splitext (os.path.normcase(src_name))
|
(base, ext) = os.path.splitext (os.path.normcase(src_name))
|
||||||
if ext not in (self.src_extensions + ['.rc']):
|
if ext not in (self.src_extensions + ['.rc']):
|
||||||
raise UnknownFileError, \
|
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
|
||||||
"unknown file type '%s' (from '%s')" % \
|
(ext, src_name))
|
||||||
(ext, src_name)
|
|
||||||
if strip_dir:
|
if strip_dir:
|
||||||
base = os.path.basename (base)
|
base = os.path.basename (base)
|
||||||
if ext == '.rc':
|
if ext == '.rc':
|
||||||
|
@ -8,8 +8,6 @@ usually raised for errors that are obviously the end-user's fault
|
|||||||
This module is safe to use in "from ... import *" mode; it only exports
|
This module is safe to use in "from ... import *" mode; it only exports
|
||||||
symbols whose names start with "Distutils" and end with "Error"."""
|
symbols whose names start with "Distutils" and end with "Error"."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
class DistutilsError (Exception):
|
class DistutilsError (Exception):
|
||||||
|
@ -125,14 +125,12 @@ class Extension:
|
|||||||
|
|
||||||
# If there are unknown keyword options, warn about them
|
# If there are unknown keyword options, warn about them
|
||||||
if len(kw):
|
if len(kw):
|
||||||
L = kw.keys() ; L.sort()
|
L = map(repr, sorted(kw))
|
||||||
L = map(repr, L)
|
|
||||||
msg = "Unknown Extension options: " + ', '.join(L)
|
msg = "Unknown Extension options: " + ', '.join(L)
|
||||||
if warnings is not None:
|
if warnings is not None:
|
||||||
warnings.warn(msg)
|
warnings.warn(msg)
|
||||||
else:
|
else:
|
||||||
sys.stderr.write(msg + '\n')
|
sys.stderr.write(msg + '\n')
|
||||||
# class Extension
|
|
||||||
|
|
||||||
|
|
||||||
def read_setup_file(filename):
|
def read_setup_file(filename):
|
||||||
@ -151,7 +149,7 @@ def read_setup_file (filename):
|
|||||||
lstrip_ws=1, rstrip_ws=1)
|
lstrip_ws=1, rstrip_ws=1)
|
||||||
extensions = []
|
extensions = []
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
line = file.readline()
|
line = file.readline()
|
||||||
if line is None: # eof
|
if line is None: # eof
|
||||||
break
|
break
|
||||||
@ -241,5 +239,3 @@ def read_setup_file (filename):
|
|||||||
# 'lib_args': library_args }
|
# 'lib_args': library_args }
|
||||||
|
|
||||||
return extensions
|
return extensions
|
||||||
|
|
||||||
# read_setup_file ()
|
|
||||||
|
@ -8,12 +8,9 @@ additional features:
|
|||||||
* options set attributes of a passed-in object
|
* options set attributes of a passed-in object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, string, re
|
import sys, string, re
|
||||||
from types import *
|
|
||||||
import getopt
|
import getopt
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
|
|
||||||
@ -44,7 +41,6 @@ class FancyGetopt:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, option_table=None):
|
def __init__(self, option_table=None):
|
||||||
|
|
||||||
# The option table is (currently) a list of tuples. The
|
# The option table is (currently) a list of tuples. The
|
||||||
# tuples may have 3 or four values:
|
# tuples may have 3 or four values:
|
||||||
# (long_option, short_option, help_string [, repeatable])
|
# (long_option, short_option, help_string [, repeatable])
|
||||||
@ -84,9 +80,6 @@ class FancyGetopt:
|
|||||||
# but expands short options, converts aliases, etc.
|
# but expands short options, converts aliases, etc.
|
||||||
self.option_order = []
|
self.option_order = []
|
||||||
|
|
||||||
# __init__ ()
|
|
||||||
|
|
||||||
|
|
||||||
def _build_index(self):
|
def _build_index(self):
|
||||||
self.option_index.clear()
|
self.option_index.clear()
|
||||||
for option in self.option_table:
|
for option in self.option_table:
|
||||||
@ -98,14 +91,13 @@ class FancyGetopt:
|
|||||||
|
|
||||||
def add_option(self, long_option, short_option=None, help_string=None):
|
def add_option(self, long_option, short_option=None, help_string=None):
|
||||||
if long_option in self.option_index:
|
if long_option in self.option_index:
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(
|
||||||
"option conflict: already an option '%s'" % long_option
|
"option conflict: already an option '%s'" % long_option)
|
||||||
else:
|
else:
|
||||||
option = (long_option, short_option, help_string)
|
option = (long_option, short_option, help_string)
|
||||||
self.option_table.append(option)
|
self.option_table.append(option)
|
||||||
self.option_index[long_option] = option
|
self.option_index[long_option] = option
|
||||||
|
|
||||||
|
|
||||||
def has_option(self, long_option):
|
def has_option(self, long_option):
|
||||||
"""Return true if the option table for this parser has an
|
"""Return true if the option table for this parser has an
|
||||||
option with long name 'long_option'."""
|
option with long name 'long_option'."""
|
||||||
@ -117,18 +109,15 @@ class FancyGetopt:
|
|||||||
to underscores."""
|
to underscores."""
|
||||||
return long_option.translate(longopt_xlate)
|
return long_option.translate(longopt_xlate)
|
||||||
|
|
||||||
|
|
||||||
def _check_alias_dict(self, aliases, what):
|
def _check_alias_dict(self, aliases, what):
|
||||||
assert type(aliases) is DictionaryType
|
assert isinstance(aliases, dict)
|
||||||
for (alias, opt) in aliases.items():
|
for (alias, opt) in aliases.items():
|
||||||
if alias not in self.option_index:
|
if alias not in self.option_index:
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(("invalid %s '%s': "
|
||||||
("invalid %s '%s': "
|
"option '%s' not defined") % (what, alias, alias))
|
||||||
"option '%s' not defined") % (what, alias, alias)
|
|
||||||
if opt not in self.option_index:
|
if opt not in self.option_index:
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(("invalid %s '%s': "
|
||||||
("invalid %s '%s': "
|
"aliased option '%s' not defined") % (what, alias, opt))
|
||||||
"aliased option '%s' not defined") % (what, alias, opt)
|
|
||||||
|
|
||||||
def set_aliases(self, alias):
|
def set_aliases(self, alias):
|
||||||
"""Set the aliases for this option parser."""
|
"""Set the aliases for this option parser."""
|
||||||
@ -143,7 +132,6 @@ class FancyGetopt:
|
|||||||
self._check_alias_dict(negative_alias, "negative alias")
|
self._check_alias_dict(negative_alias, "negative alias")
|
||||||
self.negative_alias = negative_alias
|
self.negative_alias = negative_alias
|
||||||
|
|
||||||
|
|
||||||
def _grok_option_table(self):
|
def _grok_option_table(self):
|
||||||
"""Populate the various data structures that keep tabs on the
|
"""Populate the various data structures that keep tabs on the
|
||||||
option table. Called by 'getopt()' before it can do anything
|
option table. Called by 'getopt()' before it can do anything
|
||||||
@ -163,19 +151,17 @@ class FancyGetopt:
|
|||||||
else:
|
else:
|
||||||
# the option table is part of the code, so simply
|
# the option table is part of the code, so simply
|
||||||
# assert that it is correct
|
# assert that it is correct
|
||||||
raise ValueError, "invalid option tuple: %r" % (option,)
|
raise ValueError("invalid option tuple: %r" % (option,))
|
||||||
|
|
||||||
# Type- and value-check the option names
|
# Type- and value-check the option names
|
||||||
if not isinstance(long, basestring) or len(long) < 2:
|
if not isinstance(long, basestring) or len(long) < 2:
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(("invalid long option '%s': "
|
||||||
("invalid long option '%s': "
|
"must be a string of length >= 2") % long)
|
||||||
"must be a string of length >= 2") % long
|
|
||||||
|
|
||||||
if (not ((short is None) or
|
if (not ((short is None) or
|
||||||
(isinstance(short, basestring) and len(short) == 1))):
|
(isinstance(short, basestring) and len(short) == 1))):
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError("invalid short option '%s': "
|
||||||
("invalid short option '%s': "
|
"must a single character or None" % short)
|
||||||
"must a single character or None") % short
|
|
||||||
|
|
||||||
self.repeat[long] = repeat
|
self.repeat[long] = repeat
|
||||||
self.long_opts.append(long)
|
self.long_opts.append(long)
|
||||||
@ -185,53 +171,44 @@ class FancyGetopt:
|
|||||||
long = long[0:-1]
|
long = long[0:-1]
|
||||||
self.takes_arg[long] = 1
|
self.takes_arg[long] = 1
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# Is option is a "negative alias" for some other option (eg.
|
# Is option is a "negative alias" for some other option (eg.
|
||||||
# "quiet" == "!verbose")?
|
# "quiet" == "!verbose")?
|
||||||
alias_to = self.negative_alias.get(long)
|
alias_to = self.negative_alias.get(long)
|
||||||
if alias_to is not None:
|
if alias_to is not None:
|
||||||
if self.takes_arg[alias_to]:
|
if self.takes_arg[alias_to]:
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(
|
||||||
("invalid negative alias '%s': "
|
"invalid negative alias '%s': "
|
||||||
"aliased option '%s' takes a value") % \
|
"aliased option '%s' takes a value"
|
||||||
(long, alias_to)
|
% (long, alias_to))
|
||||||
|
|
||||||
self.long_opts[-1] = long # XXX redundant?!
|
self.long_opts[-1] = long # XXX redundant?!
|
||||||
self.takes_arg[long] = 0
|
self.takes_arg[long] = 0
|
||||||
|
|
||||||
else:
|
|
||||||
self.takes_arg[long] = 0
|
|
||||||
|
|
||||||
# If this is an alias option, make sure its "takes arg" flag is
|
# If this is an alias option, make sure its "takes arg" flag is
|
||||||
# the same as the option it's aliased to.
|
# the same as the option it's aliased to.
|
||||||
alias_to = self.alias.get(long)
|
alias_to = self.alias.get(long)
|
||||||
if alias_to is not None:
|
if alias_to is not None:
|
||||||
if self.takes_arg[long] != self.takes_arg[alias_to]:
|
if self.takes_arg[long] != self.takes_arg[alias_to]:
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(
|
||||||
("invalid alias '%s': inconsistent with "
|
"invalid alias '%s': inconsistent with "
|
||||||
"aliased option '%s' (one of them takes a value, "
|
"aliased option '%s' (one of them takes a value, "
|
||||||
"the other doesn't") % (long, alias_to)
|
"the other doesn't"
|
||||||
|
% (long, alias_to))
|
||||||
|
|
||||||
# Now enforce some bondage on the long option name, so we can
|
# Now enforce some bondage on the long option name, so we can
|
||||||
# later translate it to an attribute name on some object. Have
|
# later translate it to an attribute name on some object. Have
|
||||||
# to do this a bit late to make sure we've removed any trailing
|
# to do this a bit late to make sure we've removed any trailing
|
||||||
# '='.
|
# '='.
|
||||||
if not longopt_re.match(long):
|
if not longopt_re.match(long):
|
||||||
raise DistutilsGetoptError, \
|
raise DistutilsGetoptError(
|
||||||
("invalid long option name '%s' " +
|
"invalid long option name '%s' "
|
||||||
"(must be letters, numbers, hyphens only") % long
|
"(must be letters, numbers, hyphens only" % long)
|
||||||
|
|
||||||
self.attr_name[long] = self.get_attr_name(long)
|
self.attr_name[long] = self.get_attr_name(long)
|
||||||
if short:
|
if short:
|
||||||
self.short_opts.append(short)
|
self.short_opts.append(short)
|
||||||
self.short2long[short[0]] = long
|
self.short2long[short[0]] = long
|
||||||
|
|
||||||
# for option_table
|
|
||||||
|
|
||||||
# _grok_option_table()
|
|
||||||
|
|
||||||
|
|
||||||
def getopt(self, args=None, object=None):
|
def getopt(self, args=None, object=None):
|
||||||
"""Parse command-line options in args. Store as attributes on object.
|
"""Parse command-line options in args. Store as attributes on object.
|
||||||
|
|
||||||
@ -247,9 +224,9 @@ class FancyGetopt:
|
|||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
if object is None:
|
if object is None:
|
||||||
object = OptionDummy()
|
object = OptionDummy()
|
||||||
created_object = 1
|
created_object = True
|
||||||
else:
|
else:
|
||||||
created_object = 0
|
created_object = False
|
||||||
|
|
||||||
self._grok_option_table()
|
self._grok_option_table()
|
||||||
|
|
||||||
@ -257,7 +234,7 @@ class FancyGetopt:
|
|||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(args, short_opts, self.long_opts)
|
opts, args = getopt.getopt(args, short_opts, self.long_opts)
|
||||||
except getopt.error as msg:
|
except getopt.error as msg:
|
||||||
raise DistutilsArgError, msg
|
raise DistutilsArgError(msg)
|
||||||
|
|
||||||
for opt, val in opts:
|
for opt, val in opts:
|
||||||
if len(opt) == 2 and opt[0] == '-': # it's a short option
|
if len(opt) == 2 and opt[0] == '-': # it's a short option
|
||||||
@ -293,20 +270,16 @@ class FancyGetopt:
|
|||||||
else:
|
else:
|
||||||
return args
|
return args
|
||||||
|
|
||||||
# getopt()
|
|
||||||
|
|
||||||
|
|
||||||
def get_option_order(self):
|
def get_option_order(self):
|
||||||
"""Returns the list of (option, value) tuples processed by the
|
"""Returns the list of (option, value) tuples processed by the
|
||||||
previous run of 'getopt()'. Raises RuntimeError if
|
previous run of 'getopt()'. Raises RuntimeError if
|
||||||
'getopt()' hasn't been called yet.
|
'getopt()' hasn't been called yet.
|
||||||
"""
|
"""
|
||||||
if self.option_order is None:
|
if self.option_order is None:
|
||||||
raise RuntimeError, "'getopt()' hasn't been called yet"
|
raise RuntimeError("'getopt()' hasn't been called yet")
|
||||||
else:
|
else:
|
||||||
return self.option_order
|
return self.option_order
|
||||||
|
|
||||||
|
|
||||||
def generate_help(self, header=None):
|
def generate_help(self, header=None):
|
||||||
"""Generate help text (a list of strings, one per suggested line of
|
"""Generate help text (a list of strings, one per suggested line of
|
||||||
output) from the option table for this FancyGetopt object.
|
output) from the option table for this FancyGetopt object.
|
||||||
@ -384,21 +357,14 @@ class FancyGetopt:
|
|||||||
|
|
||||||
for l in text[1:]:
|
for l in text[1:]:
|
||||||
lines.append(big_indent + l)
|
lines.append(big_indent + l)
|
||||||
|
|
||||||
# for self.option_table
|
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
# generate_help ()
|
|
||||||
|
|
||||||
def print_help(self, header=None, file=None):
|
def print_help(self, header=None, file=None):
|
||||||
if file is None:
|
if file is None:
|
||||||
file = sys.stdout
|
file = sys.stdout
|
||||||
for line in self.generate_help(header):
|
for line in self.generate_help(header):
|
||||||
file.write(line + "\n")
|
file.write(line + "\n")
|
||||||
|
|
||||||
# class FancyGetopt
|
|
||||||
|
|
||||||
|
|
||||||
def fancy_getopt(options, negative_opt, object, args):
|
def fancy_getopt(options, negative_opt, object, args):
|
||||||
parser = FancyGetopt(options)
|
parser = FancyGetopt(options)
|
||||||
@ -414,7 +380,6 @@ def wrap_text (text, width):
|
|||||||
Split 'text' into multiple lines of no more than 'width' characters
|
Split 'text' into multiple lines of no more than 'width' characters
|
||||||
each, and return the list of strings that results.
|
each, and return the list of strings that results.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if text is None:
|
if text is None:
|
||||||
return []
|
return []
|
||||||
if len(text) <= width:
|
if len(text) <= width:
|
||||||
@ -427,7 +392,6 @@ def wrap_text (text, width):
|
|||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
while chunks:
|
while chunks:
|
||||||
|
|
||||||
cur_line = [] # list of chunks (to-be-joined)
|
cur_line = [] # list of chunks (to-be-joined)
|
||||||
cur_len = 0 # length of current line
|
cur_len = 0 # length of current line
|
||||||
|
|
||||||
@ -444,7 +408,6 @@ def wrap_text (text, width):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if chunks: # any chunks left to process?
|
if chunks: # any chunks left to process?
|
||||||
|
|
||||||
# if the current line is still empty, then we had a single
|
# if the current line is still empty, then we had a single
|
||||||
# chunk that's too big too fit on a line -- so we break
|
# chunk that's too big too fit on a line -- so we break
|
||||||
# down and break it up at the line width
|
# down and break it up at the line width
|
||||||
@ -462,12 +425,8 @@ def wrap_text (text, width):
|
|||||||
# string, of course!
|
# string, of course!
|
||||||
lines.append(''.join(cur_line))
|
lines.append(''.join(cur_line))
|
||||||
|
|
||||||
# while chunks
|
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
# wrap_text ()
|
|
||||||
|
|
||||||
|
|
||||||
def translate_longopt(opt):
|
def translate_longopt(opt):
|
||||||
"""Convert a long option name to a valid Python identifier by
|
"""Convert a long option name to a valid Python identifier by
|
||||||
@ -486,8 +445,6 @@ class OptionDummy:
|
|||||||
for opt in options:
|
for opt in options:
|
||||||
setattr(self, opt, None)
|
setattr(self, opt, None)
|
||||||
|
|
||||||
# class OptionDummy
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
text = """\
|
text = """\
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
Utility functions for operating on single files.
|
Utility functions for operating on single files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@ -26,7 +24,6 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
|
|||||||
"""
|
"""
|
||||||
# Stolen from shutil module in the standard library, but with
|
# Stolen from shutil module in the standard library, but with
|
||||||
# custom error-handling added.
|
# custom error-handling added.
|
||||||
|
|
||||||
fsrc = None
|
fsrc = None
|
||||||
fdst = None
|
fdst = None
|
||||||
try:
|
try:
|
||||||
@ -34,31 +31,30 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
|
|||||||
fsrc = open(src, 'rb')
|
fsrc = open(src, 'rb')
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
(errno, errstr) = e
|
(errno, errstr) = e
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError("could not open '%s': %s" % (src, errstr))
|
||||||
"could not open '%s': %s" % (src, errstr)
|
|
||||||
|
|
||||||
if os.path.exists(dst):
|
if os.path.exists(dst):
|
||||||
try:
|
try:
|
||||||
os.unlink(dst)
|
os.unlink(dst)
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
(errno, errstr) = e
|
(errno, errstr) = e
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"could not delete '%s': %s" % (dst, errstr)
|
"could not delete '%s': %s" % (dst, errstr))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fdst = open(dst, 'wb')
|
fdst = open(dst, 'wb')
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
(errno, errstr) = e
|
(errno, errstr) = e
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"could not create '%s': %s" % (dst, errstr)
|
"could not create '%s': %s" % (dst, errstr))
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
buf = fsrc.read(buffer_size)
|
buf = fsrc.read(buffer_size)
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
(errno, errstr) = e
|
(errno, errstr) = e
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"could not read from '%s': %s" % (src, errstr)
|
"could not read from '%s': %s" % (src, errstr))
|
||||||
|
|
||||||
if not buf:
|
if not buf:
|
||||||
break
|
break
|
||||||
@ -67,25 +63,16 @@ def _copy_file_contents (src, dst, buffer_size=16*1024):
|
|||||||
fdst.write(buf)
|
fdst.write(buf)
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
(errno, errstr) = e
|
(errno, errstr) = e
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"could not write to '%s': %s" % (dst, errstr)
|
"could not write to '%s': %s" % (dst, errstr))
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if fdst:
|
if fdst:
|
||||||
fdst.close()
|
fdst.close()
|
||||||
if fsrc:
|
if fsrc:
|
||||||
fsrc.close()
|
fsrc.close()
|
||||||
|
|
||||||
# _copy_file_contents()
|
def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
|
||||||
|
link=None, verbose=0, dry_run=0):
|
||||||
def copy_file (src, dst,
|
|
||||||
preserve_mode=1,
|
|
||||||
preserve_times=1,
|
|
||||||
update=0,
|
|
||||||
link=None,
|
|
||||||
verbose=0,
|
|
||||||
dry_run=0):
|
|
||||||
|
|
||||||
"""Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
|
"""Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
|
||||||
copied there with the same name; otherwise, it must be a filename. (If
|
copied there with the same name; otherwise, it must be a filename. (If
|
||||||
the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
|
the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
|
||||||
@ -120,8 +107,8 @@ def copy_file (src, dst,
|
|||||||
from stat import ST_ATIME, ST_MTIME, ST_MODE, S_IMODE
|
from stat import ST_ATIME, ST_MTIME, ST_MODE, S_IMODE
|
||||||
|
|
||||||
if not os.path.isfile(src):
|
if not os.path.isfile(src):
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"can't copy '%s': doesn't exist or not a regular file" % src
|
"can't copy '%s': doesn't exist or not a regular file" % src)
|
||||||
|
|
||||||
if os.path.isdir(dst):
|
if os.path.isdir(dst):
|
||||||
dir = dst
|
dir = dst
|
||||||
@ -131,13 +118,12 @@ def copy_file (src, dst,
|
|||||||
|
|
||||||
if update and not newer(src, dst):
|
if update and not newer(src, dst):
|
||||||
log.debug("not copying %s (output up-to-date)", src)
|
log.debug("not copying %s (output up-to-date)", src)
|
||||||
return dst, 0
|
return (dst, 0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
action = _copy_action[link]
|
action = _copy_action[link]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError, \
|
raise ValueError("invalid value '%s' for 'link' argument" % link)
|
||||||
"invalid value '%s' for 'link' argument" % link
|
|
||||||
if os.path.basename(dst) == os.path.basename(src):
|
if os.path.basename(dst) == os.path.basename(src):
|
||||||
log.info("%s %s -> %s", action, src, dir)
|
log.info("%s %s -> %s", action, src, dir)
|
||||||
else:
|
else:
|
||||||
@ -152,8 +138,8 @@ def copy_file (src, dst,
|
|||||||
try:
|
try:
|
||||||
macostools.copy(src, dst, 0, preserve_times)
|
macostools.copy(src, dst, 0, preserve_times)
|
||||||
except os.error as exc:
|
except os.error as exc:
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"could not copy '%s' to '%s': %s" % (src, dst, exc[-1])
|
"could not copy '%s' to '%s': %s" % (src, dst, exc[-1]))
|
||||||
|
|
||||||
# If linking (hard or symbolic), use the appropriate system call
|
# If linking (hard or symbolic), use the appropriate system call
|
||||||
# (Unix only, of course, but that's the caller's responsibility)
|
# (Unix only, of course, but that's the caller's responsibility)
|
||||||
@ -180,8 +166,6 @@ def copy_file (src, dst,
|
|||||||
|
|
||||||
return (dst, 1)
|
return (dst, 1)
|
||||||
|
|
||||||
# copy_file ()
|
|
||||||
|
|
||||||
|
|
||||||
# XXX I suspect this is Unix-specific -- need porting help!
|
# XXX I suspect this is Unix-specific -- need porting help!
|
||||||
def move_file (src, dst,
|
def move_file (src, dst,
|
||||||
@ -204,31 +188,30 @@ def move_file (src, dst,
|
|||||||
return dst
|
return dst
|
||||||
|
|
||||||
if not isfile(src):
|
if not isfile(src):
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError("can't move '%s': not a regular file" % src)
|
||||||
"can't move '%s': not a regular file" % src
|
|
||||||
|
|
||||||
if isdir(dst):
|
if isdir(dst):
|
||||||
dst = os.path.join(dst, basename(src))
|
dst = os.path.join(dst, basename(src))
|
||||||
elif exists(dst):
|
elif exists(dst):
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"can't move '%s': destination '%s' already exists" % \
|
"can't move '%s': destination '%s' already exists" %
|
||||||
(src, dst)
|
(src, dst))
|
||||||
|
|
||||||
if not isdir(dirname(dst)):
|
if not isdir(dirname(dst)):
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"can't move '%s': destination '%s' not a valid path" % \
|
"can't move '%s': destination '%s' not a valid path" %
|
||||||
(src, dst)
|
(src, dst))
|
||||||
|
|
||||||
copy_it = 0
|
copy_it = False
|
||||||
try:
|
try:
|
||||||
os.rename(src, dst)
|
os.rename(src, dst)
|
||||||
except os.error as e:
|
except os.error as e:
|
||||||
(num, msg) = e
|
(num, msg) = e
|
||||||
if num == errno.EXDEV:
|
if num == errno.EXDEV:
|
||||||
copy_it = 1
|
copy_it = True
|
||||||
else:
|
else:
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
"couldn't move '%s' to '%s': %s" % (src, dst, msg)
|
"couldn't move '%s' to '%s': %s" % (src, dst, msg))
|
||||||
|
|
||||||
if copy_it:
|
if copy_it:
|
||||||
copy_file(src, dst)
|
copy_file(src, dst)
|
||||||
@ -240,15 +223,12 @@ def move_file (src, dst,
|
|||||||
os.unlink(dst)
|
os.unlink(dst)
|
||||||
except os.error:
|
except os.error:
|
||||||
pass
|
pass
|
||||||
raise DistutilsFileError, \
|
raise DistutilsFileError(
|
||||||
("couldn't move '%s' to '%s' by copy/delete: " +
|
"couldn't move '%s' to '%s' by copy/delete: "
|
||||||
"delete '%s' failed: %s") % \
|
"delete '%s' failed: %s"
|
||||||
(src, dst, src, msg)
|
% (src, dst, src, msg))
|
||||||
|
|
||||||
return dst
|
return dst
|
||||||
|
|
||||||
# move_file ()
|
|
||||||
|
|
||||||
|
|
||||||
def write_file (filename, contents):
|
def write_file (filename, contents):
|
||||||
"""Create a file with the specified name and write 'contents' (a
|
"""Create a file with the specified name and write 'contents' (a
|
||||||
|
@ -4,20 +4,16 @@ Provides the FileList class, used for poking about the filesystem
|
|||||||
and building lists of files.
|
and building lists of files.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import os, re
|
import os, re
|
||||||
import fnmatch
|
import fnmatch
|
||||||
from types import *
|
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from distutils.util import convert_path
|
from distutils.util import convert_path
|
||||||
from distutils.errors import DistutilsTemplateError, DistutilsInternalError
|
from distutils.errors import DistutilsTemplateError, DistutilsInternalError
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
||||||
class FileList:
|
class FileList:
|
||||||
|
|
||||||
"""A list of files built by on exploring the filesystem and filtered by
|
"""A list of files built by on exploring the filesystem and filtered by
|
||||||
applying various patterns to what we find there.
|
applying various patterns to what we find there.
|
||||||
|
|
||||||
@ -32,12 +28,9 @@ class FileList:
|
|||||||
filtering applied)
|
filtering applied)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self, warn=None, debug_print=None):
|
||||||
warn=None,
|
|
||||||
debug_print=None):
|
|
||||||
# ignore argument to FileList, but keep them for backwards
|
# ignore argument to FileList, but keep them for backwards
|
||||||
# compatibility
|
# compatibility
|
||||||
|
|
||||||
self.allfiles = None
|
self.allfiles = None
|
||||||
self.files = []
|
self.files = []
|
||||||
|
|
||||||
@ -91,36 +84,26 @@ class FileList:
|
|||||||
if action in ('include', 'exclude',
|
if action in ('include', 'exclude',
|
||||||
'global-include', 'global-exclude'):
|
'global-include', 'global-exclude'):
|
||||||
if len(words) < 2:
|
if len(words) < 2:
|
||||||
raise DistutilsTemplateError, \
|
raise DistutilsTemplateError(
|
||||||
"'%s' expects <pattern1> <pattern2> ..." % action
|
"'%s' expects <pattern1> <pattern2> ..." % action)
|
||||||
|
|
||||||
patterns = map(convert_path, words[1:])
|
patterns = map(convert_path, words[1:])
|
||||||
|
|
||||||
elif action in ('recursive-include', 'recursive-exclude'):
|
elif action in ('recursive-include', 'recursive-exclude'):
|
||||||
if len(words) < 3:
|
if len(words) < 3:
|
||||||
raise DistutilsTemplateError, \
|
raise DistutilsTemplateError(
|
||||||
"'%s' expects <dir> <pattern1> <pattern2> ..." % action
|
"'%s' expects <dir> <pattern1> <pattern2> ..." % action)
|
||||||
|
|
||||||
dir = convert_path(words[1])
|
dir = convert_path(words[1])
|
||||||
patterns = map(convert_path, words[2:])
|
patterns = map(convert_path, words[2:])
|
||||||
|
|
||||||
elif action in ('graft', 'prune'):
|
elif action in ('graft', 'prune'):
|
||||||
if len(words) != 2:
|
if len(words) != 2:
|
||||||
raise DistutilsTemplateError, \
|
raise DistutilsTemplateError(
|
||||||
"'%s' expects a single <dir_pattern>" % action
|
"'%s' expects a single <dir_pattern>" % action)
|
||||||
|
|
||||||
dir_pattern = convert_path(words[1])
|
dir_pattern = convert_path(words[1])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise DistutilsTemplateError, "unknown action '%s'" % action
|
raise DistutilsTemplateError("unknown action '%s'" % action)
|
||||||
|
|
||||||
return (action, patterns, dir, dir_pattern)
|
return (action, patterns, dir, dir_pattern)
|
||||||
|
|
||||||
# _parse_template_line ()
|
|
||||||
|
|
||||||
|
|
||||||
def process_template_line(self, line):
|
def process_template_line(self, line):
|
||||||
|
|
||||||
# Parse the line: split it up, make sure the right number of words
|
# Parse the line: split it up, make sure the right number of words
|
||||||
# is there, and return the relevant words. 'action' is always
|
# is there, and return the relevant words. 'action' is always
|
||||||
# defined: it's the first word of the line. Which of the other
|
# defined: it's the first word of the line. Which of the other
|
||||||
@ -149,7 +132,7 @@ class FileList:
|
|||||||
self.debug_print("global-include " + ' '.join(patterns))
|
self.debug_print("global-include " + ' '.join(patterns))
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
if not self.include_pattern(pattern, anchor=0):
|
if not self.include_pattern(pattern, anchor=0):
|
||||||
log.warn(("warning: no files found matching '%s' " +
|
log.warn(("warning: no files found matching '%s' "
|
||||||
"anywhere in distribution"), pattern)
|
"anywhere in distribution"), pattern)
|
||||||
|
|
||||||
elif action == 'global-exclude':
|
elif action == 'global-exclude':
|
||||||
@ -165,7 +148,7 @@ class FileList:
|
|||||||
(dir, ' '.join(patterns)))
|
(dir, ' '.join(patterns)))
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
if not self.include_pattern(pattern, prefix=dir):
|
if not self.include_pattern(pattern, prefix=dir):
|
||||||
log.warn(("warning: no files found matching '%s' " +
|
log.warn(("warning: no files found matching '%s' "
|
||||||
"under directory '%s'"),
|
"under directory '%s'"),
|
||||||
pattern, dir)
|
pattern, dir)
|
||||||
|
|
||||||
@ -187,19 +170,16 @@ class FileList:
|
|||||||
elif action == 'prune':
|
elif action == 'prune':
|
||||||
self.debug_print("prune " + dir_pattern)
|
self.debug_print("prune " + dir_pattern)
|
||||||
if not self.exclude_pattern(None, prefix=dir_pattern):
|
if not self.exclude_pattern(None, prefix=dir_pattern):
|
||||||
log.warn(("no previously-included directories found " +
|
log.warn(("no previously-included directories found "
|
||||||
"matching '%s'"), dir_pattern)
|
"matching '%s'"), dir_pattern)
|
||||||
else:
|
else:
|
||||||
raise DistutilsInternalError, \
|
raise DistutilsInternalError(
|
||||||
"this cannot happen: invalid action '%s'" % action
|
"this cannot happen: invalid action '%s'" % action)
|
||||||
|
|
||||||
# process_template_line ()
|
|
||||||
|
|
||||||
|
|
||||||
# -- Filtering/selection methods -----------------------------------
|
# -- Filtering/selection methods -----------------------------------
|
||||||
|
|
||||||
def include_pattern (self, pattern,
|
def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
|
||||||
anchor=1, prefix=None, is_regex=0):
|
|
||||||
"""Select strings (presumably filenames) from 'self.files' that
|
"""Select strings (presumably filenames) from 'self.files' that
|
||||||
match 'pattern', a Unix-style wildcard (glob) pattern. Patterns
|
match 'pattern', a Unix-style wildcard (glob) pattern. Patterns
|
||||||
are not quite the same as implemented by the 'fnmatch' module: '*'
|
are not quite the same as implemented by the 'fnmatch' module: '*'
|
||||||
@ -222,9 +202,9 @@ class FileList:
|
|||||||
|
|
||||||
Selected strings will be added to self.files.
|
Selected strings will be added to self.files.
|
||||||
|
|
||||||
Return 1 if files are found.
|
Return True if files are found, False otherwise.
|
||||||
"""
|
"""
|
||||||
files_found = 0
|
files_found = False
|
||||||
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
|
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
|
||||||
self.debug_print("include_pattern: applying regex r'%s'" %
|
self.debug_print("include_pattern: applying regex r'%s'" %
|
||||||
pattern_re.pattern)
|
pattern_re.pattern)
|
||||||
@ -237,12 +217,9 @@ class FileList:
|
|||||||
if pattern_re.search(name):
|
if pattern_re.search(name):
|
||||||
self.debug_print(" adding " + name)
|
self.debug_print(" adding " + name)
|
||||||
self.files.append(name)
|
self.files.append(name)
|
||||||
files_found = 1
|
files_found = True
|
||||||
|
|
||||||
return files_found
|
return files_found
|
||||||
|
|
||||||
# include_pattern ()
|
|
||||||
|
|
||||||
|
|
||||||
def exclude_pattern (self, pattern,
|
def exclude_pattern (self, pattern,
|
||||||
anchor=1, prefix=None, is_regex=0):
|
anchor=1, prefix=None, is_regex=0):
|
||||||
@ -250,9 +227,9 @@ class FileList:
|
|||||||
'pattern'. Other parameters are the same as for
|
'pattern'. Other parameters are the same as for
|
||||||
'include_pattern()', above.
|
'include_pattern()', above.
|
||||||
The list 'self.files' is modified in place.
|
The list 'self.files' is modified in place.
|
||||||
Return 1 if files are found.
|
Return True if files are found, False otherwise.
|
||||||
"""
|
"""
|
||||||
files_found = 0
|
files_found = False
|
||||||
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
|
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
|
||||||
self.debug_print("exclude_pattern: applying regex r'%s'" %
|
self.debug_print("exclude_pattern: applying regex r'%s'" %
|
||||||
pattern_re.pattern)
|
pattern_re.pattern)
|
||||||
@ -260,14 +237,9 @@ class FileList:
|
|||||||
if pattern_re.search(self.files[i]):
|
if pattern_re.search(self.files[i]):
|
||||||
self.debug_print(" removing " + self.files[i])
|
self.debug_print(" removing " + self.files[i])
|
||||||
del self.files[i]
|
del self.files[i]
|
||||||
files_found = 1
|
files_found = True
|
||||||
|
|
||||||
return files_found
|
return files_found
|
||||||
|
|
||||||
# exclude_pattern ()
|
|
||||||
|
|
||||||
# class FileList
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Utility functions
|
# Utility functions
|
||||||
@ -300,7 +272,6 @@ def findall (dir = os.curdir):
|
|||||||
list.append(fullname)
|
list.append(fullname)
|
||||||
elif S_ISDIR(mode) and not S_ISLNK(mode):
|
elif S_ISDIR(mode) and not S_ISLNK(mode):
|
||||||
push(fullname)
|
push(fullname)
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
|
||||||
|
|
||||||
@ -322,8 +293,6 @@ def glob_to_re (pattern):
|
|||||||
pattern_re = re.sub(r'(^|[^\\])\.', r'\1[^/]', pattern_re)
|
pattern_re = re.sub(r'(^|[^\\])\.', r'\1[^/]', pattern_re)
|
||||||
return pattern_re
|
return pattern_re
|
||||||
|
|
||||||
# glob_to_re ()
|
|
||||||
|
|
||||||
|
|
||||||
def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
|
def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
|
||||||
"""Translate a shell-like wildcard pattern to a compiled regular
|
"""Translate a shell-like wildcard pattern to a compiled regular
|
||||||
@ -350,5 +319,3 @@ def translate_pattern (pattern, anchor=1, prefix=None, is_regex=0):
|
|||||||
pattern_re = "^" + pattern_re
|
pattern_re = "^" + pattern_re
|
||||||
|
|
||||||
return re.compile(pattern_re)
|
return re.compile(pattern_re)
|
||||||
|
|
||||||
# translate_pattern ()
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
"""A simple log mechanism styled after PEP 282."""
|
"""A simple log mechanism styled after PEP 282."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
# The class here is styled after PEP 282 so that it could later be
|
# The class here is styled after PEP 282 so that it could later be
|
||||||
# replaced with a standard Python logging implementation.
|
# replaced with a standard Python logging implementation.
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ for the Microsoft Visual Studio.
|
|||||||
# hacked by Robin Becker and Thomas Heller to do a better job of
|
# hacked by Robin Becker and Thomas Heller to do a better job of
|
||||||
# finding DevStudio (through the registry)
|
# finding DevStudio (through the registry)
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
@ -20,11 +18,11 @@ from distutils.ccompiler import \
|
|||||||
CCompiler, gen_preprocess_options, gen_lib_options
|
CCompiler, gen_preprocess_options, gen_lib_options
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
||||||
_can_read_reg = 0
|
_can_read_reg = False
|
||||||
try:
|
try:
|
||||||
import _winreg
|
import _winreg
|
||||||
|
|
||||||
_can_read_reg = 1
|
_can_read_reg = True
|
||||||
hkey_mod = _winreg
|
hkey_mod = _winreg
|
||||||
|
|
||||||
RegOpenKeyEx = _winreg.OpenKeyEx
|
RegOpenKeyEx = _winreg.OpenKeyEx
|
||||||
@ -36,14 +34,13 @@ except ImportError:
|
|||||||
try:
|
try:
|
||||||
import win32api
|
import win32api
|
||||||
import win32con
|
import win32con
|
||||||
_can_read_reg = 1
|
_can_read_reg = True
|
||||||
hkey_mod = win32con
|
hkey_mod = win32con
|
||||||
|
|
||||||
RegOpenKeyEx = win32api.RegOpenKeyEx
|
RegOpenKeyEx = win32api.RegOpenKeyEx
|
||||||
RegEnumKey = win32api.RegEnumKey
|
RegEnumKey = win32api.RegEnumKey
|
||||||
RegEnumValue = win32api.RegEnumValue
|
RegEnumValue = win32api.RegEnumValue
|
||||||
RegError = win32api.error
|
RegError = win32api.error
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
log.info("Warning: Can't read registry to find the "
|
log.info("Warning: Can't read registry to find the "
|
||||||
"necessary compiler setting\n"
|
"necessary compiler setting\n"
|
||||||
@ -59,20 +56,19 @@ if _can_read_reg:
|
|||||||
|
|
||||||
def read_keys(base, key):
|
def read_keys(base, key):
|
||||||
"""Return list of registry keys."""
|
"""Return list of registry keys."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
handle = RegOpenKeyEx(base, key)
|
handle = RegOpenKeyEx(base, key)
|
||||||
except RegError:
|
except RegError:
|
||||||
return None
|
return None
|
||||||
L = []
|
L = []
|
||||||
i = 0
|
i = 0
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
k = RegEnumKey(handle, i)
|
k = RegEnumKey(handle, i)
|
||||||
except RegError:
|
except RegError:
|
||||||
break
|
break
|
||||||
L.append(k)
|
L.append(k)
|
||||||
i = i + 1
|
i += 1
|
||||||
return L
|
return L
|
||||||
|
|
||||||
def read_values(base, key):
|
def read_values(base, key):
|
||||||
@ -86,14 +82,14 @@ def read_values(base, key):
|
|||||||
return None
|
return None
|
||||||
d = {}
|
d = {}
|
||||||
i = 0
|
i = 0
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
name, value, type = RegEnumValue(handle, i)
|
name, value, type = RegEnumValue(handle, i)
|
||||||
except RegError:
|
except RegError:
|
||||||
break
|
break
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
d[convert_mbcs(name)] = convert_mbcs(value)
|
d[convert_mbcs(name)] = convert_mbcs(value)
|
||||||
i = i + 1
|
i += 1
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def convert_mbcs(s):
|
def convert_mbcs(s):
|
||||||
@ -106,7 +102,6 @@ def convert_mbcs(s):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
class MacroExpander:
|
class MacroExpander:
|
||||||
|
|
||||||
def __init__(self, version):
|
def __init__(self, version):
|
||||||
self.macros = {}
|
self.macros = {}
|
||||||
self.load_macros(version)
|
self.load_macros(version)
|
||||||
@ -130,8 +125,8 @@ class MacroExpander:
|
|||||||
else:
|
else:
|
||||||
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
|
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
|
||||||
except KeyError as exc: #
|
except KeyError as exc: #
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError(
|
||||||
("""Python was built with Visual Studio 2003;
|
"""Python was built with Visual Studio 2003;
|
||||||
extensions must be built with a compiler than can generate compatible binaries.
|
extensions must be built with a compiler than can generate compatible binaries.
|
||||||
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
|
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
|
||||||
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
|
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
|
||||||
@ -157,7 +152,6 @@ def get_build_version():
|
|||||||
For Python 2.3 and up, the version number is included in
|
For Python 2.3 and up, the version number is included in
|
||||||
sys.version. For earlier versions, assume the compiler is MSVC 6.
|
sys.version. For earlier versions, assume the compiler is MSVC 6.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
prefix = "MSC v."
|
prefix = "MSC v."
|
||||||
i = sys.version.find(prefix)
|
i = sys.version.find(prefix)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
@ -264,10 +258,10 @@ class MSVCCompiler (CCompiler) :
|
|||||||
self.__paths = self.get_msvc_paths("path")
|
self.__paths = self.get_msvc_paths("path")
|
||||||
|
|
||||||
if len(self.__paths) == 0:
|
if len(self.__paths) == 0:
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError("Python was built with %s, "
|
||||||
("Python was built with %s, "
|
|
||||||
"and extensions need to be built with the same "
|
"and extensions need to be built with the same "
|
||||||
"version of the compiler, but it isn't installed." % self.__product)
|
"version of the compiler, but it isn't installed."
|
||||||
|
% self.__product)
|
||||||
|
|
||||||
self.cc = self.find_exe("cl.exe")
|
self.cc = self.find_exe("cl.exe")
|
||||||
self.linker = self.find_exe("link.exe")
|
self.linker = self.find_exe("link.exe")
|
||||||
@ -344,17 +338,16 @@ class MSVCCompiler (CCompiler) :
|
|||||||
base + self.obj_extension))
|
base + self.obj_extension))
|
||||||
return obj_names
|
return obj_names
|
||||||
|
|
||||||
# object_filenames ()
|
|
||||||
|
|
||||||
|
|
||||||
def compile(self, sources,
|
def compile(self, sources,
|
||||||
output_dir=None, macros=None, include_dirs=None, debug=0,
|
output_dir=None, macros=None, include_dirs=None, debug=0,
|
||||||
extra_preargs=None, extra_postargs=None, depends=None):
|
extra_preargs=None, extra_postargs=None, depends=None):
|
||||||
|
|
||||||
if not self.initialized: self.initialize()
|
if not self.initialized:
|
||||||
macros, objects, extra_postargs, pp_opts, build = \
|
self.initialize()
|
||||||
self._setup_compile(output_dir, macros, include_dirs, sources,
|
compile_info = self._setup_compile(output_dir, macros, include_dirs,
|
||||||
depends, extra_postargs)
|
sources, depends, extra_postargs)
|
||||||
|
macros, objects, extra_postargs, pp_opts, build = compile_info
|
||||||
|
|
||||||
compile_opts = extra_preargs or []
|
compile_opts = extra_preargs or []
|
||||||
compile_opts.append ('/c')
|
compile_opts.append ('/c')
|
||||||
@ -386,10 +379,9 @@ class MSVCCompiler (CCompiler) :
|
|||||||
self.spawn([self.rc] + pp_opts +
|
self.spawn([self.rc] + pp_opts +
|
||||||
[output_opt] + [input_opt])
|
[output_opt] + [input_opt])
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
continue
|
continue
|
||||||
elif ext in self._mc_extensions:
|
elif ext in self._mc_extensions:
|
||||||
|
|
||||||
# Compile .MC to .RC file to .RES file.
|
# Compile .MC to .RC file to .RES file.
|
||||||
# * '-h dir' specifies the directory for the
|
# * '-h dir' specifies the directory for the
|
||||||
# generated include file
|
# generated include file
|
||||||
@ -401,7 +393,6 @@ class MSVCCompiler (CCompiler) :
|
|||||||
# we use the source-directory for the include file and
|
# we use the source-directory for the include file and
|
||||||
# the build directory for the RC file and message
|
# the build directory for the RC file and message
|
||||||
# resources. This works at least for win32all.
|
# resources. This works at least for win32all.
|
||||||
|
|
||||||
h_dir = os.path.dirname(src)
|
h_dir = os.path.dirname(src)
|
||||||
rc_dir = os.path.dirname(obj)
|
rc_dir = os.path.dirname(obj)
|
||||||
try:
|
try:
|
||||||
@ -415,13 +406,12 @@ class MSVCCompiler (CCompiler) :
|
|||||||
["/fo" + obj] + [rc_file])
|
["/fo" + obj] + [rc_file])
|
||||||
|
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# how to handle this file?
|
# how to handle this file?
|
||||||
raise CompileError (
|
raise CompileError("Don't know how to compile %s to %s"
|
||||||
"Don't know how to compile %s to %s" % \
|
% (src, obj))
|
||||||
(src, obj))
|
|
||||||
|
|
||||||
output_opt = "/Fo" + obj
|
output_opt = "/Fo" + obj
|
||||||
try:
|
try:
|
||||||
@ -429,12 +419,10 @@ class MSVCCompiler (CCompiler) :
|
|||||||
[input_opt, output_opt] +
|
[input_opt, output_opt] +
|
||||||
extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
# compile ()
|
|
||||||
|
|
||||||
|
|
||||||
def create_static_lib(self,
|
def create_static_lib(self,
|
||||||
objects,
|
objects,
|
||||||
@ -443,24 +431,23 @@ class MSVCCompiler (CCompiler) :
|
|||||||
debug=0,
|
debug=0,
|
||||||
target_lang=None):
|
target_lang=None):
|
||||||
|
|
||||||
if not self.initialized: self.initialize()
|
if not self.initialized:
|
||||||
|
self.initialize()
|
||||||
(objects, output_dir) = self._fix_object_args(objects, output_dir)
|
(objects, output_dir) = self._fix_object_args(objects, output_dir)
|
||||||
output_filename = \
|
output_filename = self.library_filename(output_libname,
|
||||||
self.library_filename (output_libname, output_dir=output_dir)
|
output_dir=output_dir)
|
||||||
|
|
||||||
if self._need_link(objects, output_filename):
|
if self._need_link(objects, output_filename):
|
||||||
lib_args = objects + ['/OUT:' + output_filename]
|
lib_args = objects + ['/OUT:' + output_filename]
|
||||||
if debug:
|
if debug:
|
||||||
pass # XXX what goes here?
|
pass # XXX what goes here?
|
||||||
try:
|
try:
|
||||||
self.spawn ([self.lib] + lib_args)
|
self.([self.lib] + lib_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise LibError, msg
|
raise LibError(msg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.debug("skipping %s (up-to-date)", output_filename)
|
log.debug("skipping %s (up-to-date)", output_filename)
|
||||||
|
|
||||||
# create_static_lib ()
|
|
||||||
|
|
||||||
def link(self,
|
def link(self,
|
||||||
target_desc,
|
target_desc,
|
||||||
@ -477,10 +464,12 @@ class MSVCCompiler (CCompiler) :
|
|||||||
build_temp=None,
|
build_temp=None,
|
||||||
target_lang=None):
|
target_lang=None):
|
||||||
|
|
||||||
if not self.initialized: self.initialize()
|
if not self.initialized:
|
||||||
|
self.initialize()
|
||||||
(objects, output_dir) = self._fix_object_args(objects, output_dir)
|
(objects, output_dir) = self._fix_object_args(objects, output_dir)
|
||||||
(libraries, library_dirs, runtime_library_dirs) = \
|
fixed_args = self._fix_lib_args(libraries, library_dirs,
|
||||||
self._fix_lib_args (libraries, library_dirs, runtime_library_dirs)
|
runtime_library_dirs)
|
||||||
|
(libraries, library_dirs, runtime_library_dirs) = fixed_args
|
||||||
|
|
||||||
if runtime_library_dirs:
|
if runtime_library_dirs:
|
||||||
self.warn ("I don't know what to do with 'runtime_library_dirs': "
|
self.warn ("I don't know what to do with 'runtime_library_dirs': "
|
||||||
@ -493,7 +482,6 @@ class MSVCCompiler (CCompiler) :
|
|||||||
output_filename = os.path.join(output_dir, output_filename)
|
output_filename = os.path.join(output_dir, output_filename)
|
||||||
|
|
||||||
if self._need_link(objects, output_filename):
|
if self._need_link(objects, output_filename):
|
||||||
|
|
||||||
if target_desc == CCompiler.EXECUTABLE:
|
if target_desc == CCompiler.EXECUTABLE:
|
||||||
if debug:
|
if debug:
|
||||||
ldflags = self.ldflags_shared_debug[1:]
|
ldflags = self.ldflags_shared_debug[1:]
|
||||||
@ -534,13 +522,11 @@ class MSVCCompiler (CCompiler) :
|
|||||||
try:
|
try:
|
||||||
self.spawn([self.linker] + ld_args)
|
self.spawn([self.linker] + ld_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise LinkError, msg
|
raise LinkError(msg)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.debug("skipping %s (up-to-date)", output_filename)
|
log.debug("skipping %s (up-to-date)", output_filename)
|
||||||
|
|
||||||
# link ()
|
|
||||||
|
|
||||||
|
|
||||||
# -- Miscellaneous methods -----------------------------------------
|
# -- Miscellaneous methods -----------------------------------------
|
||||||
# These are all used by the 'gen_lib_options() function, in
|
# These are all used by the 'gen_lib_options() function, in
|
||||||
@ -550,8 +536,8 @@ class MSVCCompiler (CCompiler) :
|
|||||||
return "/LIBPATH:" + dir
|
return "/LIBPATH:" + dir
|
||||||
|
|
||||||
def runtime_library_dir_option(self, dir):
|
def runtime_library_dir_option(self, dir):
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError(
|
||||||
"don't know how to set runtime library search path for MSVC++"
|
"don't know how to set runtime library search path for MSVC++")
|
||||||
|
|
||||||
def library_option(self, lib):
|
def library_option(self, lib):
|
||||||
return self.library_filename(lib)
|
return self.library_filename(lib)
|
||||||
@ -573,8 +559,6 @@ class MSVCCompiler (CCompiler) :
|
|||||||
# Oops, didn't find it in *any* of 'dirs'
|
# Oops, didn't find it in *any* of 'dirs'
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# find_library_file ()
|
|
||||||
|
|
||||||
# Helper methods for using the MSVC registry settings
|
# Helper methods for using the MSVC registry settings
|
||||||
|
|
||||||
def find_exe(self, exe):
|
def find_exe(self, exe):
|
||||||
@ -586,7 +570,6 @@ class MSVCCompiler (CCompiler) :
|
|||||||
absolute path that is known to exist. If none of them work, just
|
absolute path that is known to exist. If none of them work, just
|
||||||
return the original program name, 'exe'.
|
return the original program name, 'exe'.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for p in self.__paths:
|
for p in self.__paths:
|
||||||
fn = os.path.join(os.path.abspath(p), exe)
|
fn = os.path.join(os.path.abspath(p), exe)
|
||||||
if os.path.isfile(fn):
|
if os.path.isfile(fn):
|
||||||
@ -606,7 +589,6 @@ class MSVCCompiler (CCompiler) :
|
|||||||
Return a list of strings. The list will be empty if unable to
|
Return a list of strings. The list will be empty if unable to
|
||||||
access the registry or appropriate registry keys not found.
|
access the registry or appropriate registry keys not found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not _can_read_reg:
|
if not _can_read_reg:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -4,12 +4,9 @@ Contains MWerksCompiler, an implementation of the abstract CCompiler class
|
|||||||
for MetroWerks CodeWarrior on the Macintosh. Needs work to support CW on
|
for MetroWerks CodeWarrior on the Macintosh. Needs work to support CW on
|
||||||
Windows."""
|
Windows."""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from types import *
|
|
||||||
from distutils.errors import \
|
from distutils.errors import \
|
||||||
DistutilsExecError, DistutilsPlatformError, \
|
DistutilsExecError, DistutilsPlatformError, \
|
||||||
CompileError, LibError, LinkError
|
CompileError, LibError, LinkError
|
||||||
@ -96,13 +93,13 @@ class MWerksCompiler (CCompiler) :
|
|||||||
|
|
||||||
# First examine a couple of options for things that aren't implemented yet
|
# First examine a couple of options for things that aren't implemented yet
|
||||||
if not target_desc in (self.SHARED_LIBRARY, self.SHARED_OBJECT):
|
if not target_desc in (self.SHARED_LIBRARY, self.SHARED_OBJECT):
|
||||||
raise DistutilsPlatformError, 'Can only make SHARED_LIBRARY or SHARED_OBJECT targets on the Mac'
|
raise DistutilsPlatformError('Can only make SHARED_LIBRARY or SHARED_OBJECT targets on the Mac')
|
||||||
if runtime_library_dirs:
|
if runtime_library_dirs:
|
||||||
raise DistutilsPlatformError, 'Runtime library dirs not implemented yet'
|
raise DistutilsPlatformError('Runtime library dirs not implemented yet')
|
||||||
if extra_preargs or extra_postargs:
|
if extra_preargs or extra_postargs:
|
||||||
raise DistutilsPlatformError, 'Runtime library dirs not implemented yet'
|
raise DistutilsPlatformError('Runtime library dirs not implemented yet')
|
||||||
if len(export_symbols) != 1:
|
if len(export_symbols) != 1:
|
||||||
raise DistutilsPlatformError, 'Need exactly one export symbol'
|
raise DistutilsPlatformError('Need exactly one export symbol')
|
||||||
# Next there are various things for which we need absolute pathnames.
|
# Next there are various things for which we need absolute pathnames.
|
||||||
# This is because we (usually) create the project in a subdirectory of
|
# This is because we (usually) create the project in a subdirectory of
|
||||||
# where we are now, and keeping the paths relative is too much work right
|
# where we are now, and keeping the paths relative is too much work right
|
||||||
|
@ -6,19 +6,13 @@ Also provides the 'find_executable()' to search the path for a given
|
|||||||
executable name.
|
executable name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This module should be kept compatible with Python 2.1.
|
|
||||||
|
|
||||||
__revision__ = "$Id$"
|
__revision__ = "$Id$"
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
from distutils.errors import *
|
from distutils.errors import *
|
||||||
from distutils import log
|
from distutils import log
|
||||||
|
|
||||||
def spawn (cmd,
|
def spawn(cmd, search_path=1, verbose=0, dry_run=0):
|
||||||
search_path=1,
|
|
||||||
verbose=0,
|
|
||||||
dry_run=0):
|
|
||||||
|
|
||||||
"""Run another program, specified as a command list 'cmd', in a new
|
"""Run another program, specified as a command list 'cmd', in a new
|
||||||
process. 'cmd' is just the argument list for the new process, ie.
|
process. 'cmd' is just the argument list for the new process, ie.
|
||||||
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
|
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
|
||||||
@ -40,10 +34,8 @@ def spawn (cmd,
|
|||||||
elif os.name == 'os2':
|
elif os.name == 'os2':
|
||||||
_spawn_os2(cmd, search_path, dry_run=dry_run)
|
_spawn_os2(cmd, search_path, dry_run=dry_run)
|
||||||
else:
|
else:
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError(
|
||||||
"don't know how to spawn programs on platform '%s'" % os.name
|
"don't know how to spawn programs on platform '%s'" % os.name)
|
||||||
|
|
||||||
# spawn ()
|
|
||||||
|
|
||||||
|
|
||||||
def _nt_quote_args(args):
|
def _nt_quote_args(args):
|
||||||
@ -51,23 +43,17 @@ def _nt_quote_args (args):
|
|||||||
wraps every argument which contains blanks in double quotes, and
|
wraps every argument which contains blanks in double quotes, and
|
||||||
returns a new argument list.
|
returns a new argument list.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# XXX this doesn't seem very robust to me -- but if the Windows guys
|
# XXX this doesn't seem very robust to me -- but if the Windows guys
|
||||||
# say it'll work, I guess I'll have to accept it. (What if an arg
|
# say it'll work, I guess I'll have to accept it. (What if an arg
|
||||||
# contains quotes? What other magic characters, other than spaces,
|
# contains quotes? What other magic characters, other than spaces,
|
||||||
# have to be escaped? Is there an escaping mechanism other than
|
# have to be escaped? Is there an escaping mechanism other than
|
||||||
# quoting?)
|
# quoting?)
|
||||||
|
|
||||||
for i in range(len(args)):
|
for i in range(len(args)):
|
||||||
if args[i].find(' ') != -1:
|
if args[i].find(' ') != -1:
|
||||||
args[i] = '"%s"' % args[i]
|
args[i] = '"%s"' % args[i]
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def _spawn_nt (cmd,
|
def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0):
|
||||||
search_path=1,
|
|
||||||
verbose=0,
|
|
||||||
dry_run=0):
|
|
||||||
|
|
||||||
executable = cmd[0]
|
executable = cmd[0]
|
||||||
cmd = _nt_quote_args(cmd)
|
cmd = _nt_quote_args(cmd)
|
||||||
if search_path:
|
if search_path:
|
||||||
@ -80,19 +66,15 @@ def _spawn_nt (cmd,
|
|||||||
rc = os.spawnv(os.P_WAIT, executable, cmd)
|
rc = os.spawnv(os.P_WAIT, executable, cmd)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
# this seems to happen when the command isn't found
|
# this seems to happen when the command isn't found
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' failed: %s" % (cmd[0], exc[-1])
|
"command '%s' failed: %s" % (cmd[0], exc[-1]))
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
# and this reflects the command running but failing
|
# and this reflects the command running but failing
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' failed with exit status %d" % (cmd[0], rc)
|
"command '%s' failed with exit status %d" % (cmd[0], rc))
|
||||||
|
|
||||||
|
|
||||||
def _spawn_os2 (cmd,
|
def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0):
|
||||||
search_path=1,
|
|
||||||
verbose=0,
|
|
||||||
dry_run=0):
|
|
||||||
|
|
||||||
executable = cmd[0]
|
executable = cmd[0]
|
||||||
#cmd = _nt_quote_args(cmd)
|
#cmd = _nt_quote_args(cmd)
|
||||||
if search_path:
|
if search_path:
|
||||||
@ -105,75 +87,62 @@ def _spawn_os2 (cmd,
|
|||||||
rc = os.spawnv(os.P_WAIT, executable, cmd)
|
rc = os.spawnv(os.P_WAIT, executable, cmd)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
# this seems to happen when the command isn't found
|
# this seems to happen when the command isn't found
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' failed: %s" % (cmd[0], exc[-1])
|
"command '%s' failed: %s" % (cmd[0], exc[-1]))
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
# and this reflects the command running but failing
|
# and this reflects the command running but failing
|
||||||
print("command '%s' failed with exit status %d" % (cmd[0], rc))
|
print("command '%s' failed with exit status %d" % (cmd[0], rc))
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' failed with exit status %d" % (cmd[0], rc)
|
"command '%s' failed with exit status %d" % (cmd[0], rc))
|
||||||
|
|
||||||
|
|
||||||
def _spawn_posix (cmd,
|
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
|
||||||
search_path=1,
|
|
||||||
verbose=0,
|
|
||||||
dry_run=0):
|
|
||||||
|
|
||||||
log.info(' '.join(cmd))
|
log.info(' '.join(cmd))
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
exec_fn = search_path and os.execvp or os.execv
|
exec_fn = search_path and os.execvp or os.execv
|
||||||
|
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
|
|
||||||
if pid == 0: # in the child
|
if pid == 0: # in the child
|
||||||
try:
|
try:
|
||||||
#print "cmd[0] =", cmd[0]
|
|
||||||
#print "cmd =", cmd
|
|
||||||
exec_fn(cmd[0], cmd)
|
exec_fn(cmd[0], cmd)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
sys.stderr.write("unable to execute %s: %s\n" %
|
sys.stderr.write("unable to execute %s: %s\n"
|
||||||
(cmd[0], e.strerror))
|
% (cmd[0], e.strerror))
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0])
|
sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0])
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
|
||||||
|
|
||||||
else: # in the parent
|
else: # in the parent
|
||||||
# Loop until the child either exits or is terminated by a signal
|
# Loop until the child either exits or is terminated by a signal
|
||||||
# (ie. keep waiting if it's merely stopped)
|
# (ie. keep waiting if it's merely stopped)
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
(pid, status) = os.waitpid(pid, 0)
|
(pid, status) = os.waitpid(pid, 0)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
import errno
|
import errno
|
||||||
if exc.errno == errno.EINTR:
|
if exc.errno == errno.EINTR:
|
||||||
continue
|
continue
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' failed: %s" % (cmd[0], exc[-1])
|
"command '%s' failed: %s" % (cmd[0], exc[-1]))
|
||||||
if os.WIFSIGNALED(status):
|
if os.WIFSIGNALED(status):
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' terminated by signal %d" % \
|
"command '%s' terminated by signal %d"
|
||||||
(cmd[0], os.WTERMSIG(status))
|
% (cmd[0], os.WTERMSIG(status)))
|
||||||
|
|
||||||
elif os.WIFEXITED(status):
|
elif os.WIFEXITED(status):
|
||||||
exit_status = os.WEXITSTATUS(status)
|
exit_status = os.WEXITSTATUS(status)
|
||||||
if exit_status == 0:
|
if exit_status == 0:
|
||||||
return # hey, it succeeded!
|
return # hey, it succeeded!
|
||||||
else:
|
else:
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"command '%s' failed with exit status %d" % \
|
"command '%s' failed with exit status %d"
|
||||||
(cmd[0], exit_status)
|
% (cmd[0], exit_status))
|
||||||
|
|
||||||
elif os.WIFSTOPPED(status):
|
elif os.WIFSTOPPED(status):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise DistutilsExecError, \
|
raise DistutilsExecError(
|
||||||
"unknown error executing '%s': termination status %d" % \
|
"unknown error executing '%s': termination status %d"
|
||||||
(cmd[0], status)
|
% (cmd[0], status))
|
||||||
# _spawn_posix ()
|
|
||||||
|
|
||||||
|
|
||||||
def find_executable(executable, path=None):
|
def find_executable(executable, path=None):
|
||||||
@ -197,5 +166,3 @@ def find_executable(executable, path=None):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return executable
|
return executable
|
||||||
|
|
||||||
# find_executable()
|
|
||||||
|
@ -27,11 +27,7 @@ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
|
|||||||
# different (hard-wired) directories.
|
# different (hard-wired) directories.
|
||||||
|
|
||||||
argv0_path = os.path.dirname(os.path.abspath(sys.executable))
|
argv0_path = os.path.dirname(os.path.abspath(sys.executable))
|
||||||
landmark = os.path.join(argv0_path, "Modules", "Setup")
|
python_build = os.path.isfile(os.path.join(argv0_path, "Modules", "Setup"))
|
||||||
|
|
||||||
python_build = os.path.isfile(landmark)
|
|
||||||
|
|
||||||
del landmark
|
|
||||||
|
|
||||||
|
|
||||||
def get_python_version():
|
def get_python_version():
|
||||||
@ -105,7 +101,6 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
|||||||
return libpython
|
return libpython
|
||||||
else:
|
else:
|
||||||
return os.path.join(libpython, "site-packages")
|
return os.path.join(libpython, "site-packages")
|
||||||
|
|
||||||
elif os.name == "nt":
|
elif os.name == "nt":
|
||||||
if standard_lib:
|
if standard_lib:
|
||||||
return os.path.join(prefix, "Lib")
|
return os.path.join(prefix, "Lib")
|
||||||
@ -114,7 +109,6 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
|||||||
return prefix
|
return prefix
|
||||||
else:
|
else:
|
||||||
return os.path.join(PREFIX, "Lib", "site-packages")
|
return os.path.join(PREFIX, "Lib", "site-packages")
|
||||||
|
|
||||||
elif os.name == "mac":
|
elif os.name == "mac":
|
||||||
if plat_specific:
|
if plat_specific:
|
||||||
if standard_lib:
|
if standard_lib:
|
||||||
@ -126,13 +120,11 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
|
|||||||
return os.path.join(prefix, "Lib")
|
return os.path.join(prefix, "Lib")
|
||||||
else:
|
else:
|
||||||
return os.path.join(prefix, "Lib", "site-packages")
|
return os.path.join(prefix, "Lib", "site-packages")
|
||||||
|
|
||||||
elif os.name == "os2":
|
elif os.name == "os2":
|
||||||
if standard_lib:
|
if standard_lib:
|
||||||
return os.path.join(PREFIX, "Lib")
|
return os.path.join(PREFIX, "Lib")
|
||||||
else:
|
else:
|
||||||
return os.path.join(PREFIX, "Lib", "site-packages")
|
return os.path.join(PREFIX, "Lib", "site-packages")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise DistutilsPlatformError(
|
raise DistutilsPlatformError(
|
||||||
"I don't know where Python installs its library "
|
"I don't know where Python installs its library "
|
||||||
@ -216,7 +208,7 @@ def parse_config_h(fp, g=None):
|
|||||||
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
|
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
|
||||||
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
|
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
|
||||||
#
|
#
|
||||||
while 1:
|
while True:
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
@ -254,7 +246,7 @@ def parse_makefile(fn, g=None):
|
|||||||
done = {}
|
done = {}
|
||||||
notdone = {}
|
notdone = {}
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
line = fp.readline()
|
line = fp.readline()
|
||||||
if line is None: # eof
|
if line is None: # eof
|
||||||
break
|
break
|
||||||
@ -325,7 +317,7 @@ def expand_makefile_vars(s, vars):
|
|||||||
# 'parse_makefile()', which takes care of such expansions eagerly,
|
# 'parse_makefile()', which takes care of such expansions eagerly,
|
||||||
# according to make's variable expansion semantics.
|
# according to make's variable expansion semantics.
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
m = _findvar1_rx.search(s) or _findvar2_rx.search(s)
|
m = _findvar1_rx.search(s) or _findvar2_rx.search(s)
|
||||||
if m:
|
if m:
|
||||||
(beg, end) = m.span()
|
(beg, end) = m.span()
|
||||||
|
@ -10,7 +10,6 @@ import sys, os, io
|
|||||||
|
|
||||||
|
|
||||||
class TextFile:
|
class TextFile:
|
||||||
|
|
||||||
"""Provides a file-like object that takes care of all the things you
|
"""Provides a file-like object that takes care of all the things you
|
||||||
commonly want to do when processing a text file that has some
|
commonly want to do when processing a text file that has some
|
||||||
line-by-line syntax: strip comments (as long as "#" is your
|
line-by-line syntax: strip comments (as long as "#" is your
|
||||||
@ -80,24 +79,21 @@ class TextFile:
|
|||||||
(a string) and 'file' (a file-like object) must be supplied.
|
(a string) and 'file' (a file-like object) must be supplied.
|
||||||
They keyword argument options are described above and affect
|
They keyword argument options are described above and affect
|
||||||
the values returned by 'readline()'."""
|
the values returned by 'readline()'."""
|
||||||
|
|
||||||
if filename is None and file is None:
|
if filename is None and file is None:
|
||||||
raise RuntimeError, \
|
raise RuntimeError("you must supply either or both of 'filename' and 'file'")
|
||||||
"you must supply either or both of 'filename' and 'file'"
|
|
||||||
|
|
||||||
# set values for all options -- either from client option hash
|
# set values for all options -- either from client option hash
|
||||||
# or fallback to default_options
|
# or fallback to default_options
|
||||||
for opt in self.default_options.keys():
|
for opt in self.default_options.keys():
|
||||||
if opt in options:
|
if opt in options:
|
||||||
setattr(self, opt, options[opt])
|
setattr(self, opt, options[opt])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
setattr(self, opt, self.default_options[opt])
|
setattr(self, opt, self.default_options[opt])
|
||||||
|
|
||||||
# sanity check client option hash
|
# sanity check client option hash
|
||||||
for opt in options.keys():
|
for opt in options.keys():
|
||||||
if opt not in self.default_options:
|
if opt not in self.default_options:
|
||||||
raise KeyError, "invalid TextFile option '%s'" % opt
|
raise KeyError("invalid TextFile option '%s'" % opt)
|
||||||
|
|
||||||
if file is None:
|
if file is None:
|
||||||
self.open(filename)
|
self.open(filename)
|
||||||
@ -111,26 +107,21 @@ class TextFile:
|
|||||||
# 'unreadline()' operation
|
# 'unreadline()' operation
|
||||||
self.linebuf = []
|
self.linebuf = []
|
||||||
|
|
||||||
|
|
||||||
def open(self, filename):
|
def open(self, filename):
|
||||||
"""Open a new file named 'filename'. This overrides both the
|
"""Open a new file named 'filename'. This overrides both the
|
||||||
'filename' and 'file' arguments to the constructor."""
|
'filename' and 'file' arguments to the constructor."""
|
||||||
|
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.file = io.open(self.filename, 'r')
|
self.file = io.open(self.filename, 'r')
|
||||||
self.current_line = 0
|
self.current_line = 0
|
||||||
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the current file and forget everything we know about it
|
"""Close the current file and forget everything we know about it
|
||||||
(filename, current line number)."""
|
(filename, current line number)."""
|
||||||
|
|
||||||
self.file.close()
|
self.file.close()
|
||||||
self.file = None
|
self.file = None
|
||||||
self.filename = None
|
self.filename = None
|
||||||
self.current_line = None
|
self.current_line = None
|
||||||
|
|
||||||
|
|
||||||
def gen_error(self, msg, line=None):
|
def gen_error(self, msg, line=None):
|
||||||
outmsg = []
|
outmsg = []
|
||||||
if line is None:
|
if line is None:
|
||||||
@ -143,9 +134,8 @@ class TextFile:
|
|||||||
outmsg.append(str(msg))
|
outmsg.append(str(msg))
|
||||||
return "".join(outmsg)
|
return "".join(outmsg)
|
||||||
|
|
||||||
|
|
||||||
def error(self, msg, line=None):
|
def error(self, msg, line=None):
|
||||||
raise ValueError, "error: " + self.gen_error(msg, line)
|
raise ValueError("error: " + self.gen_error(msg, line))
|
||||||
|
|
||||||
def warn(self, msg, line=None):
|
def warn(self, msg, line=None):
|
||||||
"""Print (to stderr) a warning message tied to the current logical
|
"""Print (to stderr) a warning message tied to the current logical
|
||||||
@ -157,7 +147,6 @@ class TextFile:
|
|||||||
line."""
|
line."""
|
||||||
sys.stderr.write("warning: " + self.gen_error(msg, line) + "\n")
|
sys.stderr.write("warning: " + self.gen_error(msg, line) + "\n")
|
||||||
|
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
"""Read and return a single logical line from the current file (or
|
"""Read and return a single logical line from the current file (or
|
||||||
from an internal buffer if lines have previously been "unread"
|
from an internal buffer if lines have previously been "unread"
|
||||||
@ -168,7 +157,6 @@ class TextFile:
|
|||||||
line(s) just read. Returns None on end-of-file, since the empty
|
line(s) just read. Returns None on end-of-file, since the empty
|
||||||
string can occur if 'rstrip_ws' is true but 'strip_blanks' is
|
string can occur if 'rstrip_ws' is true but 'strip_blanks' is
|
||||||
not."""
|
not."""
|
||||||
|
|
||||||
# If any "unread" lines waiting in 'linebuf', return the top
|
# If any "unread" lines waiting in 'linebuf', return the top
|
||||||
# one. (We don't actually buffer read-ahead data -- lines only
|
# one. (We don't actually buffer read-ahead data -- lines only
|
||||||
# get put in 'linebuf' if the client explicitly does an
|
# get put in 'linebuf' if the client explicitly does an
|
||||||
@ -180,10 +168,11 @@ class TextFile:
|
|||||||
|
|
||||||
buildup_line = ''
|
buildup_line = ''
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
# read the line, make it None if EOF
|
# read the line, make it None if EOF
|
||||||
line = self.file.readline()
|
line = self.file.readline()
|
||||||
if line == '': line = None
|
if line == '':
|
||||||
|
line = None
|
||||||
|
|
||||||
if self.strip_comments and line:
|
if self.strip_comments and line:
|
||||||
|
|
||||||
@ -220,11 +209,9 @@ class TextFile:
|
|||||||
# result in "hello there".
|
# result in "hello there".
|
||||||
if line.strip() == "":
|
if line.strip() == "":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else: # it's an escaped "#"
|
else: # it's an escaped "#"
|
||||||
line = line.replace("\\#", "#")
|
line = line.replace("\\#", "#")
|
||||||
|
|
||||||
|
|
||||||
# did previous line end with a backslash? then accumulate
|
# did previous line end with a backslash? then accumulate
|
||||||
if self.join_lines and buildup_line:
|
if self.join_lines and buildup_line:
|
||||||
# oops: end of file
|
# oops: end of file
|
||||||
@ -254,7 +241,6 @@ class TextFile:
|
|||||||
else:
|
else:
|
||||||
self.current_line = self.current_line + 1
|
self.current_line = self.current_line + 1
|
||||||
|
|
||||||
|
|
||||||
# strip whitespace however the client wants (leading and
|
# strip whitespace however the client wants (leading and
|
||||||
# trailing, or one or the other, or neither)
|
# trailing, or one or the other, or neither)
|
||||||
if self.lstrip_ws and self.rstrip_ws:
|
if self.lstrip_ws and self.rstrip_ws:
|
||||||
@ -281,26 +267,20 @@ class TextFile:
|
|||||||
# well, I guess there's some actual content there: return it
|
# well, I guess there's some actual content there: return it
|
||||||
return line
|
return line
|
||||||
|
|
||||||
# readline ()
|
|
||||||
|
|
||||||
|
|
||||||
def readlines(self):
|
def readlines(self):
|
||||||
"""Read and return the list of all logical lines remaining in the
|
"""Read and return the list of all logical lines remaining in the
|
||||||
current file."""
|
current file."""
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
while 1:
|
while True:
|
||||||
line = self.readline()
|
line = self.readline()
|
||||||
if line is None:
|
if line is None:
|
||||||
return lines
|
return lines
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
|
|
||||||
|
|
||||||
def unreadline(self, line):
|
def unreadline(self, line):
|
||||||
"""Push 'line' (a string) onto an internal buffer that will be
|
"""Push 'line' (a string) onto an internal buffer that will be
|
||||||
checked by future 'readline()' calls. Handy for implementing
|
checked by future 'readline()' calls. Handy for implementing
|
||||||
a parser with line-at-a-time lookahead."""
|
a parser with line-at-a-time lookahead."""
|
||||||
|
|
||||||
self.linebuf.append(line)
|
self.linebuf.append(line)
|
||||||
|
|
||||||
|
|
||||||
@ -339,7 +319,6 @@ line 3 \\
|
|||||||
|
|
||||||
def test_input(count, description, file, expected_result):
|
def test_input(count, description, file, expected_result):
|
||||||
result = file.readlines()
|
result = file.readlines()
|
||||||
# result = ''.join (result)
|
|
||||||
if result == expected_result:
|
if result == expected_result:
|
||||||
print("ok %d (%s)" % (count, description))
|
print("ok %d (%s)" % (count, description))
|
||||||
else:
|
else:
|
||||||
|
@ -50,7 +50,7 @@ def _darwin_compiler_fixup(compiler_so, cc_args):
|
|||||||
build, without a way to remove an architecture. Furthermore GCC will
|
build, without a way to remove an architecture. Furthermore GCC will
|
||||||
barf if multiple '-isysroot' arguments are present.
|
barf if multiple '-isysroot' arguments are present.
|
||||||
"""
|
"""
|
||||||
stripArch = stripSysroot = 0
|
stripArch = stripSysroot = False
|
||||||
|
|
||||||
compiler_so = list(compiler_so)
|
compiler_so = list(compiler_so)
|
||||||
kernel_version = os.uname()[2] # 8.4.3
|
kernel_version = os.uname()[2] # 8.4.3
|
||||||
@ -65,7 +65,7 @@ def _darwin_compiler_fixup(compiler_so, cc_args):
|
|||||||
stripSysroot = '-isysroot' in cc_args
|
stripSysroot = '-isysroot' in cc_args
|
||||||
|
|
||||||
if stripArch:
|
if stripArch:
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
index = compiler_so.index('-arch')
|
index = compiler_so.index('-arch')
|
||||||
# Strip this argument and the next one:
|
# Strip this argument and the next one:
|
||||||
@ -137,11 +137,10 @@ class UnixCCompiler(CCompiler):
|
|||||||
if sys.platform == "cygwin":
|
if sys.platform == "cygwin":
|
||||||
exe_extension = ".exe"
|
exe_extension = ".exe"
|
||||||
|
|
||||||
def preprocess(self, source,
|
def preprocess(self, source, output_file=None, macros=None,
|
||||||
output_file=None, macros=None, include_dirs=None,
|
include_dirs=None, extra_preargs=None, extra_postargs=None):
|
||||||
extra_preargs=None, extra_postargs=None):
|
fixed_args = self._fix_compile_args(None, macros, include_dirs)
|
||||||
ignore, macros, include_dirs = \
|
ignore, macros, include_dirs = fixed_args
|
||||||
self._fix_compile_args(None, macros, include_dirs)
|
|
||||||
pp_opts = gen_preprocess_options(macros, include_dirs)
|
pp_opts = gen_preprocess_options(macros, include_dirs)
|
||||||
pp_args = self.preprocessor + pp_opts
|
pp_args = self.preprocessor + pp_opts
|
||||||
if output_file:
|
if output_file:
|
||||||
@ -162,7 +161,7 @@ class UnixCCompiler(CCompiler):
|
|||||||
try:
|
try:
|
||||||
self.spawn(pp_args)
|
self.spawn(pp_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||||
compiler_so = self.compiler_so
|
compiler_so = self.compiler_so
|
||||||
@ -172,7 +171,7 @@ class UnixCCompiler(CCompiler):
|
|||||||
self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||||
extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise CompileError, msg
|
raise CompileError(msg)
|
||||||
|
|
||||||
def create_static_lib(self, objects, output_libname,
|
def create_static_lib(self, objects, output_libname,
|
||||||
output_dir=None, debug=0, target_lang=None):
|
output_dir=None, debug=0, target_lang=None):
|
||||||
@ -196,7 +195,7 @@ class UnixCCompiler(CCompiler):
|
|||||||
try:
|
try:
|
||||||
self.spawn(self.ranlib + [output_filename])
|
self.spawn(self.ranlib + [output_filename])
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise LibError, msg
|
raise LibError(msg)
|
||||||
else:
|
else:
|
||||||
log.debug("skipping %s (up-to-date)", output_filename)
|
log.debug("skipping %s (up-to-date)", output_filename)
|
||||||
|
|
||||||
@ -206,13 +205,14 @@ class UnixCCompiler(CCompiler):
|
|||||||
export_symbols=None, debug=0, extra_preargs=None,
|
export_symbols=None, debug=0, extra_preargs=None,
|
||||||
extra_postargs=None, build_temp=None, target_lang=None):
|
extra_postargs=None, build_temp=None, target_lang=None):
|
||||||
objects, output_dir = self._fix_object_args(objects, output_dir)
|
objects, output_dir = self._fix_object_args(objects, output_dir)
|
||||||
libraries, library_dirs, runtime_library_dirs = \
|
fixed_args = self._fix_lib_args(libraries, library_dirs,
|
||||||
self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
|
runtime_library_dirs)
|
||||||
|
libraries, library_dirs, runtime_library_dirs = fixed_args
|
||||||
|
|
||||||
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
|
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
|
||||||
libraries)
|
libraries)
|
||||||
if not isinstance(output_dir, (basestring, type(None))):
|
if not isinstance(output_dir, (basestring, type(None))):
|
||||||
raise TypeError, "'output_dir' must be a string or None"
|
raise TypeError("'output_dir' must be a string or None")
|
||||||
if output_dir is not None:
|
if output_dir is not None:
|
||||||
output_filename = os.path.join(output_dir, output_filename)
|
output_filename = os.path.join(output_dir, output_filename)
|
||||||
|
|
||||||
@ -241,8 +241,7 @@ class UnixCCompiler(CCompiler):
|
|||||||
if os.path.basename(linker[0]) == "env":
|
if os.path.basename(linker[0]) == "env":
|
||||||
i = 1
|
i = 1
|
||||||
while '=' in linker[i]:
|
while '=' in linker[i]:
|
||||||
i = i + 1
|
i += 1
|
||||||
|
|
||||||
linker[i] = self.compiler_cxx[i]
|
linker[i] = self.compiler_cxx[i]
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
@ -250,7 +249,7 @@ class UnixCCompiler(CCompiler):
|
|||||||
|
|
||||||
self.spawn(linker + ld_args)
|
self.spawn(linker + ld_args)
|
||||||
except DistutilsExecError as msg:
|
except DistutilsExecError as msg:
|
||||||
raise LinkError, msg
|
raise LinkError(msg)
|
||||||
else:
|
else:
|
||||||
log.debug("skipping %s (up-to-date)", output_filename)
|
log.debug("skipping %s (up-to-date)", output_filename)
|
||||||
|
|
||||||
|
@ -153,9 +153,9 @@ def convert_path (pathname):
|
|||||||
if not pathname:
|
if not pathname:
|
||||||
return pathname
|
return pathname
|
||||||
if pathname[0] == '/':
|
if pathname[0] == '/':
|
||||||
raise ValueError, "path '%s' cannot be absolute" % pathname
|
raise ValueError("path '%s' cannot be absolute" % pathname)
|
||||||
if pathname[-1] == '/':
|
if pathname[-1] == '/':
|
||||||
raise ValueError, "path '%s' cannot end with '/'" % pathname
|
raise ValueError("path '%s' cannot end with '/'" % pathname)
|
||||||
|
|
||||||
paths = pathname.split('/')
|
paths = pathname.split('/')
|
||||||
while '.' in paths:
|
while '.' in paths:
|
||||||
@ -201,8 +201,7 @@ def change_root (new_root, pathname):
|
|||||||
return os.path.join(new_root, pathname)
|
return os.path.join(new_root, pathname)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise DistutilsPlatformError, \
|
raise DistutilsPlatformError("nothing known about platform '%s'" % os.name)
|
||||||
"nothing known about platform '%s'" % os.name
|
|
||||||
|
|
||||||
|
|
||||||
_environ_checked = 0
|
_environ_checked = 0
|
||||||
@ -248,7 +247,7 @@ def subst_vars (s, local_vars):
|
|||||||
try:
|
try:
|
||||||
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
|
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
|
||||||
except KeyError as var:
|
except KeyError as var:
|
||||||
raise ValueError, "invalid variable '$%s'" % var
|
raise ValueError("invalid variable '$%s'" % var)
|
||||||
|
|
||||||
# subst_vars ()
|
# subst_vars ()
|
||||||
|
|
||||||
@ -326,12 +325,10 @@ def split_quoted (s):
|
|||||||
elif s[end] == '"': # slurp doubly-quoted string
|
elif s[end] == '"': # slurp doubly-quoted string
|
||||||
m = _dquote_re.match(s, end)
|
m = _dquote_re.match(s, end)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError, \
|
raise RuntimeError("this can't happen (bad char '%c')" % s[end])
|
||||||
"this can't happen (bad char '%c')" % s[end]
|
|
||||||
|
|
||||||
if m is None:
|
if m is None:
|
||||||
raise ValueError, \
|
raise ValueError("bad string (mismatched %s quotes?)" % s[end])
|
||||||
"bad string (mismatched %s quotes?)" % s[end]
|
|
||||||
|
|
||||||
(beg, end) = m.span()
|
(beg, end) = m.span()
|
||||||
s = s[:beg] + s[beg+1:end-1] + s[end:]
|
s = s[:beg] + s[beg+1:end-1] + s[end:]
|
||||||
@ -378,7 +375,7 @@ def strtobool (val):
|
|||||||
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
raise ValueError, "invalid truth value %r" % (val,)
|
raise ValueError("invalid truth value %r" % (val,))
|
||||||
|
|
||||||
|
|
||||||
def byte_compile (py_files,
|
def byte_compile (py_files,
|
||||||
@ -502,8 +499,7 @@ byte_compile(files, optimize=%r, force=%r,
|
|||||||
dfile = file
|
dfile = file
|
||||||
if prefix:
|
if prefix:
|
||||||
if file[:len(prefix)] != prefix:
|
if file[:len(prefix)] != prefix:
|
||||||
raise ValueError, \
|
raise ValueError("invalid prefix: filename %r doesn't start with %r"
|
||||||
("invalid prefix: filename %r doesn't start with %r"
|
|
||||||
% (file, prefix))
|
% (file, prefix))
|
||||||
dfile = dfile[len(prefix):]
|
dfile = dfile[len(prefix):]
|
||||||
if base_dir:
|
if base_dir:
|
||||||
|
@ -140,7 +140,7 @@ class StrictVersion (Version):
|
|||||||
def parse (self, vstring):
|
def parse (self, vstring):
|
||||||
match = self.version_re.match(vstring)
|
match = self.version_re.match(vstring)
|
||||||
if not match:
|
if not match:
|
||||||
raise ValueError, "invalid version number '%s'" % vstring
|
raise ValueError("invalid version number '%s'" % vstring)
|
||||||
|
|
||||||
(major, minor, patch, prerelease, prerelease_num) = \
|
(major, minor, patch, prerelease, prerelease_num) = \
|
||||||
match.group(1, 2, 4, 5, 6)
|
match.group(1, 2, 4, 5, 6)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user