summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarek Ziadé <ziade.tarek@gmail.com>2009-04-12 15:03:50 (GMT)
committerTarek Ziadé <ziade.tarek@gmail.com>2009-04-12 15:03:50 (GMT)
commit7bea344d35dc43642184c00e6cae6d1c396e721b (patch)
treeca3dece1f529f687c11ca283752211f289819486
parentaa48798f1e99f9ca6ce0e859288b5a7d0419d539 (diff)
downloadcpython-7bea344d35dc43642184c00e6cae6d1c396e721b.zip
cpython-7bea344d35dc43642184c00e6cae6d1c396e721b.tar.gz
cpython-7bea344d35dc43642184c00e6cae6d1c396e721b.tar.bz2
pep8-fied the module before adding tests
-rw-r--r--Lib/distutils/command/config.py62
1 files changed, 25 insertions, 37 deletions
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
index c36456a..74eed78 100644
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -18,10 +18,9 @@ from distutils.errors import DistutilsExecError
from distutils.sysconfig import customize_compiler
from distutils import log
-LANG_EXT = {'c': '.c',
- 'c++': '.cxx'}
+LANG_EXT = {'c': '.c', 'c++': '.cxx'}
-class config (Command):
+class config(Command):
description = "prepare to build"
@@ -51,12 +50,10 @@ class config (Command):
# The three standard command methods: since the "config" command
# does nothing by default, these are empty.
- def initialize_options (self):
+ def initialize_options(self):
self.compiler = None
self.cc = None
self.include_dirs = None
- #self.define = None
- #self.undef = None
self.libraries = None
self.library_dirs = None
@@ -68,7 +65,7 @@ class config (Command):
# to clean at some point
self.temp_files = []
- def finalize_options (self):
+ def finalize_options(self):
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or []
elif type(self.include_dirs) is StringType:
@@ -93,7 +90,7 @@ class config (Command):
# loosely based on Autoconf macros of similar names. Sub-classes
# may use these freely.
- def _check_compiler (self):
+ def _check_compiler(self):
"""Check that 'self.compiler' really is a CCompiler object;
if not, make it one.
"""
@@ -112,7 +109,7 @@ class config (Command):
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]
file = open(filename, "w")
if headers:
@@ -125,14 +122,14 @@ class config (Command):
file.close()
return filename
- def _preprocess (self, body, headers, include_dirs, lang):
+ def _preprocess(self, body, headers, include_dirs, lang):
src = self._gen_temp_sourcefile(body, headers, lang)
out = "_configtest.i"
self.temp_files.extend([src, out])
self.compiler.preprocess(src, out, include_dirs=include_dirs)
return (src, out)
- def _compile (self, body, headers, include_dirs, lang):
+ def _compile(self, body, headers, include_dirs, lang):
src = self._gen_temp_sourcefile(body, headers, lang)
if self.dump_source:
dump_file(src, "compiling '%s':" % src)
@@ -141,9 +138,8 @@ class config (Command):
self.compiler.compile([src], include_dirs=include_dirs)
return (src, obj)
- def _link (self, body,
- headers, include_dirs,
- libraries, library_dirs, lang):
+ def _link(self, body, headers, include_dirs, libraries, library_dirs,
+ lang):
(src, obj) = self._compile(body, headers, include_dirs, lang)
prog = os.path.splitext(os.path.basename(src))[0]
self.compiler.link_executable([obj], prog,
@@ -157,7 +153,7 @@ class config (Command):
return (src, obj, prog)
- def _clean (self, *filenames):
+ def _clean(self, *filenames):
if not filenames:
filenames = self.temp_files
self.temp_files = []
@@ -179,7 +175,7 @@ class config (Command):
# XXX need access to the header search path and maybe default macros.
- def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"):
+ def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"):
"""Construct a source file from 'body' (a string containing lines
of C/C++ code) and 'headers' (a list of header files to include)
and run it through the preprocessor. Return true if the
@@ -197,8 +193,8 @@ class config (Command):
self._clean()
return ok
- def search_cpp (self, pattern, body=None,
- headers=None, include_dirs=None, lang="c"):
+ def search_cpp(self, pattern, body=None, headers=None, include_dirs=None,
+ lang="c"):
"""Construct a source file (just like 'try_cpp()'), run it through
the preprocessor, and return true if any line of the output matches
'pattern'. 'pattern' should either be a compiled regex object or a
@@ -227,7 +223,7 @@ class config (Command):
self._clean()
return match
- def try_compile (self, body, headers=None, include_dirs=None, lang="c"):
+ def try_compile(self, body, headers=None, include_dirs=None, lang="c"):
"""Try to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
"""
@@ -243,10 +239,8 @@ class config (Command):
self._clean()
return ok
- def try_link (self, body,
- headers=None, include_dirs=None,
- libraries=None, library_dirs=None,
- lang="c"):
+ def try_link(self, body, headers=None, include_dirs=None, libraries=None,
+ library_dirs=None, lang="c"):
"""Try to compile and link a source file, built from 'body' and
'headers', to executable form. Return true on success, false
otherwise.
@@ -264,10 +258,8 @@ class config (Command):
self._clean()
return ok
- def try_run (self, body,
- headers=None, include_dirs=None,
- libraries=None, library_dirs=None,
- lang="c"):
+ def try_run(self, body, headers=None, include_dirs=None, libraries=None,
+ library_dirs=None, lang="c"):
"""Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
@@ -291,10 +283,8 @@ class config (Command):
# (these are the ones that are actually likely to be useful
# when implementing a real-world config command!)
- def check_func (self, func,
- headers=None, include_dirs=None,
- libraries=None, library_dirs=None,
- decl=0, call=0):
+ def check_func(self, func, headers=None, include_dirs=None,
+ libraries=None, library_dirs=None, decl=0, call=0):
"""Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
@@ -327,8 +317,8 @@ class config (Command):
# 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,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing the source file to
@@ -342,8 +332,8 @@ class config (Command):
headers, include_dirs,
[library]+other_libraries, library_dirs)
- def check_header (self, header, include_dirs=None,
- library_dirs=None, lang="c"):
+ def check_header(self, header, include_dirs=None, library_dirs=None,
+ lang="c"):
"""Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
@@ -352,8 +342,6 @@ class config (Command):
include_dirs=include_dirs)
-# class config
-
def dump_file(filename, head=None):
"""Dumps a file content into log.info.