-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: add CI jobs to build and test a Windows wheel
- Loading branch information
1 parent
4f73923
commit dfa430a
Showing
3 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
# | ||
# make_wheels.sh | ||
# | ||
# Build relocatable Windows wheel for python_flint using the mingw-w64 | ||
# toolchain in the MSYS2 enironment. | ||
# | ||
# - First install Python | ||
# | ||
# https://www.python.org/ftp/python/3.10.8/python-3.10.8-amd64.exe | ||
# | ||
# - Then checkout the code: | ||
# | ||
# $ git clone https://github.com/fredrik-johansson/python-flint/issues/1 | ||
# | ||
# - Then install msys2 | ||
# | ||
# https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20221028.exe | ||
# | ||
# - Then open msys2, cd into the checked out repo. Make sure setup.py says | ||
# | ||
# libraries = ["arb", "flint", "mpfr", "gmp"] | ||
# | ||
# - Set the environment variable to the directory containing the installed | ||
# Python that we want to build a wheel for i.e. the one installed from | ||
# python.org. If python was on PATH then it would be | ||
# | ||
# PYTHONDIR=`dirname $(which python)` | ||
# | ||
# - Then run this script. | ||
|
||
set -o errexit | ||
|
||
# | ||
# In CI this environment variable needs to be set to the directory containing | ||
# the python.org installation of Python. If Python is installed in msys2 then | ||
# it is also necesary to set this environment variable so that it picks up the | ||
# right installation of Python i.e. the one that we want to build a wheel for. | ||
# | ||
if [[ -z "$PYTHONDIR" ]]; then | ||
PYTHONDIR=`dirname $(which python)` | ||
fi | ||
PYTHON=$PYTHONDIR/python | ||
|
||
WHEELNAME=python_flint-0.3.0-cp310-cp310-win_amd64.whl | ||
|
||
$PYTHON -c 'print("hello world")' | ||
|
||
echo $PYTHONDIR | ||
ls $PYTHONDIR | ||
ls $PYTHONDIR/libs | ||
|
||
# Install the mingw-w64 toolchain | ||
pacman -S --noconfirm mingw-w64-x86_64-gcc m4 make mingw-w64-x86_64-tools-git | ||
|
||
# This takes ~1hr | ||
bin/build_dependencies_unix.sh | ||
|
||
# Add the libpython310.a file to Python installation | ||
cd $PYTHONDIR | ||
gendef python310.dll | ||
dlltool --dllname python310.dll --def python310.def --output-lib libpython310.a | ||
mv libpython310.a libs | ||
cd - | ||
|
||
# Make a virtual environment to install the build dependencies | ||
$PYTHON -m venv .local/venv | ||
source .local/venv/Scripts/activate | ||
pip install numpy cython wheel delvewheel | ||
|
||
# Build the wheel | ||
C_INCLUDE_PATH=.local/include/ LIBRARY_PATH=.local/lib/ python setup.py build_ext -cmingw32 -f bdist_wheel | ||
|
||
# Make the wheel relocatable | ||
delvewheel repair dist/python_flint-0.3.0-cp310-cp310-win_amd64.whl \ | ||
--add-path .local/bin:.local/lib/ \ | ||
'--no-mangle=libflint-17.dll;libarb-2.dll;libgmp-10.dll;libmpfr-6.dll;libgcc_s_seh-1.dll' | ||
|
||
# Make a virtual enironment to test the wheel | ||
# | ||
# $PYTHON -m venv test_env | ||
# source test_env/Scripts/activate | ||
# pip install wheelhouse/$WHEELNAME | ||
# python -c 'import flint; print(flint.fmpz(2) + 2)' # 2 + 2 = 4? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters