From 34ddffdce3f1b4b400a23eb6234647e2a8ec1393 Mon Sep 17 00:00:00 2001 From: Massoud Mazar Date: Tue, 26 Apr 2022 14:50:49 -0700 Subject: [PATCH] Initial commit --- .github/workflows/buildwheel.yml | 25 ++++ bin/build_dependencies_unix.sh | 2 +- bin/build_dependencies_windows.sh | 214 ++++++++++++++++++++++++++++++ bin/cibw_before_build_windows.sh | 6 + setup.py | 2 +- 5 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 bin/build_dependencies_windows.sh create mode 100644 bin/cibw_before_build_windows.sh diff --git a/.github/workflows/buildwheel.yml b/.github/workflows/buildwheel.yml index 2b2da417..898b58d6 100644 --- a/.github/workflows/buildwheel.yml +++ b/.github/workflows/buildwheel.yml @@ -35,6 +35,31 @@ jobs: with: path: wheelhouse/*.whl + windows_wheels: + name: Build wheels for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-2019] + + steps: + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: git mingw-w64-x86_64-cc patch m4 lzip curl tar make diffutils unzip + - uses: actions/checkout@v3 + - name: Checkout ARB repo + uses: actions/checkout@v3 + with: + repository: fredrik-johansson/arb + path: arb + - name: Build Dependencies + shell: msys2 {0} + run: bin/cibw_before_build_windows.sh + test_wheels: needs: build_wheels name: Test ${{ matrix.python-version }} wheel on ${{ matrix.os }} diff --git a/bin/build_dependencies_unix.sh b/bin/build_dependencies_unix.sh index 6ff7117e..8437e1b2 100755 --- a/bin/build_dependencies_unix.sh +++ b/bin/build_dependencies_unix.sh @@ -80,7 +80,7 @@ if [ $USE_GMP = "gmp" ]; then --enable-fat\ --enable-shared=yes\ --enable-static=no\ - --host=$HOSTARG + --host=$HOST_ARG make -j3 make install cd .. diff --git a/bin/build_dependencies_windows.sh b/bin/build_dependencies_windows.sh new file mode 100644 index 00000000..f74bd115 --- /dev/null +++ b/bin/build_dependencies_windows.sh @@ -0,0 +1,214 @@ +#!/usr/bin/env bash +# +# Build local installs of python-flint's dependencies. This should be run +# before attempting to build python-flint itself. + +set -o errexit + +# ------------------------------------------------------------------------- # +# # +# Supported options: # +# # +# --gmp gmp - build based on GMP (default) # +# --gmp mpir - build based on MPIR (instead of GMP) # +# # +# ------------------------------------------------------------------------- # + +USE_GMP=gmp + +while [[ $# -gt 0 ]] +do + key="$1" + case $key in + -h|--help) + echo "bin/download_dependencies.sh [--gmp gmp|mpir] [--host HOST] [--with-pic]" + exit + ;; + --gmp) + # e.g. --gmp gmp or --gmp mpir + USE_GMP="$2" + if [[ "$USE_GMP" != "gmp" && "$USE_GMP" != "mpir" ]]; then + echo "--gmp option should be gmp or mpir" + exit 1 + fi + shift + shift + ;; + --host) + # e.g. --host x86_64-unknown-linux-gnu + # or --host x86_64-apple-darwin + HOST_ARG="$2" + shift + shift + ;; + --pic) + WITH_PIC="--with-pic" + shift + ;; + esac +done + + +# ------------------------------------------------------------------------- # +# # +# The build_variables.sh script sets variables specifying the versions to # +# use for all dependencies and also the PREFIX variable. # +# # +# ------------------------------------------------------------------------- # + +source bin/build_variables.sh + +cd $PREFIX +mkdir -p src +cd src + +# ------------------------------------------------------------------------- # +# # +# Now build all dependencies. # +# # +# ------------------------------------------------------------------------- # + +if [ $USE_GMP = "gmp" ]; then + + # ----------------------------------------------------------------------- # + # # + # GMP # + # # + # ----------------------------------------------------------------------- # + + curl -O https://gmplib.org/download/gmp/gmp-$GMPVER.tar.xz + tar xf gmp-$GMPVER.tar.xz + cd gmp-$GMPVER + # Show the output of configfsf.guess + ./configfsf.guess + ./configure --prefix=$PREFIX\ + --enable-fat\ + --enable-shared=yes\ + --enable-static=no\ + --host=$HOST_ARG\ + $WITH_PIC + make -j3 + make install + cd .. + + FLINTARB_WITHGMP="--with-gmp=$PREFIX" + +else + + # ----------------------------------------------------------------------- # + # # + # YASM (needed to build MPIR) # + # # + # ----------------------------------------------------------------------- # + + curl -O http://www.tortall.net/projects/yasm/releases/yasm-$YASMVER.tar.gz + tar xf yasm-$YASMVER.tar.gz + cd yasm-$YASMVER + ./configure --prefix=$PREFIX + make -j3 + make install + cd .. + + # ----------------------------------------------------------------------- # + # # + # MPIR # + # # + # ----------------------------------------------------------------------- # + + curl -O http://mpir.org/mpir-$MPIRVER.tar.bz2 + tar xf mpir-$MPIRVER.tar.bz2 + cd mpir-$MPIRVER + ./configure --prefix=$PREFIX\ + --with-yasm=$PREFIX/bin/yasm\ + --enable-fat\ + --enable-shared=yes\ + --enable-static=no\ + --enable-gmpcompat + make -j3 + make install + cd .. + + FLINTARB_WITHGMP="--with-mpir=$PREFIX" + +fi + +# ------------------------------------------------------------------------- # +# # +# MPFR # +# # +# ------------------------------------------------------------------------- # + +curl -O https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFRVER.tar.gz +tar xf mpfr-$MPFRVER.tar.gz +cd mpfr-$MPFRVER + ./configure --prefix=$PREFIX\ + --with-gmp=$PREFIX\ + --enable-shared=yes\ + --enable-static=no\ + --host=$HOST_ARG\ + $WITH_PIC + make -j3 + make install +cd .. + +# ------------------------------------------------------------------------- # +# # +# FLINT # +# # +# ------------------------------------------------------------------------- # + +curl -O https://www.flintlib.org/flint-$FLINTVER.tar.gz +tar xf flint-$FLINTVER.tar.gz +cd flint-$FLINTVER + ./configure --prefix=$PREFIX\ + $FLINTARB_WITHGMP\ + --with-mpfr=$PREFIX\ + --disable-static + make -j3 + make install +cd .. + +# ------------------------------------------------------------------------- # +# # +# ARB # +# # +# ------------------------------------------------------------------------- # + +# curl -O -L https://github.com/fredrik-johansson/arb/archive/refs/tags/$ARBVER.tar.gz +# mv $ARBVER.tar.gz arb-$ARBVER.tar.gz +# tar xf arb-$ARBVER.tar.gz +cd $GITHUB_WORKSPACE/arb + ./configure --prefix=$PREFIX\ + --with-flint=$PREFIX\ + $FLINTARB_WITHGMP\ + --with-mpfr=$PREFIX\ + --disable-static + make -j3 + make install +cd .. + +# ------------------------------------------------------------------------- # +# # +# Done! # +# # +# ------------------------------------------------------------------------- # + +echo +echo ----------------------------------------------------------------------- +echo +echo Build dependencies for python-flint compiled as shared libraries in: +echo $PREFIX +echo +echo Versions: +if [[ $USE_GMP = "gmp" ]]; then + echo GMP: $GMPVER +else + echo MPIR: $MPIRVER +fi +echo MPFR: $MPFRVER +echo Flint: $FLINTVER +echo Arb: $ARBVER +echo +echo ----------------------------------------------------------------------- +echo + diff --git a/bin/cibw_before_build_windows.sh b/bin/cibw_before_build_windows.sh new file mode 100644 index 00000000..6085bffb --- /dev/null +++ b/bin/cibw_before_build_windows.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +bin/build_dependencies_windows.sh\ + --gmp gmp\ + --host x86_64-pc-mingw64\ + --pic diff --git a/setup.py b/setup.py index 126003fd..5c9ed3f2 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from distutils.sysconfig import get_config_vars if sys.platform == 'win32': - libraries = ["arb", "flint", "mpir", "mpfr", "pthreads"] + libraries = ["arb", "flint", "gmp", "mpfr"] else: libraries = ["arb", "flint"] (opt,) = get_config_vars('OPT')