diff --git a/pyproject.toml b/pyproject.toml index 9fddfd5..c44efab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,10 @@ before-build = "bash {project}/tools/cibw_macos.sh" environment = { CC="/usr/local/opt/llvm/bin/clang", CXX="/usr/local/opt/llvm/bin/clang++" } [tool.cibuildwheel.windows] -# before-build = "sh tools/cibw_windows.sh" -before-build = "choco install rtools -y --no-progress --force --version=4.0.0.20220206 && set PATH=C:\\rtools40\\ucrt64\\bin\\;%PATH%" -environment = { PKG_CONFIG_PATH="C:/opt/64/lib/pkgconfig", CXX="g++", CC="gcc" } \ No newline at end of file +before-build = "bash {project}/tools/cibw_windows.sh" +# before-build = "choco install rtools -y --no-progress --force --version=4.0.0.20220206 && set PATH=C:\\rtools40\\ucrt64\\bin\\;%PATH%" +environment = { PKG_CONFIG_PATH="C:/opt/64/lib/pkgconfig", CXX="g++", CC="gcc" } +repair-wheel-command = "bash ./tools/wheels/repair_windows.sh {wheel} {dest_dir}" + +[tool.cibuildwheel.linux] +environment = { CC="clang", CXX="clang++" } \ No newline at end of file diff --git a/tools/repair_windows.sh b/tools/repair_windows.sh new file mode 100644 index 0000000..c16773e --- /dev/null +++ b/tools/repair_windows.sh @@ -0,0 +1,29 @@ +set -xe + +WHEEL="$1" +DEST_DIR="$2" + +# create a temporary directory in the destination folder and unpack the wheel into there +pushd $DEST_DIR +mkdir -p tmp +pushd tmp +wheel unpack $WHEEL +pushd primate* + +# To avoid DLL hell, the file name of libopenblas that's being vendored with +# the wheel has to be name-mangled. delvewheel is unable to name-mangle PYD +# containing extra data at the end of the binary, which frequently occurs when +# building with mingw. +# We therefore find each PYD in the directory structure and strip them. +for f in $(find ./primate* -name '*.pyd'); do strip $f; done + + +# now repack the wheel and overwrite the original +wheel pack . +mv -fv *.whl $WHEEL + +cd $DEST_DIR +rm -rf tmp + +# the libopenblas.dll is placed into this directory in the cibw_before_build script. +delvewheel repair -w $DEST_DIR $WHEEL \ No newline at end of file