Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joseph Weston
kwant
Commits
50a8240f
Commit
50a8240f
authored
9 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
setup.py: simplify ext_modules()
parent
1d45a300
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
setup.py
+23
-17
23 additions, 17 deletions
setup.py
with
23 additions
and
17 deletions
setup.py
+
23
−
17
View file @
50a8240f
...
...
@@ -361,33 +361,39 @@ def complain_cython_unavailable():
def
ext_modules
(
extensions
):
"""
Prepare the ext_modules argument for distutils
'
setup.
"""
"""
Prepare the ext_modules argument for setuptools.
If Cython is not to be run, replace .pyx extensions with .c or .cpp, and
check timestamps.
"""
result
=
[]
problematic_files
=
[]
for
args
,
kwrds
in
extensions
:
name
,
sources
=
args
if
not
cythonize
or
cython_version
<
REQUIRED_CYTHON_VERSION
:
# Cython is not going to be run: replace pyx extension by that of
# the shipped translated file.
if
'
language
'
in
kwrds
:
if
kwrds
[
'
language
'
]
==
'
c
'
:
ext
=
'
.c
'
elif
kwrds
[
'
language
'
]
==
'
c++
'
:
ext
=
'
.cpp
'
else
:
print
(
'
Unknown language
'
,
file
=
sys
.
stderr
)
exit
(
1
)
else
:
language
=
kwrds
.
get
(
'
language
'
)
if
language
is
None
:
ext
=
'
.c
'
elif
language
==
'
c
'
:
ext
=
'
.c
'
elif
language
==
'
c++
'
:
ext
=
'
.cpp
'
else
:
print
(
'
Unknown language: {}
'
.
format
(
language
),
file
=
sys
.
stderr
)
exit
(
1
)
pyx_files
=
[]
cythonized_files
=
[]
sources
=
[]
for
f
in
args
[
1
]
:
if
f
[
-
4
:]
==
'
.pyx
'
:
new_
sources
=
[]
for
f
in
sources
:
if
f
.
endswith
(
'
.pyx
'
)
:
pyx_files
.
append
(
f
)
f
=
f
[:
-
4
]
+
ext
f
=
f
.
rstrip
(
'
.pyx
'
)
+
ext
cythonized_files
.
append
(
f
)
sources
.
append
(
f
)
args
[
1
]
=
sources
new_
sources
.
append
(
f
)
sources
=
new_
sources
# Complain if cythonized files are older than Cython source files.
try
:
...
...
@@ -406,7 +412,7 @@ def ext_modules(extensions):
if
os
.
stat
(
f
).
st_mtime
>
cythonized_oldest
:
problematic_files
.
append
(
f
)
result
.
append
(
Extension
(
*
arg
s
,
**
kwrds
))
result
.
append
(
Extension
(
name
,
source
s
,
**
kwrds
))
if
problematic_files
:
problematic_files
=
"
,
"
.
join
(
problematic_files
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment