Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7bea344d
Commit
7bea344d
authored
Apr 12, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8-fied the module before adding tests
parent
aa48798f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
37 deletions
+25
-37
Lib/distutils/command/config.py
Lib/distutils/command/config.py
+25
-37
No files found.
Lib/distutils/command/config.py
View file @
7bea344d
...
@@ -18,10 +18,9 @@ from distutils.errors import DistutilsExecError
...
@@ -18,10 +18,9 @@ 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
):
description
=
"prepare to build"
description
=
"prepare to build"
...
@@ -51,12 +50,10 @@ class config (Command):
...
@@ -51,12 +50,10 @@ class config (Command):
# The three standard command methods: since the "config" command
# The three standard command methods: since the "config" command
# does nothing by default, these are empty.
# does nothing by default, these are empty.
def
initialize_options
(
self
):
def
initialize_options
(
self
):
self
.
compiler
=
None
self
.
compiler
=
None
self
.
cc
=
None
self
.
cc
=
None
self
.
include_dirs
=
None
self
.
include_dirs
=
None
#self.define = None
#self.undef = None
self
.
libraries
=
None
self
.
libraries
=
None
self
.
library_dirs
=
None
self
.
library_dirs
=
None
...
@@ -68,7 +65,7 @@ class config (Command):
...
@@ -68,7 +65,7 @@ class config (Command):
# to clean at some point
# to clean at some point
self
.
temp_files
=
[]
self
.
temp_files
=
[]
def
finalize_options
(
self
):
def
finalize_options
(
self
):
if
self
.
include_dirs
is
None
:
if
self
.
include_dirs
is
None
:
self
.
include_dirs
=
self
.
distribution
.
include_dirs
or
[]
self
.
include_dirs
=
self
.
distribution
.
include_dirs
or
[]
elif
type
(
self
.
include_dirs
)
is
StringType
:
elif
type
(
self
.
include_dirs
)
is
StringType
:
...
@@ -93,7 +90,7 @@ class config (Command):
...
@@ -93,7 +90,7 @@ class config (Command):
# 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.
def
_check_compiler
(
self
):
def
_check_compiler
(
self
):
"""Check that 'self.compiler' really is a CCompiler object;
"""Check that 'self.compiler' really is a CCompiler object;
if not, make it one.
if not, make it one.
"""
"""
...
@@ -112,7 +109,7 @@ class config (Command):
...
@@ -112,7 +109,7 @@ class config (Command):
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"
)
if
headers
:
if
headers
:
...
@@ -125,14 +122,14 @@ class config (Command):
...
@@ -125,14 +122,14 @@ class config (Command):
file
.
close
()
file
.
close
()
return
filename
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
)
src
=
self
.
_gen_temp_sourcefile
(
body
,
headers
,
lang
)
out
=
"_configtest.i"
out
=
"_configtest.i"
self
.
temp_files
.
extend
([
src
,
out
])
self
.
temp_files
.
extend
([
src
,
out
])
self
.
compiler
.
preprocess
(
src
,
out
,
include_dirs
=
include_dirs
)
self
.
compiler
.
preprocess
(
src
,
out
,
include_dirs
=
include_dirs
)
return
(
src
,
out
)
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
)
src
=
self
.
_gen_temp_sourcefile
(
body
,
headers
,
lang
)
if
self
.
dump_source
:
if
self
.
dump_source
:
dump_file
(
src
,
"compiling '%s':"
%
src
)
dump_file
(
src
,
"compiling '%s':"
%
src
)
...
@@ -141,9 +138,8 @@ class config (Command):
...
@@ -141,9 +138,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
,
library_dirs
,
headers
,
include_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
,
...
@@ -157,7 +153,7 @@ class config (Command):
...
@@ -157,7 +153,7 @@ class config (Command):
return
(
src
,
obj
,
prog
)
return
(
src
,
obj
,
prog
)
def
_clean
(
self
,
*
filenames
):
def
_clean
(
self
,
*
filenames
):
if
not
filenames
:
if
not
filenames
:
filenames
=
self
.
temp_files
filenames
=
self
.
temp_files
self
.
temp_files
=
[]
self
.
temp_files
=
[]
...
@@ -179,7 +175,7 @@ class config (Command):
...
@@ -179,7 +175,7 @@ class config (Command):
# XXX need access to the header search path and maybe default macros.
# 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
"""Construct a source file from 'body' (a string containing lines
of C/C++ code) and 'headers' (a list of header files to include)
of C/C++ code) and 'headers' (a list of header files to include)
and run it through the preprocessor. Return true if the
and run it through the preprocessor. Return true if the
...
@@ -197,8 +193,8 @@ class config (Command):
...
@@ -197,8 +193,8 @@ class config (Command):
self
.
_clean
()
self
.
_clean
()
return
ok
return
ok
def
search_cpp
(
self
,
pattern
,
body
=
None
,
def
search_cpp
(
self
,
pattern
,
body
=
None
,
headers
=
None
,
include_dirs
=
None
,
headers
=
None
,
include_dirs
=
None
,
lang
=
"c"
):
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
...
@@ -227,7 +223,7 @@ class config (Command):
...
@@ -227,7 +223,7 @@ class config (Command):
self
.
_clean
()
self
.
_clean
()
return
match
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'.
"""Try to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
Return true on success, false otherwise.
"""
"""
...
@@ -243,10 +239,8 @@ class config (Command):
...
@@ -243,10 +239,8 @@ class config (Command):
self
.
_clean
()
self
.
_clean
()
return
ok
return
ok
def
try_link
(
self
,
body
,
def
try_link
(
self
,
body
,
headers
=
None
,
include_dirs
=
None
,
libraries
=
None
,
headers
=
None
,
include_dirs
=
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.
...
@@ -264,10 +258,8 @@ class config (Command):
...
@@ -264,10 +258,8 @@ class config (Command):
self
.
_clean
()
self
.
_clean
()
return
ok
return
ok
def
try_run
(
self
,
body
,
def
try_run
(
self
,
body
,
headers
=
None
,
include_dirs
=
None
,
libraries
=
None
,
headers
=
None
,
include_dirs
=
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.
...
@@ -291,10 +283,8 @@ class config (Command):
...
@@ -291,10 +283,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.
...
@@ -327,8 +317,8 @@ class config (Command):
...
@@ -327,8 +317,8 @@ class config (Command):
# check_func ()
# check_func ()
def
check_lib
(
self
,
library
,
library_di
rs
=
None
,
def
check_lib
(
self
,
library
,
library_dirs
=
None
,
heade
rs
=
None
,
headers
=
None
,
include_dirs
=
None
,
other_libraries
=
[]):
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
...
@@ -342,8 +332,8 @@ class config (Command):
...
@@ -342,8 +332,8 @@ class config (Command):
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.
...
@@ -352,8 +342,6 @@ class config (Command):
...
@@ -352,8 +342,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
):
"""Dumps a file content into log.info.
"""Dumps a file content into log.info.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment