From 1ed1ad216f46ba821a1c82bcb7850c74ed8f3e8c Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Wed, 9 Oct 2024 15:45:50 +0200 Subject: [PATCH] Run cibuildwheel from bash script --- .github/workflows/ci.yml | 45 +++++++++++++++------------------- ci/scripts/run_cibuildwheel.sh | 32 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 ci/scripts/run_cibuildwheel.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37ad4b77..197ccc6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,22 +11,6 @@ on: - cron: '30 2 * * 1,4' # Every Monday and Thursday @ 2h30am UTC env: - CIBW_BUILD_FRONTEND: build - CIBW_BEFORE_ALL_LINUX: yum install -y zip flex bison gcc-gfortran - # Install miniforge - CIBW_BEFORE_ALL_MACOS: | - curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" - bash Miniforge3-$(uname)-$(uname -m).sh -b -p "$HOME/conda" - # Install conda-forge compilers and llvm-openmp - CIBW_BEFORE_BUILD_MACOS: | - source "${HOME}/conda/etc/profile.d/conda.sh" - conda create -n arcae-build -c conda-forge compilers llvm-openmp python - conda activate arcae-build - CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 - CIBW_TEST_EXTRAS_LINUX: applications,test - CIBW_TEST_COMMAND_LINUX: py.test -s -vvv --pyargs arcae - CIBW_TEST_COMMAND_MACOS: python -c "from arcae.testing import sanity; sanity()" - HOST_PYTHON_VERSION: "3.10" VCPKG_INSTALLED_DIR: /tmp/vcpkg_installed ARTIFACT_NAME: wheel @@ -60,9 +44,6 @@ jobs: cpp-tests: name: Execute C++ test cases runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[skip ci]')" - strategy: - fail-fast: false env: VCPKG_TARGET_TRIPLET: "x64-linux-dynamic-cxx17-abi1-rel" @@ -108,7 +89,7 @@ jobs: build-wheels: - name: Build and Test Binary Wheels + name: Build wheel for ${{ matrix.cpython }}-${{ matrix.os_short }}-${{ matrix.arch }} runs-on: ${{ matrix.os }} if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: @@ -168,15 +149,28 @@ jobs: LD_LIBRARY_PATH=${{ env.VCPKG_INSTALLED_DIR }}/${{ matrix.triplet }}/lib run: echo "CIBW_ENVIRONMENT_COMMON=$COMMON_ENV" >> $GITHUB_ENV + - name: Install conda for macos + if: ${{ matrix.os_short == 'macos' }} + run: | + set -ex + curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" + + # Install miniforge + MINIFORGE_PATH=$HOME/miniforge + bash Miniforge3-$(uname)-$(uname -m).sh -b -p $MINIFORGE_PATH + echo "$MINIFORGE_PATH/bin" >> $GITHUB_PATH + echo "CONDA_HOME=$MINIFORGE_PATH" >> $GITHUB_ENV + - name: Run cibuildwheel - uses: pypa/cibuildwheel@v2.21.3 env: CIBW_BUILD: ${{ matrix.cpython }}-${{ matrix.extra_build }}* + CIBW_BUILD_FRONTEND: build CIBW_ARCHS: ${{ matrix.arch }} - CIBW_ENVIRONMENT_LINUX: ${{ env.CIBW_ENVIRONMENT_COMMON }} - CIBW_ENVIRONMENT_MACOS: > - ${{ env.CIBW_ENVIRONMENT_COMMON }} - MACOSX_DEPLOYMENT_TARGET=12.0 + CIBW_BEFORE_ALL_LINUX: yum install -y zip flex bison gcc-gfortran + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64 + CIBW_TEST_EXTRAS_LINUX: applications,test + CIBW_TEST_COMMAND_LINUX: py.test -s -vvv --pyargs arcae + CIBW_TEST_COMMAND_MACOS: python -c "from arcae.testing import sanity; sanity()" CIBW_REPAIR_WHEEL_COMMAND_LINUX: > auditwheel repair -w {dest_dir} {wheel} @@ -191,6 +185,7 @@ jobs: --exclude libarrow_python.dylib \ --exclude libarrow.1601.dylib \ --ignore-missing-dependencies + run: ci/scripts/run_cibuildwheel.sh - name: Upload wheel artifacts uses: actions/upload-artifact@v4 diff --git a/ci/scripts/run_cibuildwheel.sh b/ci/scripts/run_cibuildwheel.sh new file mode 100644 index 00000000..05aa545f --- /dev/null +++ b/ci/scripts/run_cibuildwheel.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e +set -x + +# OpenMP is not present on macOS by default +if [[ $(uname) == "Darwin" ]]; then + if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then + # SciPy requires 12.0 on arm to prevent kernel panics + # https://github.com/scipy/scipy/issues/14688 + # We use the same deployment target to match SciPy. + export MACOSX_DEPLOYMENT_TARGET=12.0 + OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2" + else + export MACOSX_DEPLOYMENT_TARGET=10.9 + OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2" + fi + + # This depends on miniforge installation + conda create -n arcae-build $OPENMP_URL + PREFIX="$CONDA_HOME/envs/arcae-build" + + export CC=/usr/bin/clang + export CXX=/usr/bin/clang++ + export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" + export CFLAGS="$CFLAGS -I$PREFIX/include" + export CXXFLAGS="$CXXFLAGS -I$PREFIX/include" + export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp" +fi + +python -m pip install cibuildwheel +python -m cibuildwheel