diff options
Diffstat (limited to 'src/distutils2/compiler')
| -rw-r--r-- | src/distutils2/compiler/bcppcompiler.py | 2 | ||||
| -rw-r--r-- | src/distutils2/compiler/ccompiler.py | 25 | ||||
| -rw-r--r-- | src/distutils2/compiler/emxccompiler.py | 9 | ||||
| -rw-r--r-- | src/distutils2/compiler/msvc9compiler.py | 6 | ||||
| -rw-r--r-- | src/distutils2/compiler/msvccompiler.py | 4 | ||||
| -rw-r--r-- | src/distutils2/compiler/unixccompiler.py | 8 |
6 files changed, 29 insertions, 25 deletions
diff --git a/src/distutils2/compiler/bcppcompiler.py b/src/distutils2/compiler/bcppcompiler.py index 71a116b..7587048 100644 --- a/src/distutils2/compiler/bcppcompiler.py +++ b/src/distutils2/compiler/bcppcompiler.py @@ -16,7 +16,7 @@ __revision__ = "$Id: bcppcompiler.py 76956 2009-12-21 01:22:46Z tarek.ziade $" import os from distutils2.errors import (DistutilsExecError, CompileError, LibError, - LinkError, UnknownFileError) + LinkError, UnknownFileError) from distutils2.compiler.ccompiler import CCompiler, gen_preprocess_options from distutils2.file_util import write_file from distutils2.dep_util import newer diff --git a/src/distutils2/compiler/ccompiler.py b/src/distutils2/compiler/ccompiler.py index 025febd..c9bb129 100644 --- a/src/distutils2/compiler/ccompiler.py +++ b/src/distutils2/compiler/ccompiler.py @@ -10,9 +10,8 @@ import os import re from distutils2.errors import (CompileError, LinkError, UnknownFileError, - DistutilsPlatformError, DistutilsModuleError) -from distutils2.spawn import spawn -from distutils2.util import split_quoted, execute, newer_group + DistutilsPlatformError, DistutilsModuleError) +from distutils2.util import split_quoted, execute, newer_group, spawn from distutils2 import log from shutil import move @@ -76,7 +75,7 @@ def customize_compiler(compiler): compiler.shared_lib_extension = so_ext -class CCompiler: +class CCompiler(object): """Abstract base class to define the interface that must be implemented by real compiler classes. Also has some utility methods used by several compiler classes. @@ -800,14 +799,16 @@ class CCompiler: library_dirs = [] fd, fname = tempfile.mkstemp(".c", funcname, text=True) f = os.fdopen(fd, "w") - for incl in includes: - f.write("""#include "%s"\n""" % incl) - f.write("""\ + try: + for incl in includes: + f.write("""#include "%s"\n""" % incl) + f.write("""\ main (int argc, char **argv) { %s(); } """ % funcname) - f.close() + finally: + f.close() try: objects = self.compile([fname], include_dirs=include_dirs) except CompileError: @@ -938,8 +939,10 @@ main (int argc, char **argv) { if os.path.isdir(name) or name == '': return if self.dry_run: + head = '' for part in name.split(os.sep): - self.log(part) + log.info("created directory %s%s", head, part) + head += part + os.sep return os.makedirs(name, mode) @@ -1048,7 +1051,7 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0): module_name = "distutils2.compiler." + module_name __import__ (module_name) module = sys.modules[module_name] - klass = vars(module)[class_name] + cls = vars(module)[class_name] except ImportError: raise DistutilsModuleError, \ "can't compile C/C++ code: unable to load module '%s'" % \ @@ -1061,7 +1064,7 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0): # XXX The None is necessary to preserve backwards compatibility # with classes that expect verbose to be the first positional # argument. - return klass(None, dry_run, force) + return cls(None, dry_run, force) def gen_preprocess_options(macros, include_dirs): diff --git a/src/distutils2/compiler/emxccompiler.py b/src/distutils2/compiler/emxccompiler.py index cb6fb16..6247c00 100644 --- a/src/distutils2/compiler/emxccompiler.py +++ b/src/distutils2/compiler/emxccompiler.py @@ -25,9 +25,8 @@ import os, sys, copy from warnings import warn from distutils2.compiler.unixccompiler import UnixCCompiler -from distutils2.util import write_file from distutils2.errors import DistutilsExecError, CompileError, UnknownFileError -from distutils2.util import get_compiler_versions +from distutils2.util import get_compiler_versions, write_file class EMXCCompiler (UnixCCompiler): @@ -273,8 +272,10 @@ def check_config_h(): # It would probably better to read single lines to search. # But we do this only once, and it is fast enough f = open(fn) - s = f.read() - f.close() + try: + s = f.read() + finally: + f.close() except IOError, exc: # if we can't read this file, we cannot say it is wrong diff --git a/src/distutils2/compiler/msvc9compiler.py b/src/distutils2/compiler/msvc9compiler.py index 9f98d60..46cffa5 100644 --- a/src/distutils2/compiler/msvc9compiler.py +++ b/src/distutils2/compiler/msvc9compiler.py @@ -20,7 +20,7 @@ import sys import re from distutils2.errors import (DistutilsExecError, DistutilsPlatformError, - CompileError, LibError, LinkError) + CompileError, LibError, LinkError) from distutils2.compiler.ccompiler import CCompiler, gen_lib_options from distutils2 import log from distutils2.util import get_platform @@ -50,7 +50,7 @@ PLAT_TO_VCVARS = { 'win-ia64' : 'ia64', } -class Reg: +class Reg(object): """Helper class to read values from the registry """ @@ -112,7 +112,7 @@ class Reg: return s convert_mbcs = staticmethod(convert_mbcs) -class MacroExpander: +class MacroExpander(object): def __init__(self, version): self.macros = {} diff --git a/src/distutils2/compiler/msvccompiler.py b/src/distutils2/compiler/msvccompiler.py index 46f8517..d2b049f 100644 --- a/src/distutils2/compiler/msvccompiler.py +++ b/src/distutils2/compiler/msvccompiler.py @@ -15,7 +15,7 @@ import os import string from distutils2.errors import (DistutilsExecError, DistutilsPlatformError, - CompileError, LibError, LinkError) + CompileError, LibError, LinkError) from distutils2.compiler.ccompiler import CCompiler, gen_lib_options from distutils2 import log @@ -104,7 +104,7 @@ def convert_mbcs(s): pass return s -class MacroExpander: +class MacroExpander(object): def __init__(self, version): self.macros = {} diff --git a/src/distutils2/compiler/unixccompiler.py b/src/distutils2/compiler/unixccompiler.py index 18276f7..7e52959 100644 --- a/src/distutils2/compiler/unixccompiler.py +++ b/src/distutils2/compiler/unixccompiler.py @@ -19,10 +19,10 @@ import os, sys from types import StringType, NoneType from distutils2.util import newer -from distutils2.compiler.ccompiler import \ - CCompiler, gen_preprocess_options, gen_lib_options -from distutils2.errors import \ - DistutilsExecError, CompileError, LibError, LinkError +from distutils2.compiler.ccompiler import (CCompiler, gen_preprocess_options, + gen_lib_options) +from distutils2.errors import (DistutilsExecError, CompileError, + LibError, LinkError) from distutils2 import log try: |
