diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 885e6f8ae551a3dbf765226c808731235def3c99..3c1d3c7438398f3239b9b5e5dc9dd12acb76948a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,16 +29,6 @@ Python 3.5 small integer opt: except: - tags -Python 2.6: - script: - - export PY_EXE=python2.6 - - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - - ". ./build-and-test-py-project.sh" - tags: - - python2.6 - except: - - tags - Python 3.6 + Barvinok: script: - git clean -fdx diff --git a/gen_wrap.py b/gen_wrap.py index cbbe940a1921e46675e50af14d8cbb17d7ddbebc..018fc821c36acda95620791b69982391bb5f6602 100644 --- a/gen_wrap.py +++ b/gen_wrap.py @@ -25,6 +25,7 @@ THE SOFTWARE. import re import sys from py_codegen import PythonCodeGenerator, Indentation +from distutils.sysconfig import get_config_var SEM_TAKE = "take" SEM_GIVE = "give" @@ -360,18 +361,32 @@ import threading _PY3 = sys.version_info >= (3,) +is_win = sys.platform.startswith('win32') from islpy._isl_cffi import ffi -lib = ffi.dlopen(None) + +if is_win: + lib = ffi.dlopen('{win_pyd}') +else: + lib = ffi.dlopen(None) from cffi import FFI libc_ffi = FFI() -libc_ffi.cdef(''' + +cdef_string = ''' char *strdup(const char *s); void free(void *ptr); - ''') + ''' -libc = libc_ffi.dlopen(None) +if is_win: + cdef_string = cdef_string.replace('strdup', '_strdup') + +libc_ffi.cdef(cdef_string) + +if is_win and sys.version_info >= (3,5): + libc = libc_ffi.dlopen('ucrtbase') +else: + libc = libc_ffi.dlopen(None) class Error(Exception): @@ -381,7 +396,7 @@ class Error(Exception): class IslTypeError(Error, TypeError): pass -_context_use_map = {} +_context_use_map = {{}} def _deref_ctx(ctx_data, ctx_iptr): _context_use_map[ctx_iptr] -= 1 @@ -465,7 +480,10 @@ class _EnumBase(object): class _ManagedCString(object): def __init__(self, cdata): - self.data = libc.strdup(cdata) + if is_win: + self.data = libc._strdup(cdata) + else: + self.data = libc.strdup(cdata) if self.data == libc_ffi.NULL: raise Error("strdup() failed") @@ -1624,7 +1642,11 @@ def gen_wrapper(include_dirs, include_barvinok=False, isl_version=None): wrapper_f.write( "# AUTOMATICALLY GENERATED by gen_wrap.py -- do not edit\n") - wrapper_f.write(PY_PREAMBLE) + win_ext_suffix = get_config_var('EXT_SUFFIX') + if win_ext_suffix is None: + win_ext_suffix = ".pyd" + win_pyd = "_isl_cffi{}".format(win_ext_suffix) + wrapper_f.write(PY_PREAMBLE.format(win_pyd=win_pyd)) write_enums_to_wrapper(wrapper_f) write_classes_to_wrapper(wrapper_f) diff --git a/setup.py b/setup.py index 6cc8bb3e794fd7786c912bc5fdd91d153dc30030..ab16279f2f88f8b5308f8fbbf44a3b859386aaaa 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ def get_config_schema(): return ConfigSchema([ Switch("USE_SHIPPED_ISL", True, "Use included copy of isl"), Switch("USE_SHIPPED_IMATH", True, "Use included copy of imath in isl"), + Switch("USE_GMP", True, "Use gmp in external isl"), Switch("USE_BARVINOK", False, "Include wrapper for Barvinok"), Switch("USE_IMATH_SIO", False, "When using imath, use small-integer " "optimization"), @@ -236,7 +237,8 @@ def main(): INCLUDE_DIRS.extend(conf["ISL_INC_DIR"]) - if not (conf["USE_SHIPPED_ISL"] and conf["USE_SHIPPED_IMATH"]): + if not (conf["USE_SHIPPED_ISL"] and conf["USE_SHIPPED_IMATH"]) and \ + conf["USE_GMP"]: INCLUDE_DIRS.extend(conf["GMP_INC_DIR"]) LIBRARY_DIRS.extend(conf["GMP_LIB_DIR"]) LIBRARIES.extend(conf["GMP_LIBNAME"]) @@ -281,11 +283,12 @@ def main(): 'Natural Language :: English', 'Programming Language :: C++', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Multimedia :: Graphics :: 3D Modeling',