Skip to content

Commit

Permalink
Merge pull request #147 from ExaScience/dev/cibw
Browse files Browse the repository at this point in the history
cibw: cibuildwheel for linux and macOS
  • Loading branch information
tvandera authored Jun 20, 2024
2 parents 3c89bd4 + d20bad4 commit 195af50
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build Wheels

on:
pull_request:
push:
branches:
- master

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-13, macos-14]
# os: [ubuntu-latest, windows-latest, macos-13, macos-14]

steps:
- uses: actions/checkout@v4

# Used to host cibuildwheel
- uses: actions/setup-python@v5

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.18.1

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
17 changes: 17 additions & 0 deletions ci/buildwheel/Dockerfile.manylinux
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM quay.io/pypa/manylinux2014_x86_64

RUN yum -y install wget eigen3-devel openblas-devel hdf5-devel && \
yum clean all

#install HighFive
RUN wget -O HighFive.tar.gz https://github.com/BlueBrain/HighFive/archive/v2.2.tar.gz && \
tar xzf HighFive.tar.gz && \
rm HighFive.tar.gz && \
cd HighFive* && \
mkdir build && \
cd build && \
cmake .. -DHIGHFIVE_USE_BOOST=OFF && \
make -j2 && \
make install && \
cd ../.. && \
rm -r HighFive*
16 changes: 16 additions & 0 deletions ci/buildwheel/Dockerfile.musllinux
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM quay.io/pypa/musllinux_1_2_x86_64

RUN apk add wget eigen openblas hdf5

#install HighFive
RUN wget -O HighFive.tar.gz https://github.com/BlueBrain/HighFive/archive/v2.2.tar.gz && \
tar xzf HighFive.tar.gz && \
rm HighFive.tar.gz && \
cd HighFive* && \
mkdir build && \
cd build && \
cmake .. -DHIGHFIVE_USE_BOOST=OFF && \
make -j2 && \
make install && \
cd ../.. && \
rm -r HighFive*
14 changes: 14 additions & 0 deletions ci/buildwheel/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -ex

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
cd "$SCRIPT_DIR"

echo "MACOSX_DEPLOYMENT_TARGET: [$MACOSX_DEPLOYMENT_TARGET]"
echo "PWD: [$PWD]"

brew install --formulae eigen ../highfive.rb
brew uninstall --ignore-dependencies hdf5

./install_hdf5.sh
21 changes: 21 additions & 0 deletions ci/buildwheel/install_hdf5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -ex

BASEDIR=$PWD

# Set the HDF5 version
HDF5_MAJOR=1
HDF5_MINOR=12
HDF5_RELEASE=2
HDF5_VERSION=${HDF5_MAJOR}.${HDF5_MINOR}.${HDF5_RELEASE}
HDF5_URL="https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_MAJOR}.${HDF5_MINOR}/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz"

mkdir -p hdf5_build
cd hdf5_build

wget -q $HDF5_URL -O - | tar -xvzf - --strip-components 2

./configure --prefix=/usr/local/hdf5
make -j4
sudo make install
26 changes: 26 additions & 0 deletions ci/buildwheel/install_openblas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -ex

VERSION=0.3.27
BASEDIR=$PWD

# Define OpenBLAS GitHub repository URL
REPO_URL="https://github.com/xianyi/OpenBLAS"

# Create a directory for the build process
BUILD_DIR="openblas_build_$VERSION"
mkdir -p $BUILD_DIR
cd $BUILD_DIR

# Download the specified version of OpenBLAS
echo "Downloading OpenBLAS version $VERSION..."
wget -qO- "$REPO_URL/archive/refs/tags/v$VERSION.tar.gz" | tar xz --strip-components=1

# Build OpenBLAS
echo "Building OpenBLAS version $VERSION..."
make MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}

make install PREFIX=$BASEDIR/openblas

echo "OpenBLAS version $VERSION has been installed in $BASEDIR/openblas"
40 changes: 37 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ cmake.verbose = true
logging.level = "INFO"

[tool.scikit-build.cmake.define]
ENABLE_BOOST = "OFF"
ENABLE_CMDLINE = "OFF"
ENABLE_TESTS = "OFF"
ENABLE_BOOST = "ON"
ENABLE_CMDLINE = "ON"
ENABLE_TESTS = "ON"
ENABLE_BLAS = "ON"

[tool.setuptools_scm] # Section required
write_to = "python/smurff/_version.py"
Expand Down Expand Up @@ -62,3 +63,36 @@ Homepage = "http://github.com/ExaScience/smurff"

[project.scripts]
py_smurff = "smurff.cmdline:main"

[tool.cibuildwheel]
manylinux-x86_64-image = "vanderaa/manylinux2014_x86_64_smurff"
musllinux-x86_64-image = "vanderaa/musllinux_1_2_x86_64_smurff"

# We skip these:
# - PyPy: never tested, pandas does not seem to work
# - CPython 3.6: unsupported by scikit_build_core
# - CPython 3.7: unsupported by h5sparse
# - CPython 3.12: removed pkg_resources in h5sparse
# - i686 and win32: we do not care about 32bit
skip = "pp* cp36-* cp37-* cp312-* *-win32 *i686"
test-command = 'pytest {project}/python/test'
test-requires = 'parameterized pytest'
build-verbosity = 3

[tool.cibuildwheel.macos.config-settings]
"cmake.define.HDF5_ROOT" = "/usr/local/hdf5"
"cmake.define.ENABLE_BLAS" = "ON"
"cmake.define.ENABLE_BOOST" = "OFF"
"cmake.define.ENABLE_CMDLINE" = "OFF"
"cmake.define.ENABLE_TESTS" = "OFF"
"cmake.define.BLA_VENDOR" = "Apple"

[tool.cibuildwheel.linux.config-settings]
"cmake.define.ENABLE_BLAS" = "ON"
"cmake.define.ENABLE_BOOST" = "OFF"
"cmake.define.ENABLE_CMDLINE" = "OFF"
"cmake.define.ENABLE_TESTS" = "OFF"
"cmake.define.BLA_VENDOR" = "OpenBLAS"

[tool.cibuildwheel.macos]
before-all = "ci/buildwheel/install_deps.sh"

0 comments on commit 195af50

Please sign in to comment.