diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index f8b4dd13..18fa1d8e 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -21,14 +21,19 @@ jobs: - uses: msys2/setup-msys2@v2 with: - msystem: mingw64 + msystem: ucrt64 # path-type inherit is used so that when cibuildwheel calls msys2 to # run bin/cibw_before_build_windows.sh the virtual environment # created by cibuildwheel will be available within msys2. The # msys2/setup-msys2 README warns that using inherit here can be # problematic in some situations. Maybe there is a better way to do # this. - path-type: inherit + #path-type: inherit + install: >- + m4 + make + mingw-w64-ucrt-x86_64-gcc + mingw-w64-ucrt-x86_64-tools-git if: ${{ matrix.os == 'windows-2019' }} - name: Build wheels @@ -42,13 +47,14 @@ jobs: CIBW_BEFORE_ALL_LINUX: bin/cibw_before_all_linux.sh CIBW_BEFORE_ALL_MACOS: bin/cibw_before_all_macosx.sh CIBW_BEFORE_ALL_WINDOWS: msys2 -c bin/cibw_before_all_windows.sh - CIBW_BEFORE_BUILD_WINDOWS: msys2 -c bin/cibw_before_build_windows.sh + CIBW_BEFORE_BUILD_WINDOWS: bin\cibw_before_build_windows.bat CIBW_BEFORE_BUILD: pip install numpy cython delvewheel CIBW_ENVIRONMENT: > C_INCLUDE_PATH=$(pwd)/.local/include/ LIBRARY_PATH=$(pwd)/.local/lib/ LD_LIBRARY_PATH=$(pwd)/.local/lib:$LD_LIBRARY_PATH PYTHON_FLINT_MINGW64=true + MSYSTEM=UCRT64 CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >- bin\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel} CIBW_TEST_COMMAND: python -c "import flint; print(str(flint.fmpz(2)))" diff --git a/bin/cibw.bat b/bin/cibw.bat index a21ebb6d..28dc63dd 100644 --- a/bin/cibw.bat +++ b/bin/cibw.bat @@ -23,9 +23,11 @@ del /q wheelhouse\* set CIBW_BUILD=cp39-* cp310-* cp311-* set CIBW_SKIP=*-win32 *-manylinux_i686 *-musllinux_* -set CIBW_BEFORE_ALL_WINDOWS=C:\msys64\usr\bin\bash bin/cibw_before_all_windows.sh -set CIBW_BEFORE_BUILD_WINDOWS=C:\msys64\usr\bin\bash bin/cibw_before_build_windows.sh -set CIBW_ENVIRONMENT=PYTHON_FLINT_MINGW64=true +set CIBW_BEFORE_ALL_WINDOWS=msys2 -c bin/cibw_before_all_windows.sh +set CIBW_BEFORE_BUILD_WINDOWS=bin\cibw_before_build_windows.bat +set CIBW_ENVIRONMENT=^ + PYTHON_FLINT_MINGW64=true ^ + MSYSTEM=UCRT64 set CIBW_REPAIR_WHEEL_COMMAND_WINDOWS=bin\cibw_repair_wheel_command_windows.bat {dest_dir} {wheel} set CIBW_TEST_COMMAND=python -c "import flint; print(str(flint.fmpz(2)))" diff --git a/bin/cibw_before_all_windows.sh b/bin/cibw_before_all_windows.sh index ea2f8a89..df96936b 100755 --- a/bin/cibw_before_all_windows.sh +++ b/bin/cibw_before_all_windows.sh @@ -13,8 +13,16 @@ echo '[build]' > setup.cfg echo 'compiler = mingw32' >> setup.cfg cat setup.cfg +echo "NEED UCRT64 gcc:" +which gcc + +echo $PATH + # Install the mingw-w64 toolchain -pacman -S --noconfirm mingw-w64-x86_64-gcc m4 make mingw-w64-x86_64-tools-git +# pacman -S --noconfirm mingw-w64-x86_64-gcc m4 make mingw-w64-x86_64-tools-git + +# Install the mingw-ucrt toolchain +# pacman -S --noconfirm mingw-w64-ucrt-x86_64-gcc m4 make mingw-w64-ucrt-x86_64-tools-git # This takes ~30mins bin/build_dependencies_unix.sh diff --git a/bin/cibw_before_build_windows.bat b/bin/cibw_before_build_windows.bat new file mode 100644 index 00000000..ff45fb4d --- /dev/null +++ b/bin/cibw_before_build_windows.bat @@ -0,0 +1,6 @@ +SET +FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys, os; print(os.path.dirname(sys.executable))"`) DO ( + SET VIRTUAL_ENV_BIN=%%F +) +echo %VIRTUAL_ENV_BIN% +msys2 -c bin/cibw_before_build_windows.sh diff --git a/bin/cibw_before_build_windows.sh b/bin/cibw_before_build_windows.sh index d0410b35..a3966127 100644 --- a/bin/cibw_before_build_windows.sh +++ b/bin/cibw_before_build_windows.sh @@ -5,6 +5,10 @@ set -o errexit # Uncomment this to run cibuildwheel locally on Windows: # export PATH=$PATH:/c/msys64/usr/bin:/c/msys64/mingw64/bin +# msys2 will not inherit the PATH for the virtual environment +export PATH=$PATH:$(cygpath ${VIRTUAL_ENV_BIN}) +echo PATH=$PATH + # VER should be set be e.g. 310 for Python 3.10 VER=`python -c 'import sys; print("%s%s" % sys.version_info[:2])'` echo VER=${VER} @@ -14,7 +18,8 @@ echo VER=${VER} ################################################### which python -PYTHONBIN=`dirname $(which python)` +PYTHONBIN=$VIRTUAL_ENV_BIN +echo PYTHONBIN=$PYTHONBIN PYTHONDIR=`dirname $PYTHONBIN` cfgfile=$PYTHONDIR/pyvenv.cfg homeline=`grep home $cfgfile` @@ -40,4 +45,4 @@ mv libpython${VER}.a libs # Install build dependencies # ################################################### -pip install Cython numpy delvewheel +pip install Cython numpy delvewheel wheel diff --git a/bin/cibw_repair_wheel_command_windows.bat b/bin/cibw_repair_wheel_command_windows.bat index 00e7d151..b136f171 100644 --- a/bin/cibw_repair_wheel_command_windows.bat +++ b/bin/cibw_repair_wheel_command_windows.bat @@ -9,5 +9,10 @@ set tempfile=tmpfile.deleteme set WHEELHOUSE=%1 set WHEELNAME=%2 +FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "import sys, os; print(os.path.dirname(sys.executable))"`) DO ( + SET VIRTUAL_ENV_BIN=%%F +) +echo %VIRTUAL_ENV_BIN% + msys2 -c bin/cibw_repair_wheel_command_windows.sh rem C:\msys64\usr\bin\bash bin/cibw_repair_wheel_command_windows.sh diff --git a/bin/cibw_repair_wheel_command_windows.sh b/bin/cibw_repair_wheel_command_windows.sh index c4827867..bb02d73f 100755 --- a/bin/cibw_repair_wheel_command_windows.sh +++ b/bin/cibw_repair_wheel_command_windows.sh @@ -9,6 +9,18 @@ set -o errexit # Uncomment this to run cibuildwheel locally on Windows: # export PATH=$PATH:/c/msys64/usr/bin:/c/msys64/mingw64/bin +# msys2 will not inherit the PATH for the virtual environment in CI +export PATH=$PATH:$(cygpath ${VIRTUAL_ENV_BIN}) +echo PATH=$PATH + +echo of VIRTUAL_ENV_BIN=$VIRTUAL_ENV_BIN +echo Contents of VIRTUAL_ENV_BIN: +ls $VIRTUAL_ENV_BIN + +which pip +which wheel +pip list + # We cannot use ordinary command line arguments in CI because msys2 -c mangles # them. Instead we have a batch file to receive the arguments and convert them # into environment variables before calling this script. When running locally @@ -46,5 +58,6 @@ popd # --no-mangle if strip has not been applied to all mingw64-created .dll and # .pyd files that are needed for the wheel. delvewheel repair $WHEELNAME \ - -w $WHEELHOUSE \ - --add-path .local/bin:.local/lib/ + -vv \ + -w $WHEELHOUSE \ + --add-path .local/bin:.local/lib/:/c/msys64/ucrt64/bin