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
0cb7c312
Commit
0cb7c312
authored
Jan 26, 2001
by
Marc-André Lemburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added an execution layer to be able to customize per-extension
building.
parent
5634233c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
91 deletions
+92
-91
command/build_ext.py
command/build_ext.py
+92
-91
No files found.
command/build_ext.py
View file @
0cb7c312
...
...
@@ -356,104 +356,105 @@ class build_ext (Command):
# get_outputs ()
def
build_extensions
(
self
):
def
build_extensions
(
self
):
# First, sanity-check the 'extensions' list
self
.
check_extensions_list
(
self
.
extensions
)
for
ext
in
self
.
extensions
:
sources
=
ext
.
sources
if
sources
is
None
or
type
(
sources
)
not
in
(
ListType
,
TupleType
):
raise
DistutilsSetupError
,
\
(
"in 'ext_modules' option (extension '%s'), "
+
"'sources' must be present and must be "
+
"a list of source filenames"
)
%
ext
.
name
sources
=
list
(
sources
)
self
.
build_extension
(
ext
)
fullname
=
self
.
get_ext_fullname
(
ext
.
name
)
if
self
.
inplace
:
# ignore build-lib -- put the compiled extension into
# the source tree along with pure Python modules
modpath
=
string
.
split
(
fullname
,
'.'
)
package
=
string
.
join
(
modpath
[
0
:
-
1
],
'.'
)
base
=
modpath
[
-
1
]
build_py
=
self
.
get_finalized_command
(
'build_py'
)
package_dir
=
build_py
.
get_package_dir
(
package
)
ext_filename
=
os
.
path
.
join
(
package_dir
,
self
.
get_ext_filename
(
base
))
else
:
ext_filename
=
os
.
path
.
join
(
self
.
build_lib
,
self
.
get_ext_filename
(
fullname
))
def
build_extension
(
self
,
ext
):
if
not
(
self
.
force
or
newer_group
(
sources
,
ext_filename
,
'newer'
)):
self
.
announce
(
"skipping '%s' extension (up-to-date)"
%
ext
.
name
)
continue
# 'for' loop over all extensions
else
:
self
.
announce
(
"building '%s' extension"
%
ext
.
name
)
# First, scan the sources for SWIG definition files (.i), run
# SWIG on 'em to create .c files, and modify the sources list
# accordingly.
sources
=
self
.
swig_sources
(
sources
)
# Next, compile the source code to object files.
# XXX not honouring 'define_macros' or 'undef_macros' -- the
# CCompiler API needs to change to accommodate this, and I
# want to do one thing at a time!
# Two possible sources for extra compiler arguments:
# - 'extra_compile_args' in Extension object
# - CFLAGS environment variable (not particularly
# elegant, but people seem to expect it and I
# guess it's useful)
# The environment variable should take precedence, and
# any sensible compiler will give precedence to later
# command line args. Hence we combine them in order:
extra_args
=
ext
.
extra_compile_args
or
[]
macros
=
ext
.
define_macros
[:]
for
undef
in
ext
.
undef_macros
:
macros
.
append
((
undef
,))
# XXX and if we support CFLAGS, why not CC (compiler
# executable), CPPFLAGS (pre-processor options), and LDFLAGS
# (linker options) too?
# XXX should we use shlex to properly parse CFLAGS?
if
os
.
environ
.
has_key
(
'CFLAGS'
):
extra_args
.
extend
(
string
.
split
(
os
.
environ
[
'CFLAGS'
]))
objects
=
self
.
compiler
.
compile
(
sources
,
output_dir
=
self
.
build_temp
,
macros
=
macros
,
include_dirs
=
ext
.
include_dirs
,
debug
=
self
.
debug
,
extra_postargs
=
extra_args
)
# Now link the object files together into a "shared object" --
# of course, first we have to figure out all the other things
# that go into the mix.
if
ext
.
extra_objects
:
objects
.
extend
(
ext
.
extra_objects
)
extra_args
=
ext
.
extra_link_args
or
[]
self
.
compiler
.
link_shared_object
(
objects
,
ext_filename
,
libraries
=
self
.
get_libraries
(
ext
),
library_dirs
=
ext
.
library_dirs
,
runtime_library_dirs
=
ext
.
runtime_library_dirs
,
extra_postargs
=
extra_args
,
export_symbols
=
self
.
get_export_symbols
(
ext
),
debug
=
self
.
debug
,
build_temp
=
self
.
build_temp
)
# build_extensions ()
sources
=
ext
.
sources
if
sources
is
None
or
type
(
sources
)
not
in
(
ListType
,
TupleType
):
raise
DistutilsSetupError
,
\
(
"in 'ext_modules' option (extension '%s'), "
+
"'sources' must be present and must be "
+
"a list of source filenames"
)
%
ext
.
name
sources
=
list
(
sources
)
fullname
=
self
.
get_ext_fullname
(
ext
.
name
)
if
self
.
inplace
:
# ignore build-lib -- put the compiled extension into
# the source tree along with pure Python modules
modpath
=
string
.
split
(
fullname
,
'.'
)
package
=
string
.
join
(
modpath
[
0
:
-
1
],
'.'
)
base
=
modpath
[
-
1
]
build_py
=
self
.
get_finalized_command
(
'build_py'
)
package_dir
=
build_py
.
get_package_dir
(
package
)
ext_filename
=
os
.
path
.
join
(
package_dir
,
self
.
get_ext_filename
(
base
))
else
:
ext_filename
=
os
.
path
.
join
(
self
.
build_lib
,
self
.
get_ext_filename
(
fullname
))
if
not
(
self
.
force
or
newer_group
(
sources
,
ext_filename
,
'newer'
)):
self
.
announce
(
"skipping '%s' extension (up-to-date)"
%
ext
.
name
)
return
else
:
self
.
announce
(
"building '%s' extension"
%
ext
.
name
)
# First, scan the sources for SWIG definition files (.i), run
# SWIG on 'em to create .c files, and modify the sources list
# accordingly.
sources
=
self
.
swig_sources
(
sources
)
# Next, compile the source code to object files.
# XXX not honouring 'define_macros' or 'undef_macros' -- the
# CCompiler API needs to change to accommodate this, and I
# want to do one thing at a time!
# Two possible sources for extra compiler arguments:
# - 'extra_compile_args' in Extension object
# - CFLAGS environment variable (not particularly
# elegant, but people seem to expect it and I
# guess it's useful)
# The environment variable should take precedence, and
# any sensible compiler will give precedence to later
# command line args. Hence we combine them in order:
extra_args
=
ext
.
extra_compile_args
or
[]
macros
=
ext
.
define_macros
[:]
for
undef
in
ext
.
undef_macros
:
macros
.
append
((
undef
,))
# XXX and if we support CFLAGS, why not CC (compiler
# executable), CPPFLAGS (pre-processor options), and LDFLAGS
# (linker options) too?
# XXX should we use shlex to properly parse CFLAGS?
if
os
.
environ
.
has_key
(
'CFLAGS'
):
extra_args
.
extend
(
string
.
split
(
os
.
environ
[
'CFLAGS'
]))
objects
=
self
.
compiler
.
compile
(
sources
,
output_dir
=
self
.
build_temp
,
macros
=
macros
,
include_dirs
=
ext
.
include_dirs
,
debug
=
self
.
debug
,
extra_postargs
=
extra_args
)
# Now link the object files together into a "shared object" --
# of course, first we have to figure out all the other things
# that go into the mix.
if
ext
.
extra_objects
:
objects
.
extend
(
ext
.
extra_objects
)
extra_args
=
ext
.
extra_link_args
or
[]
self
.
compiler
.
link_shared_object
(
objects
,
ext_filename
,
libraries
=
self
.
get_libraries
(
ext
),
library_dirs
=
ext
.
library_dirs
,
runtime_library_dirs
=
ext
.
runtime_library_dirs
,
extra_postargs
=
extra_args
,
export_symbols
=
self
.
get_export_symbols
(
ext
),
debug
=
self
.
debug
,
build_temp
=
self
.
build_temp
)
def
swig_sources
(
self
,
sources
):
...
...
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