From 6d205b016941602badafef9f9f582ec1bc2c5aba Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Fri, 31 Oct 2025 14:16:29 +1100 Subject: [PATCH 1/5] BLD: roll back to non conda-forge compilers for macos --- tools/wheels/cibw_before_build.sh | 4 +++ tools/wheels/gfortran_macos.sh | 55 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tools/wheels/gfortran_macos.sh diff --git a/tools/wheels/cibw_before_build.sh b/tools/wheels/cibw_before_build.sh index ff614ef..20947c1 100644 --- a/tools/wheels/cibw_before_build.sh +++ b/tools/wheels/cibw_before_build.sh @@ -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 diff --git a/tools/wheels/gfortran_macos.sh b/tools/wheels/gfortran_macos.sh new file mode 100644 index 0000000..6a01428 --- /dev/null +++ b/tools/wheels/gfortran_macos.sh @@ -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 From 50c6e6ce4c1acf85cfd1b9be1f135b7e59b05937 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Fri, 31 Oct 2025 14:27:06 +1100 Subject: [PATCH 2/5] BLD: roll back to non conda-forge compilers for macos --- .github/workflows/wheels.yml | 49 +++++++++++-------------------- tools/wheels/cibw_before_build.sh | 2 +- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 242ed6e..c1176eb 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -51,17 +51,17 @@ jobs: # should also be able to do multi-archs on a single entry, e.g. # [windows-2025, win*, "AMD64 x86"]. However, those two require a different compiler setup # so easier to separate out here. - - [ubuntu-24.04, manylinux, x86_64, "", ""] - - [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"] +# - [ubuntu-24.04, manylinux, x86_64, "", ""] +# - [ubuntu-24.04, musllinux, x86_64, "", ""] +# - [ubuntu-24.04-arm, manylinux, aarch64, "", ""] +# - [ubuntu-24.04-arm, musllinux, aarch64, "", ""] + - [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"] - - [windows-2025, win, AMD64, "", ""] - - [windows-11-arm, win, ARM64, "", ""] - python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "cp314"], ["cp314t", "cp314"]] +# - [windows-2025, win, AMD64, "", ""] +# - [windows-11-arm, win, ARM64, "", ""] + python: [["cp311", "3.11"]]#, ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "cp314"], ["cp314t", "cp314"]] # python[0] is used to specify the python versions made by cibuildwheel steps: @@ -146,41 +146,26 @@ 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 + CIBW="$PREFIX delocate-listdeps -d {wheel} && echo "-----------" &&\ + $PREFIX delocate-wheel -v $EXCLUDE --require-archs \ + {delocate_archs} -w {dest_dir} {wheel} && echo "-----------" &&\ + delocate-listdeps -d {dest_dir}/*.whl" - name: Build Wheels shell: bash -el {0} diff --git a/tools/wheels/cibw_before_build.sh b/tools/wheels/cibw_before_build.sh index 20947c1..432c6b6 100644 --- a/tools/wheels/cibw_before_build.sh +++ b/tools/wheels/cibw_before_build.sh @@ -50,7 +50,7 @@ if [[ "$INSTALL_OPENBLAS" = "true" ]] ; 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 From 7ca14c77e46904d35552baba834b7a99c5a115d1 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Fri, 31 Oct 2025 14:31:05 +1100 Subject: [PATCH 3/5] BLD: roll back to non conda-forge compilers for macos --- .github/workflows/wheels.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c1176eb..096ef8b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -156,8 +156,8 @@ jobs: CIBW_ENV="CIBW_ENVIRONMENT_MACOS=MACOSX_DEPLOYMENT_TARGET=14.0 INSTALL_OPENBLAS=false" else CIBW_ENV="CIBW_ENVIRONMENT_MACOS=PKG_CONFIG_PATH=$PWD/.openblas \ - MACOSX_DEPLOYMENT_TARGET=${{ matrix.buildplat[4] }}" \ - SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" + MACOSX_DEPLOYMENT_TARGET=${{ matrix.buildplat[4] }} \ + SDKROOT=$(xcrun --sdk macosx --show-sdk-path)" fi echo "$CIBW_ENV" >> "$GITHUB_ENV" @@ -166,6 +166,7 @@ jobs: $PREFIX delocate-wheel -v $EXCLUDE --require-archs \ {delocate_archs} -w {dest_dir} {wheel} && echo "-----------" &&\ delocate-listdeps -d {dest_dir}/*.whl" + echo "CIBW_REPAIR_WHEEL_COMMAND_MACOS=$CIBW" >> "$GITHUB_ENV" - name: Build Wheels shell: bash -el {0} From 84a033558c37a3c9fd601681c5692a4fe8f9909e Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Fri, 31 Oct 2025 15:07:39 +1100 Subject: [PATCH 4/5] BLD: roll back to non conda-forge compilers for macos --- .github/workflows/wheels.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 096ef8b..f4334ff 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -51,16 +51,16 @@ jobs: # should also be able to do multi-archs on a single entry, e.g. # [windows-2025, win*, "AMD64 x86"]. However, those two require a different compiler setup # so easier to separate out here. -# - [ubuntu-24.04, manylinux, x86_64, "", ""] -# - [ubuntu-24.04, musllinux, x86_64, "", ""] -# - [ubuntu-24.04-arm, manylinux, aarch64, "", ""] -# - [ubuntu-24.04-arm, musllinux, aarch64, "", ""] + - [ubuntu-24.04, manylinux, x86_64, "", ""] + - [ubuntu-24.04, musllinux, x86_64, "", ""] + - [ubuntu-24.04-arm, manylinux, aarch64, "", ""] + - [ubuntu-24.04-arm, musllinux, aarch64, "", ""] - [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"] -# - [windows-2025, win, AMD64, "", ""] -# - [windows-11-arm, win, ARM64, "", ""] + - [windows-2025, win, AMD64, "", ""] + - [windows-11-arm, win, ARM64, "", ""] python: [["cp311", "3.11"]]#, ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "cp314"], ["cp314t", "cp314"]] # python[0] is used to specify the python versions made by cibuildwheel @@ -162,10 +162,7 @@ jobs: echo "$CIBW_ENV" >> "$GITHUB_ENV" PREFIX=DYLD_LIBRARY_PATH="\$(dirname \$(gfortran --print-file-name libgfortran.dylib))" - CIBW="$PREFIX delocate-listdeps -d {wheel} && echo "-----------" &&\ - $PREFIX delocate-wheel -v $EXCLUDE --require-archs \ - {delocate_archs} -w {dest_dir} {wheel} && echo "-----------" &&\ - delocate-listdeps -d {dest_dir}/*.whl" + CIBW="$PREFIX delocate-wheel -v $EXCLUDE --require-archs {delocate_archs} -w {dest_dir} {wheel}" echo "CIBW_REPAIR_WHEEL_COMMAND_MACOS=$CIBW" >> "$GITHUB_ENV" - name: Build Wheels From 0c21897f189cce4bd8db9251a11315fa79ea0c97 Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Fri, 31 Oct 2025 15:09:29 +1100 Subject: [PATCH 5/5] BLD: roll back to non conda-forge compilers for macos --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f4334ff..3417803 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -61,7 +61,7 @@ jobs: - [macos-14, macosx, arm64, accelerate, "14.0"] - [windows-2025, win, AMD64, "", ""] - [windows-11-arm, win, ARM64, "", ""] - python: [["cp311", "3.11"]]#, ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "cp314"], ["cp314t", "cp314"]] + python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "cp314"], ["cp314t", "cp314"]] # python[0] is used to specify the python versions made by cibuildwheel steps: