Commit e1ba0d3f authored by serge-sans-paille's avatar serge-sans-paille

Make pythran version checks more resilient

Current checks breaks when setting 0.10.0 as a Pythran version :-/
parent 7d8439e8
......@@ -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
......
......@@ -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 = False
pythran = None
pythran_is_pre_0_9 = True
# 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)
......
......@@ -760,12 +760,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'])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment