From 0920cca7020ba1f2d8f098c0ff4cb6a45d1fb4a8 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 26 Jun 2015 13:16:02 -0500 Subject: [PATCH] Enum wrapping, out-of-line-mode, build fixes --- .gitignore | 5 +- gen_wrap.py | 272 +++++++++++++++++++++++++++++++------------- islpy/__init__.py | 42 +++++-- islpy/_isl_build.py | 12 -- setup.py | 115 ++++++++++++++----- test/test_isl.py | 24 +++- 6 files changed, 336 insertions(+), 134 deletions(-) delete mode 100644 islpy/_isl_build.py diff --git a/.gitignore b/.gitignore index 121f09a..a1c1404 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,7 @@ core src/wrapper/gen-* .dirty-git-ok wrapped-functions.h -_isl_cffi.py +_isl_cffi.c _isl.py -class_list.py +name_list.py +islpy_cffi_build.py diff --git a/gen_wrap.py b/gen_wrap.py index e13fb57..e671579 100644 --- a/gen_wrap.py +++ b/gen_wrap.py @@ -1,4 +1,27 @@ from __future__ import print_function + +__copyright__ = "Copyright (C) 2011-15 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import re import sys from py_codegen import PythonCodeGenerator, Indentation @@ -32,29 +55,36 @@ def for lambda try # {{{ data model class Argument: - def __init__(self, name, semantics, base_type, ptr): + def __init__(self, name, semantics, decl_words, base_type, ptr): self.name = name self.semantics = semantics + assert isinstance(decl_words, list) + self.decl_words = decl_words self.base_type = base_type self.ptr = ptr def c_declarator(self): - return "{type} {ptr}{name}".format( + return "{decl_words} {type} {ptr}{name}".format( + decl_words=" ".join(self.decl_words), type=self.base_type, ptr=self.ptr, name=self.name) class CallbackArgument: - def __init__(self, name, return_semantics, return_base_type, return_ptr, args): + def __init__(self, name, + return_semantics, return_decl_words, return_base_type, return_ptr, args): self.name = name self.return_semantics = return_semantics + assert isinstance(return_decl_words, list) + self.return_decl_words = return_decl_words self.return_base_type = return_base_type self.return_ptr = return_ptr self.args = args def c_declarator(self): - return "{type} {ptr}(*{name})({args})".format( + return "{decl_words} {type} {ptr}(*{name})({args})".format( + decl_words=" ".join(self.return_decl_words), type=self.return_base_type, ptr=self.return_ptr, name=self.name, @@ -63,12 +93,13 @@ class CallbackArgument: class Method: def __init__(self, cls, name, c_name, - return_semantics, return_base_type, return_ptr, + return_semantics, return_decl_words, return_base_type, return_ptr, args, is_exported, is_constructor): self.cls = cls self.name = name self.c_name = c_name self.return_semantics = return_semantics + self.return_decl_words = return_decl_words self.return_base_type = return_base_type self.return_ptr = return_ptr self.args = args @@ -144,6 +175,8 @@ CLASSES = [ "ast_build", ] +UNTYPEDEFD_CLASSES = ["options"] + IMPLICIT_CONVERSIONS = { "isl_set": [("isl_basic_set", "from_basic_set")], @@ -155,44 +188,41 @@ IMPLICIT_CONVERSIONS = { } -HEADER_PREAMBLE = """ -// ctx.h -typedef enum { - isl_error_none = 0, +ENUMS = { + # ctx.h + "isl_error": """ + isl_error_none, isl_error_abort, isl_error_alloc, isl_error_unknown, isl_error_internal, isl_error_invalid, isl_error_quota, - isl_error_unsupported -} isl_error; - -typedef enum { - isl_stat_error = -1, - isl_stat_ok = 0, -} isl_stat; - -typedef enum { - isl_bool_error = -1, - isl_bool_false = 0, - isl_bool_true = 1 -} isl_bool; - -// space.h -typedef enum { + isl_error_unsupported, + """, + "isl_stat": """ + isl_stat_error, + isl_stat_ok, + """, + "isl_bool": """ + isl_bool_error, + isl_bool_false, + isl_bool_true, + """, + # space.h + "isl_dim_type": """ isl_dim_cst, isl_dim_param, isl_dim_in, isl_dim_out, - isl_dim_set = isl_dim_out, + isl_dim_set, isl_dim_div, - isl_dim_all -} isl_dim_type; + isl_dim_all, + """, -// ast_type.h -typedef enum { - isl_ast_op_error = -1, + # ast_type.h + "isl_ast_op_type": """ + isl_ast_op_error, isl_ast_op_and, isl_ast_op_and_then, isl_ast_op_or, @@ -204,10 +234,10 @@ typedef enum { isl_ast_op_sub, isl_ast_op_mul, isl_ast_op_div, - isl_ast_op_fdiv_q, /* Round towards -infty */ - isl_ast_op_pdiv_q, /* Dividend is non-negative */ - isl_ast_op_pdiv_r, /* Dividend is non-negative */ - isl_ast_op_zdiv_r, /* Result only compared against zero */ + isl_ast_op_fdiv_q, + isl_ast_op_pdiv_q, + isl_ast_op_pdiv_r, + isl_ast_op_zdiv_r, isl_ast_op_cond, isl_ast_op_select, isl_ast_op_eq, @@ -218,45 +248,47 @@ typedef enum { isl_ast_op_call, isl_ast_op_access, isl_ast_op_member, - isl_ast_op_address_of -} isl_ast_op_type; - -typedef enum { - isl_ast_expr_error = -1, + isl_ast_op_address_of, + """, + "isl_ast_expr_type": """ + isl_ast_expr_error, isl_ast_expr_op, isl_ast_expr_id, - isl_ast_expr_int -} isl_ast_expr_type ; - -typedef enum { - isl_ast_node_error = -1, - isl_ast_node_for = 1, + isl_ast_expr_int, + """, + "isl_ast_node_type": """ + isl_ast_node_error, + isl_ast_node_for, isl_ast_node_if, isl_ast_node_block, isl_ast_node_mark, - isl_ast_node_user -} isl_ast_node_type; - -typedef enum { - isl_ast_loop_error = -1, - isl_ast_loop_default = 0, + isl_ast_node_user, + """, + "isl_ast_loop_type": """ + isl_ast_loop_error, + isl_ast_loop_default, isl_ast_loop_atomic, isl_ast_loop_unroll, - isl_ast_loop_separate -} isl_ast_loop_type; + isl_ast_loop_separate, + """, + # polynomial_type.h + "isl_fold": """ + isl_fold_min, + isl_fold_max, + isl_fold_list, + """ + } + +TYPEDEFD_ENUMS = ["isl_stat", "isl_bool"] + +HEADER_PREAMBLE = """ // flow.h typedef int (*isl_access_level_before)(void *first, void *second); typedef isl_restriction *(*isl_access_restrict)( isl_map *source_map, isl_set *sink, void *source_user, void *user); -// polynomial_type.h -typedef enum { - isl_fold_min, - isl_fold_max, - isl_fold_list -} isl_fold; """ PY_PREAMBLE = """ @@ -266,7 +298,7 @@ import six from islpy._isl_cffi import ffi -lib = ffi.dlopen("libisl.so.13") +lib = ffi.dlopen(None) from cffi import FFI libc_ffi = FFI() @@ -368,11 +400,7 @@ CLASS_MAP = { "options": "ctx", } -ENUMS = ["isl_dim_type", "isl_fold", - "isl_ast_op_type", "isl_ast_expr_type", - "isl_ast_node_type", "isl_stat", "isl_error"] - -SAFE_TYPES = ENUMS + ["int", "unsigned", "uint32_t", "size_t", "double", +SAFE_TYPES = list(ENUMS) + ["int", "unsigned", "uint32_t", "size_t", "double", "long", "unsigned long"] SAFE_IN_TYPES = SAFE_TYPES + ["const char *", "char *"] @@ -476,8 +504,8 @@ def parse_arg(arg): return_semantics, ret_words = filter_semantics( arg_match.group(1).split()) - ret_words = [w for w in ret_words if w not in ["struct", "enum"]] - return_base_type, = ret_words + return_decl_words = ret_words[:-1] + return_base_type = ret_words[-1] return_ptr = arg_match.group(2) name = arg_match.group(3) @@ -486,6 +514,7 @@ def parse_arg(arg): return CallbackArgument(name.strip(), return_semantics, + return_decl_words, return_base_type, return_ptr.strip(), args) @@ -493,7 +522,9 @@ def parse_arg(arg): words = arg.split() semantics, words = filter_semantics(words) - words = [w for w in words if w not in ["struct", "enum"]] + decl_words = [] + if words[0] in ["struct", "enum"]: + decl_words.append(words.pop(0)) rebuilt_arg = " ".join(words) arg_match = ARG_RE.match(rebuilt_arg) @@ -507,6 +538,7 @@ def parse_arg(arg): return Argument( name=arg_match.group(3), semantics=semantics, + decl_words=decl_words, base_type=base_type, ptr=arg_match.group(2).strip()) @@ -517,7 +549,11 @@ class FunctionData: self.include_dirs = include_dirs self.seen_c_names = set() + self.headers = [] + def read_header(self, fname): + self.headers.append(fname) + from os.path import join success = False for inc_dir in self.include_dirs: @@ -697,7 +733,9 @@ class FunctionData: words.remove("__isl_constructor") return_semantics, words = filter_semantics(words) - words = [w for w in words if w not in ["struct", "enum"]] + return_decl_words = [] + if words[0] in ["struct", "enum"]: + return_decl_words.append(words.pop(0)) return_base_type = " ".join(words) cls_meth_list = self.classes_to_methods.setdefault(cls, []) @@ -707,7 +745,7 @@ class FunctionData: cls_meth_list.append(Method( cls, name, c_name, - return_semantics, return_base_type, return_ptr, + return_semantics, return_decl_words, return_base_type, return_ptr, args, is_exported=is_exported, is_constructor=is_constructor)) self.seen_c_names.add(c_name) @@ -717,18 +755,35 @@ class FunctionData: # {{{ header writer +def write_enums_to_header(header_f): + for enum_name, value_str in ENUMS.items(): + values = [v.strip() for v in value_str.split(",") if v.strip()] + + if enum_name in TYPEDEFD_ENUMS: + pattern = "typedef enum {{ {values}, ... }} {name};\n" + else: + pattern = "enum {name} {{ {values}, ... }};\n" + + header_f.write( + pattern.format( + name=enum_name, + values=", ".join(values))) + + def write_classes_to_header(header_f): for cls_name in CLASSES: - header_f.write("struct isl_{name}_struct;\n".format(name=cls_name)) - header_f.write( - "typedef struct isl_{name}_struct isl_{name};\n" - .format(name=cls_name)) + header_f.write("struct isl_{name};\n".format(name=cls_name)) + if cls_name not in UNTYPEDEFD_CLASSES: + header_f.write( + "typedef struct isl_{name} isl_{name};\n" + .format(name=cls_name)) def write_method_header(header_f, method): header_f.write( - "{ret_type} {ret_ptr}{name}({args});\n" + "{return_decl_words} {ret_type} {ret_ptr}{name}({args});\n" .format( + return_decl_words=" ".join(method.return_decl_words), ret_type=method.return_base_type, ret_ptr=method.return_ptr, name=method.c_name, @@ -739,6 +794,44 @@ def write_method_header(header_f, method): # {{{ python wrapper writer +def write_enums_to_wrapper(wrapper_f): + gen = PythonCodeGenerator() + + gen("") + gen("# {{{ enums") + gen("") + for enum_name, value_str in ENUMS.items(): + values = [v.strip() for v in value_str.split(",") if v.strip()] + + assert enum_name.startswith("isl_") + name = enum_name[4:] + + if name == "bool": + continue + + from os.path import commonprefix + common_len = len(commonprefix(values)) + + gen("class {name}:".format(name=name)) + with Indentation(gen): + for val in values: + py_name = val[common_len:] + if py_name in PYTHON_RESERVED_WORDS: + py_name += "_" + gen( + "{py_name} = lib.{val}" + .format( + val=val, + py_name=py_name, + )) + + gen("") + + gen("# }}}") + gen("") + wrapper_f.write(gen.get()) + + def write_classes_to_wrapper(wrapper_f): gen = PythonCodeGenerator() @@ -1276,22 +1369,25 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None): else: fdata.read_header("isl_declaration_macros_expanded_v%d.h" % isl_version) + fdata.headers.pop() if include_barvinok: fdata.read_header("barvinok/isl.h") undoc = [] - with open("islpy/wrapped-functions.h", "wt") as header_f: + with open("wrapped-functions.h", "wt") as header_f: with open("islpy/_isl.py", "wt") as wrapper_f: - write_classes_to_header(header_f) header_f.write( "// AUTOMATICALLY GENERATED by gen_wrap.py -- do not edit\n\n") + write_enums_to_header(header_f) + write_classes_to_header(header_f) header_f.write(HEADER_PREAMBLE) wrapper_f.write( "# AUTOMATICALLY GENERATED by gen_wrap.py -- do not edit\n") wrapper_f.write(PY_PREAMBLE) + write_enums_to_wrapper(wrapper_f) write_classes_to_wrapper(wrapper_f) wrapper_gen = PythonCodeGenerator() @@ -1362,17 +1458,33 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None): wrapper_f.write("\n" + wrapper_gen.get()) wrapper_f.write("\n\n# vim: fdm=marker\n") - with open("class_list.py", "wt") as clist_f: + with open("name_list.py", "wt") as clist_f: py_classes = [] for cls_name in CLASSES: py_cls = isl_class_to_py_class(cls_name) py_classes.append(py_cls) clist_f.write("{py_cls} = _isl.{py_cls}\n".format(py_cls=py_cls)) - clist_f.write("\nALL_CLASSES = [{}]\n".format(", ".join(py_classes))) + clist_f.write("\n") + + for enum_name in ENUMS: + py_name = enum_name[4:] + + if py_name == "bool": + continue + + clist_f.write( + "{py_name} = _isl.{py_name}\n" + .format(py_name=py_name) + ) + clist_f.write("\n") + + clist_f.write("ALL_CLASSES = [{}]\n".format(", ".join(py_classes))) print("SKIP (%d undocumented methods): %s" % (len(undoc), ", ".join(undoc))) + return fdata.headers + if __name__ == "__main__": from os.path import expanduser gen_wrapper([expanduser("isl/include")]) diff --git a/islpy/__init__.py b/islpy/__init__.py index 098e71e..4b2869a 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -1,5 +1,26 @@ from __future__ import division, absolute_import +__copyright__ = "Copyright (C) 2011-15 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" import islpy._isl as _isl from islpy.version import VERSION, VERSION_TEXT # noqa @@ -9,7 +30,7 @@ from six.moves import range Error = _isl.Error -# {{{ generated by gen_wrap as class_list.py +# {{{ generated by gen_wrap as name_list.py Options = _isl.Options Context = _isl.Context @@ -75,6 +96,15 @@ AstNode = _isl.AstNode AstPrintOptions = _isl.AstPrintOptions AstBuild = _isl.AstBuild +stat = _isl.stat +fold = _isl.fold +dim_type = _isl.dim_type +error = _isl.error +ast_expr_type = _isl.ast_expr_type +ast_loop_type = _isl.ast_loop_type +ast_node_type = _isl.ast_node_type +ast_op_type = _isl.ast_op_type + ALL_CLASSES = [Options, Context, IdList, ValList, BasicSetList, BasicMapList, SetList, MapList, UnionSetList, ConstraintList, AffList, PwAffList, BandList, AstExprList, AstNodeList, IdToAstExpr, Printer, Val, @@ -90,16 +120,6 @@ ALL_CLASSES = [Options, Context, IdList, ValList, BasicSetList, BasicMapList, # }}} -class dim_type: # noqa - cst = _isl.lib.isl_dim_cst - param = _isl.lib.isl_dim_param - in_ = _isl.lib.isl_dim_in - out = _isl.lib.isl_dim_out - set = _isl.lib.isl_dim_set - div = _isl.lib.isl_dim_div - all = _isl.lib.isl_dim_all - - _CHECK_DIM_TYPES = [ dim_type.in_, dim_type.param, dim_type.set] diff --git a/islpy/_isl_build.py b/islpy/_isl_build.py deleted file mode 100644 index 5822879..0000000 --- a/islpy/_isl_build.py +++ /dev/null @@ -1,12 +0,0 @@ -from cffi import FFI - -ffi = FFI() -ffi.set_source("_isl_cffi", None) - -with open("wrapped-functions.h", "rt") as header_f: - header = header_f.read() - -ffi.cdef(header) - -if __name__ == "__main__": - ffi.compile() diff --git a/setup.py b/setup.py index 47217eb..4b57aaf 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,27 @@ #!/usr/bin/env python +__copyright__ = "Copyright (C) 2011-15 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + def get_config_schema(): from aksetup_helper import (ConfigSchema, @@ -30,21 +52,63 @@ def get_config_schema(): ]) +CFFI_TEMPLATE = """ +from cffi import FFI + +EXTRA_DEFINES = {EXTRA_DEFINES} + +INCLUDES = ''' +{INCLUDES} +''' + +ffi = FFI() +ffi.set_source( + "islpy._isl_cffi", + INCLUDES, + define_macros=list(EXTRA_DEFINES.items()), + sources={EXTRA_SOURCES}, + include_dirs={INCLUDE_DIRS}, + library_dirs={LIBRARY_DIRS}, + libraries={LIBRARIES}, + extra_compile_args={CFLAGS}, + extra_link_args={LDFLAGS}) + + +with open("wrapped-functions.h", "rt") as header_f: + header = header_f.read() + +ffi.cdef(header) + +if __name__ == "__main__": + ffi.compile() +""" + + +def write_cffi_build_script(headers, **kwargs): + format_args = dict((k, repr(v)) for k, v in kwargs.items()) + + format_args["INCLUDES"] = "\n".join( + "#include <%s>" % header + for header in headers) + + with open("islpy_cffi_build.py", "wt") as outf: + outf.write(CFFI_TEMPLATE.format(**format_args)) + + def main(): from aksetup_helper import (hack_distutils, - get_config, setup, Extension, - check_git_submodules) + get_config, setup, check_git_submodules) check_git_submodules() hack_distutils(what_opt=None) conf = get_config(get_config_schema(), warn_about_no_config=False) - EXTRA_OBJECTS = [] # noqa - EXTRA_DEFINES = [] # noqa - INCLUDE_DIRS = conf["BOOST_INC_DIR"] + ["src/wrapper"] # noqa - LIBRARY_DIRS = conf["BOOST_LIB_DIR"] # noqa - LIBRARIES = conf["BOOST_PYTHON_LIBNAME"] # noqa + EXTRA_SOURCES = [] # noqa + EXTRA_DEFINES = {} # noqa + INCLUDE_DIRS = [] # noqa + LIBRARY_DIRS = [] # noqa + LIBRARIES = [] # noqa if conf["USE_SHIPPED_ISL"]: from glob import glob @@ -86,12 +150,12 @@ def main(): inf.close() if "int main(" not in contents and not blacklisted: - EXTRA_OBJECTS.append(fn) + EXTRA_SOURCES.append(fn) conf["ISL_INC_DIR"] = ["isl-supplementary", "isl/include", "isl"] if conf["USE_SHIPPED_IMATH"]: - EXTRA_OBJECTS.extend([ + EXTRA_SOURCES.extend([ "isl/imath/imath.c", "isl/imath/imrat.c", "isl/imath/gmp_compat.c", @@ -143,9 +207,20 @@ def main(): exec(compile(open(init_filename, "r").read(), init_filename, "exec"), conf) from gen_wrap import gen_wrapper - gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"], + headers = gen_wrapper(wrapper_dirs, include_barvinok=conf["USE_BARVINOK"], isl_version=EXTRA_DEFINES.get("ISLPY_ISL_VERSION")) + write_cffi_build_script( + headers, + EXTRA_DEFINES=EXTRA_DEFINES, + EXTRA_SOURCES=EXTRA_SOURCES, + INCLUDE_DIRS=INCLUDE_DIRS, + LIBRARY_DIRS=LIBRARY_DIRS, + LIBRARIES=LIBRARIES, + CFLAGS=conf["CXXFLAGS"], + LDFLAGS=conf["LDFLAGS"] + ) + setup(name="islpy", version=conf["VERSION_TEXT"], description="Wrapper around isl, an integer set library", @@ -181,30 +256,14 @@ def main(): packages=["islpy"], setup_requires=["cffi>=1.1.0"], - cffi_modules=["simple_example_build.py:ffi"], + cffi_modules=["islpy_cffi_build.py:ffi"], install_requires=[ "pytest>=2", "cffi>=1.1.0", # "Mako>=0.3.6", "six", ], - ext_modules=[ - Extension( - "islpy._isl", - [ - "src/wrapper/wrap_isl.cpp", - "src/wrapper/wrap_isl_part1.cpp", - "src/wrapper/wrap_isl_part2.cpp", - "src/wrapper/wrap_isl_part3.cpp", - ] + EXTRA_OBJECTS, - include_dirs=INCLUDE_DIRS, - library_dirs=LIBRARY_DIRS, - libraries=LIBRARIES, - define_macros=list(EXTRA_DEFINES.items()), - extra_compile_args=conf["CXXFLAGS"], - extra_link_args=conf["LDFLAGS"], - ), - ]) + ) if __name__ == '__main__': diff --git a/test/test_isl.py b/test/test_isl.py index 4f7a9cf..2a160fe 100644 --- a/test/test_isl.py +++ b/test/test_isl.py @@ -1,5 +1,27 @@ from __future__ import division, print_function +__copyright__ = "Copyright (C) 2011-15 Andreas Kloeckner" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + import islpy as isl @@ -36,7 +58,7 @@ def test_error_on_invalid_index(): p = my_set.sample_point() try: p.get_coordinate_val(isl.dim_type.set, 99999999) - except RuntimeError: + except isl.Error: pass else: assert False -- GitLab