From 5c3745ec967774c4e59f1a88a7689f41dfb8666e Mon Sep 17 00:00:00 2001 From: dekken Date: Sun, 29 Sep 2019 14:27:30 +0200 Subject: [PATCH] call import_array statically for linux/mac / use rpath on linux for auditwheel --- lib/swig/tick/array/array_module.i | 10 ++++++++++ setup.py | 6 +++++- tools/docker/build_wheels.sh | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/swig/tick/array/array_module.i b/lib/swig/tick/array/array_module.i index e27962b77..c8df3e15c 100644 --- a/lib/swig/tick/array/array_module.i +++ b/lib/swig/tick/array/array_module.i @@ -9,9 +9,19 @@ #include #include "numpy/arrayobject.h" #include "numpy/npy_math.h" + +#ifndef _WIN32 +int tick_import_numpy(){ + return _import_array(); +} +static const int tick_numpy_import = tick_import_numpy(); +#endif + #include "tick/base/debug.h" #include "tick/array/carray_python.h" #include "tick/array/vector_operations.h" + + %} diff --git a/setup.py b/setup.py index db3c6df0a..6418f3674 100644 --- a/setup.py +++ b/setup.py @@ -353,7 +353,11 @@ def add_dir_name(dir_name, filenames): lib = os.path.join(build_dir, mod.build, "_"+mod.extension_name) lib += os.path.splitext(sysconfig.get_config_var("EXT_SUFFIX"))[0] libraries.append(lib) - # names (i.e. not lib.so) we specify the full library path + elif platform.system() == 'Linux': + lib_dir = os.path.abspath(os.path.join(build_dir, mod.build)) + extra_link_args.append("-L"+lib_dir) + extra_link_args.append("-Wl,-rpath,"+lib_dir) + extra_link_args.append("-l:"+mod.lib_filename) else: extra_link_args.append(os.path.abspath( os.path.join(build_dir, mod.build, mod.lib_filename))) diff --git a/tools/docker/build_wheels.sh b/tools/docker/build_wheels.sh index 58937e6fc..c13947b59 100755 --- a/tools/docker/build_wheels.sh +++ b/tools/docker/build_wheels.sh @@ -2,14 +2,14 @@ set -e -x -python_versions=(cp36-cp36m) +python_versions=(cp36-cp36m cp37-cp37m) for PYVER in ${python_versions[@]}; do PYBIN=/opt/python/${PYVER}/bin cd /io - - "${PYBIN}/python3" -mpip install -r requirements.txt + "${PYBIN}/python3" -m pip install pip --upgrade + "${PYBIN}/python3" -m pip install -r requirements.txt "${PYBIN}/python3" setup.py bdist_wheel --dist-dir=/tick/wheelhouse done