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:
...
@@ -39,10 +39,8 @@ except ImportError:
try
:
try
:
import
pythran
import
pythran
import
pythran.config
pythran_version
=
pythran
.
__version__
except
:
except
:
pythran
_version
=
None
pythran
=
None
from
..
import
Utils
from
..
import
Utils
from
..Utils
import
(
cached_function
,
cached_method
,
path_exists
,
from
..Utils
import
(
cached_function
,
cached_method
,
path_exists
,
...
@@ -131,13 +129,13 @@ def file_hash(filename):
...
@@ -131,13 +129,13 @@ def file_hash(filename):
def
update_pythran_extension
(
ext
):
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."
)
raise
RuntimeError
(
"You first need to install Pythran to use the np_pythran directive."
)
pythran_ext
=
(
try
:
pythran
.
config
.
make_extension
(
python
=
True
)
pythran
_ext
=
pythran
.
config
.
make_extension
(
python
=
True
)
if
pythran_version
>=
'0.9'
or
pythran_version
>=
'0.8.7'
except
TypeError
:
# older pythran version only
else
pythran
.
config
.
make_extension
()
pythran_ext
=
pythran
.
config
.
make_extension
()
)
ext
.
include_dirs
.
extend
(
pythran_ext
[
'include_dirs'
])
ext
.
include_dirs
.
extend
(
pythran_ext
[
'include_dirs'
])
ext
.
extra_compile_args
.
extend
(
pythran_ext
[
'extra_compile_args'
])
ext
.
extra_compile_args
.
extend
(
pythran_ext
[
'extra_compile_args'
])
ext
.
extra_link_args
.
extend
(
pythran_ext
[
'extra_link_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,
...
@@ -953,8 +951,9 @@ def cythonize(module_list, exclude=None, nthreads=0, aliases=None, quiet=False,
if
'common_utility_include_dir'
in
options
:
if
'common_utility_include_dir'
in
options
:
safe_makedirs
(
options
[
'common_utility_include_dir'
])
safe_makedirs
(
options
[
'common_utility_include_dir'
])
pythran_options
=
None
if
pythran
is
None
:
if
pythran_version
:
pythran_options
=
None
else
:
pythran_options
=
CompilationOptions
(
**
options
)
pythran_options
=
CompilationOptions
(
**
options
)
pythran_options
.
cplus
=
True
pythran_options
.
cplus
=
True
pythran_options
.
np_pythran
=
True
pythran_options
.
np_pythran
=
True
...
...
Cython/Compiler/Pythran.py
View file @
cd76a42a
...
@@ -8,11 +8,10 @@ import cython
...
@@ -8,11 +8,10 @@ import cython
try
:
try
:
import
pythran
import
pythran
pythran_version
=
pythran
.
__version__
pythran_is_pre_0_9
=
tuple
(
map
(
int
,
pythran
.
__version__
.
split
(
'.'
)[
0
:
2
]))
<
(
0
,
9
)
pythran_is_0_8_7
=
pythran_version
>=
'0.9'
or
pythran_version
>=
'0.8.7'
except
ImportError
:
except
ImportError
:
pythran
_version
=
None
pythran
=
None
pythran_is_
0_8_7
=
Fals
e
pythran_is_
pre_0_9
=
Tru
e
# Pythran/Numpy specific operations
# Pythran/Numpy specific operations
...
@@ -41,10 +40,10 @@ def pythran_type(Ty, ptype="ndarray"):
...
@@ -41,10 +40,10 @@ def pythran_type(Ty, ptype="ndarray"):
ctype
=
dtype
.
typedef_cname
ctype
=
dtype
.
typedef_cname
else
:
else
:
raise
ValueError
(
"unsupported type %s!"
%
dtype
)
raise
ValueError
(
"unsupported type %s!"
%
dtype
)
if
pythran_is_0_8_7
:
if
pythran_is_pre_0_9
:
return
"pythonic::types::%s<%s,pythonic::types::pshape<%s>>"
%
(
ptype
,
ctype
,
","
.
join
((
"Py_ssize_t"
,)
*
ndim
))
else
:
return
"pythonic::types::%s<%s,%d>"
%
(
ptype
,
ctype
,
ndim
)
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
:
if
Ty
.
is_pythran_expr
:
return
Ty
.
pythran_type
return
Ty
.
pythran_type
#if Ty.is_none:
#if Ty.is_none:
...
@@ -129,7 +128,10 @@ def np_func_to_list(func):
...
@@ -129,7 +128,10 @@ def np_func_to_list(func):
return
[]
return
[]
return
np_func_to_list
(
func
.
obj
)
+
[
func
.
attribute
]
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
):
def
pythran_is_numpy_func_supported
(
func
):
CurF
=
pythran
.
tables
.
MODULES
[
'numpy'
]
CurF
=
pythran
.
tables
.
MODULES
[
'numpy'
]
FL
=
np_func_to_list
(
func
)
FL
=
np_func_to_list
(
func
)
...
@@ -138,9 +140,6 @@ if pythran_version:
...
@@ -138,9 +140,6 @@ if pythran_version:
if
CurF
is
None
:
if
CurF
is
None
:
return
False
return
False
return
True
return
True
else
:
def
pythran_is_numpy_func_supported
(
name
):
return
False
def
pythran_functor
(
func
):
def
pythran_functor
(
func
):
func
=
np_func_to_list
(
func
)
func
=
np_func_to_list
(
func
)
...
...
runtests.py
View file @
cd76a42a
...
@@ -761,12 +761,10 @@ class TestBuilder(object):
...
@@ -761,12 +761,10 @@ class TestBuilder(object):
pythran_dir = self.pythran_dir
pythran_dir = self.pythran_dir
if 'pythran' in tags['tag'] and not pythran_dir and 'cpp' in languages:
if 'pythran' in tags['tag'] and not pythran_dir and 'cpp' in languages:
import pythran.config
import pythran.config
from pythran import __version__ as pythran_version
try:
pythran_ext = (
pythran_ext = pythran.config.make_extension(python=True)
pythran.config.make_extension(python=True)
except TypeError: # old pythran version syntax
if pythran_version >= '0.9' or pythran_version >= '0.8.7'
pythran_ext = pythran.config.make_extension()
else pythran.config.make_extension()
)
pythran_dir = pythran_ext['include_dirs'][0]
pythran_dir = pythran_ext['include_dirs'][0]
preparse_list = tags.get('preparse', ['id'])
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