diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 00000000..a313f522 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -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 diff --git a/ci/buildwheel/Dockerfile.manylinux b/ci/buildwheel/Dockerfile.manylinux new file mode 100644 index 00000000..1d684956 --- /dev/null +++ b/ci/buildwheel/Dockerfile.manylinux @@ -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* diff --git a/ci/buildwheel/Dockerfile.musllinux b/ci/buildwheel/Dockerfile.musllinux new file mode 100644 index 00000000..23ce5a7b --- /dev/null +++ b/ci/buildwheel/Dockerfile.musllinux @@ -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* diff --git a/ci/buildwheel/install_deps.sh b/ci/buildwheel/install_deps.sh new file mode 100755 index 00000000..64f99c25 --- /dev/null +++ b/ci/buildwheel/install_deps.sh @@ -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 \ No newline at end of file diff --git a/ci/buildwheel/install_hdf5.sh b/ci/buildwheel/install_hdf5.sh new file mode 100755 index 00000000..4fcf0b95 --- /dev/null +++ b/ci/buildwheel/install_hdf5.sh @@ -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 \ No newline at end of file diff --git a/ci/buildwheel/install_openblas.sh b/ci/buildwheel/install_openblas.sh new file mode 100755 index 00000000..617ec990 --- /dev/null +++ b/ci/buildwheel/install_openblas.sh @@ -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" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 8a6fa631..54256ea8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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" \ No newline at end of file