Skip to content

Commit

Permalink
Run cibuildwheel from bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins committed Oct 9, 2024
1 parent e6abb43 commit 1ed1ad2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
45 changes: 20 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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/[email protected]
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}
Expand All @@ -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
Expand Down
32 changes: 32 additions & 0 deletions ci/scripts/run_cibuildwheel.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1ed1ad2

Please sign in to comment.