Skip to content

Commit

Permalink
Try to get gmp working on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanDunfield committed Jul 31, 2024
1 parent 15cdf7b commit 1bafe02
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 36 deletions.
25 changes: 0 additions & 25 deletions .cirrus.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/linux_newer_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64
CIBW_BEFORE_ALL_LINUX: >
yum install -y gmp-devel zlib-devel bzip2-devel &&
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/macos_newer_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ jobs:
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_BUILD: cp311-* cp312-* cp313-*
# gmp already installed on macos runner
CIBW_BEFORE_ALL_MACOS: >
python -m pip install wheel setuptools &&
python setup.py package_assemble &&
ln -s /opt/homebrew/opt/gmp/include/gmp.h extinclude &&
ln -s /opt/homebrew/opt/gmp/include/gmpxx.h extinclude &&
ln -s /opt/homebrew/opt/gmp/lib/libgmp.a extlib &&
ln -s /opt/homebrew/opt/gmp/lib/libgmpxx.a extlib
bash build_gmp.sh
CIBW_TEST_COMMAND: python -m regina.test

- uses: actions/upload-artifact@v4
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/macos_older_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ jobs:
uses: pypa/cibuildwheel@v2.19.2
env:
CIBW_BUILD: cp38-* cp39-* cp310-*
# gmp already installed on macos runner
CIBW_BEFORE_ALL_MACOS: >
python -m pip install wheel setuptools &&
python setup.py package_assemble &&
brew install gmp &&
ln -s /opt/homebrew/opt/gmp/include/gmp.h extinclude &&
ln -s /opt/homebrew/opt/gmp/include/gmpxx.h extinclude &&
ln -s /opt/homebrew/opt/gmp/lib/libgmp.a extlib &&
ln -s /opt/homebrew/opt/gmp/lib/libgmpxx.a extlib
bash build_gmp.sh
CIBW_TEST_COMMAND: python -m regina.test

- uses: actions/upload-artifact@v4
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extlib/libgmp*
extlib/pkgconfig
extinclude/gmp*.h
gmp-*tar.bz2
gmp_src/
PKG-INFO
build/
dist/
libxml2-2.9.3/
regina_*/
tokyocabinet-1.4.48/
52 changes: 52 additions & 0 deletions build_gmp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#! /bin/bash

set -e

GMPURL=https://ftp.gnu.org/gnu/gmp/
GMPVERSION=gmp-6.3.0

if [ ! $(uname) = "Darwin" ] ; then
echo "This script configured for macOS only"
exit 1
fi

if [[ $(pwd) =~ " " ]]; then
echo "Fatal Error: Sorry, the path:"
echo " $(pwd)"
echo " has a space in it, preventing GMP from building"
echo " because of a limitation of libtool."
exit 1
fi

echo Building gmp ...


if [ ! -e ${GMPVERSION}.tar.bz2 ] ; then
echo "Downloading GMP source archive ..." ;
curl -O ${GMPURL}${GMPVERSION}.tar.bz2 ;
fi
if [ ! -e gmp_src ] ; then
echo "Extracting gmp source code ..."
tar xjf ${GMPVERSION}.tar.bz2
mv ${GMPVERSION} gmp_src
fi
cd gmp_src
export ABI=64
if /usr/bin/machine | grep arm > /dev/null ; then
BUILD_SYSTEM=arm64-none-darwin
export CFLAGS="-mmacosx-version-min=11.0"
else
BUILD_SYSTEM=x86_64-none-darwin
export CFLAGS="-mmacosx-version-min=10.9 -mno-avx2 -mno-bmi2"
fi
echo $BUILD_SYSTEM
# Use the old linker for x86_64 to avoid a spurious "branch8 out of range" error.
if [ `/usr/bin/ld -ld_classic 2> >(grep -c warning)` != "0" ] ; then
export LDFLAGS="-ld_classic"
fi


./configure --enable-cxx --with-pic --build=${BUILD_SYSTEM} --prefix=$(pwd)/local
make install
ln -s local/lib/* ../extlib
ln -s local/include/* ../extinclude

0 comments on commit 1bafe02

Please sign in to comment.