Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: use msys2-ucrt instead of msys2-mingw64 #41

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)))"
Expand Down
8 changes: 5 additions & 3 deletions bin/cibw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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)))"

Expand Down
10 changes: 9 additions & 1 deletion bin/cibw_before_all_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions bin/cibw_before_build_windows.bat
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions bin/cibw_before_build_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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`
Expand All @@ -40,4 +45,4 @@ mv libpython${VER}.a libs
# Install build dependencies #
###################################################

pip install Cython numpy delvewheel
pip install Cython numpy delvewheel wheel
5 changes: 5 additions & 0 deletions bin/cibw_repair_wheel_command_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 15 additions & 2 deletions bin/cibw_repair_wheel_command_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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