Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
cd76a42a
Commit
cd76a42a
authored
May 06, 2019
by
Stefan Behnel
Committed by
GitHub
May 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2947 from serge-sans-paille/fix/pythran-version-checks
Make pythran version checks more resilient
parents
c2386dfe
e1ba0d3f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
28 deletions
+24
-28
Cython/Build/Dependencies.py
Cython/Build/Dependencies.py
+10
-11
Cython/Compiler/Pythran.py
Cython/Compiler/Pythran.py
+10
-11
runtests.py
runtests.py
+4
-6
No files found.
Cython/Build/Dependencies.py
View file @
cd76a42a
...
...
@@ -39,10 +39,8 @@ except ImportError:
try
:
import
pythran
import
pythran.config
pythran_version
=
pythran
.
__version__
except
:
pythran
_version
=
None
pythran
=
None
from
..
import
Utils
from
..Utils
import
(
cached_function
,
cached_method
,
path_exists
,
...
...
@@ -131,13 +129,13 @@ def file_hash(filename):
def
update_pythran_extension
(
ext
):
if
not
pythran_version
:
if
pythran
is
None
:
raise
RuntimeError
(
"You first need to install Pythran to use the np_pythran directive."
)
pythran_ext
=
(
pythran
.
config
.
make_extension
(
python
=
True
)
if
pythran_version
>=
'0.9'
or
pythran_version
>=
'0.8.7'
else
pythran
.
config
.
make_extension
()
)
try
:
pythran
_ext
=
pythran
.
config
.
make_extension
(
python
=
True
)
except
TypeError
:
# older pythran version only
pythran_ext
=
pythran
.
config
.
make_extension
()
ext
.
include_dirs
.
extend
(
pythran_ext
[
'include_dirs'
])
ext
.
extra_compile_args
.
extend
(
pythran_ext
[
'extra_compile_args'
])
ext
.
extra_link_args
.
extend
(
pythran_ext
[
'extra_link_args'
])
...
...
@@ -953,8 +951,9 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False,
if
'common_utility_include_dir'
in
options
:
safe_makedirs
(
options
[
'common_utility_include_dir'
])
pythran_options
=
None
if
pythran_version
:
if
pythran
is
None
:
pythran_options
=
None
else
:
pythran_options
=
CompilationOptions
(
**
options
)
pythran_options
.
cplus
=
True
pythran_options
.
np_pythran
=
True
...
...
Cython/Compiler/Pythran.py
View file @
cd76a42a
...
...
@@ -8,11 +8,10 @@ import cython
try
:
import
pythran
pythran_version
=
pythran
.
__version__
pythran_is_0_8_7
=
pythran_version
>=
'0.9'
or
pythran_version
>=
'0.8.7'
pythran_is_pre_0_9
=
tuple
(
map
(
int
,
pythran
.
__version__
.
split
(
'.'
)[
0
:
2
]))
<
(
0
,
9
)
except
ImportError
:
pythran
_version
=
None
pythran_is_
0_8_7
=
Fals
e
pythran
=
None
pythran_is_
pre_0_9
=
Tru
e
# Pythran/Numpy specific operations
...
...
@@ -41,10 +40,10 @@ def pythran_type(Ty, ptype="ndarray"):
ctype
=
dtype
.
typedef_cname
else
:
raise
ValueError
(
"unsupported type %s!"
%
dtype
)
if
pythran_is_0_8_7
:
return
"pythonic::types::%s<%s,pythonic::types::pshape<%s>>"
%
(
ptype
,
ctype
,
","
.
join
((
"Py_ssize_t"
,)
*
ndim
))
else
:
if
pythran_is_pre_0_9
:
return
"pythonic::types::%s<%s,%d>"
%
(
ptype
,
ctype
,
ndim
)
else
:
return
"pythonic::types::%s<%s,pythonic::types::pshape<%s>>"
%
(
ptype
,
ctype
,
","
.
join
((
"Py_ssize_t"
,)
*
ndim
))
if
Ty
.
is_pythran_expr
:
return
Ty
.
pythran_type
#if Ty.is_none:
...
...
@@ -129,7 +128,10 @@ def np_func_to_list(func):
return
[]
return
np_func_to_list
(
func
.
obj
)
+
[
func
.
attribute
]
if
pythran_version
:
if
pythran
is
None
:
def
pythran_is_numpy_func_supported
(
name
):
return
False
else
:
def
pythran_is_numpy_func_supported
(
func
):
CurF
=
pythran
.
tables
.
MODULES
[
'numpy'
]
FL
=
np_func_to_list
(
func
)
...
...
@@ -138,9 +140,6 @@ if pythran_version:
if
CurF
is
None
:
return
False
return
True
else
:
def
pythran_is_numpy_func_supported
(
name
):
return
False
def
pythran_functor
(
func
):
func
=
np_func_to_list
(
func
)
...
...
runtests.py
View file @
cd76a42a
...
...
@@ -761,12 +761,10 @@ class TestBuilder(object):
pythran_dir = self.pythran_dir
if 'pythran' in tags['tag'] and not pythran_dir and 'cpp' in languages:
import pythran.config
from pythran import __version__ as pythran_version
pythran_ext = (
pythran.config.make_extension(python=True)
if pythran_version >= '0.9' or pythran_version >= '0.8.7'
else pythran.config.make_extension()
)
try:
pythran_ext = pythran.config.make_extension(python=True)
except TypeError: # old pythran version syntax
pythran_ext = pythran.config.make_extension()
pythran_dir = pythran_ext['include_dirs'][0]
preparse_list = tags.get('preparse', ['id'])
...
...
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