Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
c7cb2d86
Commit
c7cb2d86
authored
Jul 11, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaned up distutils.build_ext module
parent
56d54402
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
26 deletions
+16
-26
command/build_ext.py
command/build_ext.py
+16
-26
No files found.
command/build_ext.py
View file @
c7cb2d86
...
@@ -6,8 +6,7 @@ extensions ASAP)."""
...
@@ -6,8 +6,7 @@ extensions ASAP)."""
__revision__
=
"$Id$"
__revision__
=
"$Id$"
import
sys
,
os
,
string
,
re
import
sys
,
os
,
re
from
types
import
*
from
warnings
import
warn
from
warnings
import
warn
from
distutils.core
import
Command
from
distutils.core
import
Command
...
@@ -41,7 +40,7 @@ def show_compilers ():
...
@@ -41,7 +40,7 @@ def show_compilers ():
show_compilers
()
show_compilers
()
class
build_ext
(
Command
):
class
build_ext
(
Command
):
description
=
"build C/C++ extensions (compile/link to build directory)"
description
=
"build C/C++ extensions (compile/link to build directory)"
...
@@ -149,7 +148,7 @@ class build_ext (Command):
...
@@ -149,7 +148,7 @@ class build_ext (Command):
compiler
=
property
(
_get_compiler
,
_set_compiler
)
compiler
=
property
(
_get_compiler
,
_set_compiler
)
def
initialize_options
(
self
):
def
initialize_options
(
self
):
self
.
extensions
=
None
self
.
extensions
=
None
self
.
build_lib
=
None
self
.
build_lib
=
None
self
.
plat_name
=
None
self
.
plat_name
=
None
...
@@ -213,13 +212,13 @@ class build_ext (Command):
...
@@ -213,13 +212,13 @@ class build_ext (Command):
self
.
libraries
=
[]
self
.
libraries
=
[]
if
self
.
library_dirs
is
None
:
if
self
.
library_dirs
is
None
:
self
.
library_dirs
=
[]
self
.
library_dirs
=
[]
elif
type
(
self
.
library_dirs
)
is
StringType
:
elif
isinstance
(
self
.
library_dirs
,
str
)
:
self
.
library_dirs
=
s
tring
.
split
(
self
.
library_dirs
,
os
.
pathsep
)
self
.
library_dirs
=
s
elf
.
library_dirs
.
split
(
os
.
pathsep
)
if
self
.
rpath
is
None
:
if
self
.
rpath
is
None
:
self
.
rpath
=
[]
self
.
rpath
=
[]
elif
type
(
self
.
rpath
)
is
StringType
:
elif
isinstance
(
self
.
rpath
,
str
)
:
self
.
rpath
=
s
tring
.
split
(
self
.
rpath
,
os
.
pathsep
)
self
.
rpath
=
s
elf
.
rpath
.
split
(
os
.
pathsep
)
# for extensions under windows use different directories
# for extensions under windows use different directories
# for Release and Debug builds.
# for Release and Debug builds.
...
@@ -296,7 +295,7 @@ class build_ext (Command):
...
@@ -296,7 +295,7 @@ class build_ext (Command):
if
self
.
define
:
if
self
.
define
:
defines
=
self
.
define
.
split
(
','
)
defines
=
self
.
define
.
split
(
','
)
self
.
define
=
map
(
lambda
symbol
:
(
symbol
,
'1'
),
defines
)
self
.
define
=
[(
symbol
,
'1'
)
for
symbol
in
defines
]
# The option for macros to undefine is also a string from the
# The option for macros to undefine is also a string from the
# option parsing, but has to be a list. Multiple symbols can also
# option parsing, but has to be a list. Multiple symbols can also
...
@@ -512,7 +511,7 @@ class build_ext (Command):
...
@@ -512,7 +511,7 @@ 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 "
+
...
@@ -593,14 +592,12 @@ class build_ext (Command):
...
@@ -593,14 +592,12 @@ class build_ext (Command):
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
=
{}
...
@@ -649,9 +646,7 @@ class build_ext (Command):
...
@@ -649,9 +646,7 @@ 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.
...
@@ -680,8 +675,6 @@ class build_ext (Command):
...
@@ -680,8 +675,6 @@ class build_ext (Command):
(
"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)
def
get_ext_fullpath
(
self
,
ext_name
):
def
get_ext_fullpath
(
self
,
ext_name
):
...
@@ -726,29 +719,28 @@ class build_ext (Command):
...
@@ -726,29 +719,28 @@ class build_ext (Command):
"foo\bar.pyd").
"foo\bar.pyd").
"""
"""
from
distutils.sysconfig
import
get_config_var
from
distutils.sysconfig
import
get_config_var
ext_path
=
string
.
split
(
ext_name
,
'.'
)
ext_path
=
ext_name
.
split
(
'.'
)
# OS/2 has an 8 character module (extension) limit :-(
# OS/2 has an 8 character module (extension) limit :-(
if
os
.
name
==
"os2"
:
if
os
.
name
==
"os2"
:
ext_path
[
len
(
ext_path
)
-
1
]
=
ext_path
[
len
(
ext_path
)
-
1
][:
8
]
ext_path
[
len
(
ext_path
)
-
1
]
=
ext_path
[
len
(
ext_path
)
-
1
][:
8
]
# extensions in debug_mode are named 'module_d.pyd' under windows
# extensions in debug_mode are named 'module_d.pyd' under windows
so_ext
=
get_config_var
(
'SO'
)
so_ext
=
get_config_var
(
'SO'
)
if
os
.
name
==
'nt'
and
self
.
debug
:
if
os
.
name
==
'nt'
and
self
.
debug
:
return
apply
(
os
.
path
.
join
,
ext_path
)
+
'_d'
+
so_ext
return
os
.
path
.
join
(
*
ext_path
)
+
'_d'
+
so_ext
return
os
.
path
.
join
(
*
ext_path
)
+
so_ext
return
os
.
path
.
join
(
*
ext_path
)
+
so_ext
def
get_export_symbols
(
self
,
ext
):
def
get_export_symbols
(
self
,
ext
):
"""Return the list of symbols that a shared extension has to
"""Return the list of symbols that a shared extension has to
export. This either uses 'ext.export_symbols' or, if it's not
export. This either uses 'ext.export_symbols' or, if it's not
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"
+
string
.
split
(
ext
.
name
,
'.'
)[
-
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
)
return
ext
.
export_symbols
return
ext
.
export_symbols
def
get_libraries
(
self
,
ext
):
def
get_libraries
(
self
,
ext
):
"""Return the list of libraries to link against when building a
"""Return the list of libraries to link against when building a
shared extension. On most platforms, this is just 'ext.libraries';
shared extension. On most platforms, this is just 'ext.libraries';
on Windows and OS/2, we add the Python library (eg. python20.dll).
on Windows and OS/2, we add the Python library (eg. python20.dll).
...
@@ -821,5 +813,3 @@ class build_ext (Command):
...
@@ -821,5 +813,3 @@ class build_ext (Command):
return
ext
.
libraries
+
[
pythonlib
]
return
ext
.
libraries
+
[
pythonlib
]
else
:
else
:
return
ext
.
libraries
return
ext
.
libraries
# class build_ext
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