Skip to content
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
31 changes: 7 additions & 24 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- [ubuntu-24.04, musllinux, x86_64, "", ""]
- [ubuntu-24.04-arm, manylinux, aarch64, "", ""]
- [ubuntu-24.04-arm, musllinux, aarch64, "", ""]
- [macos-13, macosx, x86_64, openblas, "10.14"]
- [macos-15-intel, macosx, x86_64, openblas, "10.15"]
- [macos-15-intel, macosx, x86_64, accelerate, "14.0"]
- [macos-14, macosx, arm64, openblas, "12.3"]
- [macos-14, macosx, arm64, accelerate, "14.0"]
Expand Down Expand Up @@ -146,41 +146,24 @@ jobs:
run: |
if [[ ${{ matrix.buildplat[3] }} == 'accelerate' ]]; then
echo CIBW_CONFIG_SETTINGS=\"setup-args=-Dblas=accelerate\" >> "$GITHUB_ENV"

# use preinstalled gfortran for Accelerate builds
ln -s $(which gfortran-13) gfortran
export PATH=$PWD:$PATH
echo "PATH=$PATH" >> "$GITHUB_ENV"

# Builds with Accelerate only target macOS>=14.0
CIBW_ENV="CIBW_ENVIRONMENT_MACOS=MACOSX_DEPLOYMENT_TARGET=14.0 INSTALL_OPENBLAS=false"
else
# use conda-forge compilers the difficult targets
INSTALL_DIR=/Users/runner/miniforge3

wget -q -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"

# Make the installer executable
chmod +x Miniforge3.sh

# Run the installer in batch mode (-b) and specify the installation prefix (-p)
# The -u flag is for updating an existing installation if it exists
./Miniforge3.sh -b -u -p "${INSTALL_DIR}"

source "${INSTALL_DIR}/etc/profile.d/conda.sh"
conda init
conda create -q -y -n build compilers
echo "conda activate build" >> $HOME/.bash_profile
cat $HOME/.bash_profile

CIBW_ENV="CIBW_ENVIRONMENT_MACOS=PKG_CONFIG_PATH=$PWD/.openblas \
MACOSX_DEPLOYMENT_TARGET=${{ matrix.buildplat[4] }}"
MACOSX_DEPLOYMENT_TARGET=${{ matrix.buildplat[4] }} \
SDKROOT=$(xcrun --sdk macosx --show-sdk-path)"
fi
echo "$CIBW_ENV" >> $GITHUB_ENV
echo "$CIBW_ENV" >> "$GITHUB_ENV"

PREFIX=DYLD_LIBRARY_PATH="\$(dirname \$(gfortran --print-file-name libgfortran.dylib))"
CIBW="$PREFIX delocate-wheel -v $EXCLUDE --require-archs {delocate_archs} -w {dest_dir} {wheel}"
echo "CIBW_REPAIR_WHEEL_COMMAND_MACOS=$CIBW" >> $GITHUB_ENV
echo "CIBW_REPAIR_WHEEL_COMMAND_MACOS=$CIBW" >> "$GITHUB_ENV"

- name: Build Wheels
shell: bash -el {0}
Expand Down
4 changes: 4 additions & 0 deletions tools/wheels/cibw_before_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ if [[ "$INSTALL_OPENBLAS" = "true" ]] ; then
python -c "import scipy_${OPENBLAS}; print(scipy_${OPENBLAS}.get_pkg_config())" > $pkgconf_path/scipy-openblas.pc

if [[ $RUNNER_OS == "macOS" ]]; then
# For scipy_openblas we need the older fortran compilers that were used to
# build it, homebrew's are too modern.
source $PROJECT_DIR/tools/wheels/gfortran_macos.sh

lib_loc=$(python -c"import scipy_openblas32; print(scipy_openblas32.get_lib_dir())")
# Use the libgfortran from gfortran rather than the one in the wheel
# since delocate gets confused if there is more than one
Expand Down
55 changes: 55 additions & 0 deletions tools/wheels/gfortran_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
set -xe
PLATFORM=$(uname -m)
echo $PLATFORM

#########################################################################################
# Install GFortran + OpenBLAS

if [[ $PLATFORM == "x86_64" ]]; then
#GFORTRAN=$(type -p gfortran-9)
#sudo ln -s $GFORTRAN /usr/local/bin/gfortran
# same version of gfortran as the openblas-libs
# https://github.com/MacPython/gfortran-install.git
curl -L https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-x86_64-native.tar.gz -o gfortran.tar.gz

GFORTRAN_SHA256=$(shasum -a 256 gfortran.tar.gz)
KNOWN_SHA256="981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4 gfortran.tar.gz"
if [ "$GFORTRAN_SHA256" != "$KNOWN_SHA256" ]; then
echo sha256 mismatch
exit 1
fi

sudo mkdir -p /opt/
# places gfortran in /opt/gfortran-darwin-x86_64-native. There's then
# bin, lib, include, libexec underneath that.
sudo tar -xv -C /opt -f gfortran.tar.gz

# Link these into /usr/local so that there's no need to add rpath or -L
for f in libgfortran.dylib libgfortran.5.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib libquadmath.dylib libquadmath.0.dylib; do
ln -sf /opt/gfortran-darwin-x86_64-native/lib/$f /usr/local/lib/$f
done
ln -sf /opt/gfortran-darwin-x86_64-native/bin/gfortran /usr/local/bin/gfortran

# Set SDKROOT env variable if not set
# This step is required whenever the gfortran compilers sourced from
# conda-forge (built by isuru fernando) are used outside of a conda-forge
# environment (so it mirrors what is done in the conda-forge compiler
# activation scripts)
export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)}
fi


if [[ $PLATFORM == "arm64" ]]; then
curl -L https://github.com/fxcoudert/gfortran-for-macOS/releases/download/12.1-monterey/gfortran-ARM-12.1-Monterey.dmg -o gfortran.dmg
GFORTRAN_SHA256=$(shasum -a 256 gfortran.dmg)
KNOWN_SHA256="e2e32f491303a00092921baebac7ffb7ae98de4ca82ebbe9e6a866dd8501acdf gfortran.dmg"

if [ "$GFORTRAN_SHA256" != "$KNOWN_SHA256" ]; then
echo sha256 mismatch
exit 1
fi

hdiutil attach -mountpoint /Volumes/gfortran gfortran.dmg
sudo installer -pkg /Volumes/gfortran/gfortran.pkg -target /
type -p gfortran
fi