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
261a4ed0
Commit
261a4ed0
authored
Mar 10, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a single method to handle both languages.
parent
158b463e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
+21
-19
CHANGES.txt
CHANGES.txt
+6
-0
setuptools/extension.py
setuptools/extension.py
+15
-19
No files found.
CHANGES.txt
View file @
261a4ed0
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
CHANGES
CHANGES
=======
=======
---
3.2
---
* Pull Request #39: Add support for C++ targets from Cython ``.pyx`` files.
---
---
3.1
3.1
---
---
...
...
setuptools/extension.py
View file @
261a4ed0
...
@@ -26,27 +26,23 @@ class Extension(_Extension):
...
@@ -26,27 +26,23 @@ class Extension(_Extension):
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
*
args
,
**
kw
):
_Extension
.
__init__
(
self
,
*
args
,
**
kw
)
_Extension
.
__init__
(
self
,
*
args
,
**
kw
)
if
not
have_pyrex
():
self
.
_convert_pyx_sources_to_lang
()
if
self
.
language
.
lower
()
==
'c++'
:
self
.
_convert_pyx_sources_to_cpp
()
else
:
self
.
_convert_pyx_sources_to_c
()
def
_convert_pyx_sources_to_cpp
(
self
):
"convert .pyx extensions to .cpp"
def
pyx_to_c
(
source
):
if
source
.
endswith
(
'.pyx'
):
source
=
source
[:
-
4
]
+
'.cpp'
return
source
self
.
sources
=
list
(
map
(
pyx_to_c
,
self
.
sources
))
def
_convert_pyx_sources_to_c
(
self
):
def
_convert_pyx_sources_to_lang
(
self
):
"convert .pyx extensions to .c"
"""
def
pyx_to_c
(
source
):
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
"""
if
have_pyrex
():
# the build has Cython, so allow it to compile the .pyx files
return
def
pyx_to_target
(
source
):
target_ext
=
'.cpp'
if
self
.
language
.
lower
()
==
'c++'
else
'.c'
if
source
.
endswith
(
'.pyx'
):
if
source
.
endswith
(
'.pyx'
):
source
=
source
[:
-
4
]
+
'.c'
source
=
source
[:
-
4
]
+
target_ext
return
source
return
source
self
.
sources
=
list
(
map
(
pyx_to_
c
,
self
.
sources
))
self
.
sources
=
list
(
map
(
pyx_to_
target
,
self
.
sources
))
class
Library
(
Extension
):
class
Library
(
Extension
):
"""Just like a regular Extension, but built as a library instead"""
"""Just like a regular Extension, but built as a library instead"""
...
...
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