Skip to content

Commit

Permalink
Cibuildwheel (#54)
Browse files Browse the repository at this point in the history
* started cibuildwheel support

* testing stage

* fix path

* add mac, though will not build

* update mac openblas

* mac fix

* windows fix

* expand os

* bugfix

* bugfix

* upgrade version

* update to v4

* changes to openblas

* fix rpath

* Revert "changes to openblas"

This reverts commit bb07fe9.

* bugfix

* bugfix

* bugfix

* bugfix

* bugfix

* bugfix

* windows fix

* windows fix

* bugfix

* add mkl

* turn off repair

* remove openblas

* fix for new upload-artificat

* fix pypi upload

* finished turn on by tag
  • Loading branch information
jdtuck authored May 26, 2024
1 parent d1f8576 commit 12ba4d1
Show file tree
Hide file tree
Showing 9 changed files with 623 additions and 76 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,25 @@ jobs:
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3

# build_wheels:
# needs: [build]
# if: startsWith( github.ref, 'refs/tags/')
# name: Build wheels on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-22.04]
build_wheels:
needs: [build]
if: startsWith( github.ref, 'refs/tags/')
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]

# steps:
# - uses: actions/checkout@v4
steps:
- uses: actions/checkout@v4

# - name: Build wheels
# uses: pypa/[email protected].2
- name: Build wheels
uses: pypa/[email protected].5

# - uses: actions/upload-artifact@v3
# with:
# path: ./wheelhouse/*.whl
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
needs: [build]
Expand All @@ -92,24 +93,26 @@ jobs:
- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_sdist]
needs: [build_sdist, build_wheels]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
46 changes: 0 additions & 46 deletions bin/cibw_before_build.sh

This file was deleted.

24 changes: 24 additions & 0 deletions bin/cibw_before_build_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set -xe


NIGHTLY_FLAG=""

if [ "$#" -eq 1 ]; then
PROJECT_DIR="$1"
elif [ "$#" -eq 2 ] && [ "$1" = "--nightly" ]; then
NIGHTLY_FLAG="--nightly"
PROJECT_DIR="$2"
else
echo "Usage: $0 [--nightly] <project_dir>"
exit 1
fi

PLATFORM=$(PYTHONPATH=bin python -c "import openblas_support; print(openblas_support.get_plat())")

printenv
# Update license

# Install Openblas
basedir=$(python bin/openblas_support.py $NIGHTLY_FLAG)
cp -r $basedir/lib/* /usr/local/lib
cp $basedir/include/* /usr/local/include
89 changes: 89 additions & 0 deletions bin/cibw_before_build_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
set -xe

PROJECT_DIR="$1"
PLATFORM=$(PYTHONPATH=bin python -c "import openblas_support; print(openblas_support.get_plat())")
echo $PLATFORM


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

if [[ $PLATFORM == "macosx-x86_64" ]]; then
# Openblas
basedir=$(python bin/openblas_support.py)

# copy over the OpenBLAS library stuff first
cp -r $basedir/lib/* /usr/local/lib
cp $basedir/include/* /usr/local/include

#GFORTRAN=$(type -p gfortran-9)
#sudo ln -s $GFORTRAN /usr/local/bin/gfortran
# same version of gfortran as the openblas-libs and scipy-wheel builds
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 == "macosx-arm64" ]]; then
# OpenBLAS
# need a version of OpenBLAS that is suited for gcc >= 11
basedir=$(python bin/openblas_support.py)

# use /opt/arm64-builds as a prefix, because that's what the multibuild
# OpenBLAS pkgconfig files state
sudo mkdir -p /opt/arm64-builds/lib
sudo mkdir -p /opt/arm64-builds/include
sudo mkdir -p /usr/local/lib
sudo mkdir -p /usr/local/include
sudo cp -r $basedir/lib/* /opt/arm64-builds/lib
sudo cp $basedir/include/* /opt/arm64-builds/include

# we want to force a dynamic linking
sudo rm /opt/arm64-builds/lib/*.a

sudo cp -r /opt/arm64-builds/lib/* /usr/local/lib
sudo cp /opt/arm64-builds/include/* /usr/local/include

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

# 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.1.dylib libquadmath.dylib libquadmath.0.dylib; do
sudo cp /usr/local/gfortran/lib/$f /opt/arm64-builds/lib/$f
done
sudo ln -sf /usr/local/gfortran//bin/gfortran /usr/local/bin/gfortran

fi
2 changes: 2 additions & 0 deletions bin/cibw_before_build_win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

python -m pip install mkl-devel
Loading

0 comments on commit 12ba4d1

Please sign in to comment.