| 1 | #!/bin/bash |
| 2 | |
| 3 | ####### Build biosig wheels for windows 64bit ################################## |
| 4 | # |
| 5 | # Copyright 2024-2026 Alois Schloegl <[email protected]> |
| 6 | # This file is part of the "BioSig for C/C++" repository |
| 7 | # (biosig4c++) at http://biosig.sf.net/ |
| 8 | # |
| 9 | ################################################################################ |
| 10 | |
| 11 | # WINE=~/mywine-ea/bin/wine |
| 12 | if [ -z "$WINE" ]; then |
| 13 | export WINE="wine" |
| 14 | fi |
| 15 | if [ -z "$WINEPREFIX" ]; then |
| 16 | export WINEPREFIX=${HOME}/.wine |
| 17 | fi |
| 18 | ### install (multiple versions of) python in wine prefix ### |
| 19 | |
| 20 | |
| 21 | if [ -z "$MXEBASE" ]; then |
| 22 | ### needs to point to local clone of https://github.com/schloegl/mxe |
| 23 | export MXEBASE=${HOME}/src/mxe.schloegl |
| 24 | fi |
| 25 | |
| 26 | ## make sure mingw-gcc, libbiosig.dll, libbiosig.dll.a are available |
| 27 | (cd ${MXEBASE} && MXE_TARGETS=x86_64-w64-mingw32.static make biosig) |
| 28 | |
| 29 | # mask calls to cl.exe and link.exe |
| 30 | ${MXEBASE}/usr/bin/x86_64-w64-mingw32.static-gcc hello.c -o ${WINEPREFIX}/drive_c/windows/cl.exe |
| 31 | ${MXEBASE}/usr/bin/x86_64-w64-mingw32.static-gcc hello.c -o ${WINEPREFIX}/drive_c/windows/link.exe |
| 32 | |
| 33 | # cd src/biosig-code/biosig4c++/python |
| 34 | for PYVER in ${WINEPREFIX}/drive_c/"Program Files"/Python* ; do |
| 35 | VER="${PYVER/*Python/}" |
| 36 | ${WINE} "${PYVER}"/python.exe -m pip install build matplotlib numpy setuptools wheel |
| 37 | ### build dummy wheels ### |
| 38 | ${WINE} "${PYVER}"/python.exe -m build --wheel |
| 39 | |
| 40 | ${MXEBASE}/usr/bin/x86_64-w64-mingw32.static-gcc -mdll biosigmodule.c \ |
| 41 | -o build/lib.win-amd64-cpython-${VER}/biosig.cp${VER}-win_amd64.pyd \ |
| 42 | -I"${PYVER}"/Lib/site-packages/numpy/_core/include \ |
| 43 | -I"${PYVER}"/Lib/site-packages/numpy/core/include \ |
| 44 | -I"${PYVER}"/include \ |
| 45 | -L"${PYVER}"/libs/ \ |
| 46 | -L${MXEBASE}/usr/x86_64-w64-mingw32.static/lib/ \ |
| 47 | -lpython3 -lbiosig -lws2_32 -ltinyxml -liconv -lstdc++ |
| 48 | |
| 49 | cp ${MXEBASE}/usr/x86_64-w64-mingw32.static/lib/libbiosig.a build/lib.win-amd64-cpython-${VER}/ |
| 50 | |
| 51 | ### build real wheel in dist/Biosig*.whl ### |
| 52 | ${WINE} "${PYVER}"/python.exe -m build --wheel |
| 53 | done |
| 54 |