Set library paths, add python root dir to cmake search paths and enab… #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Upload Wheels | |
on: | |
release: | |
types: [published] | |
push: | |
branches: | |
- setuptools | |
workflow_dispatch: | |
inputs: | |
deploy_target: | |
type: choice | |
description: "Choose the deployment target" | |
options: | |
- None | |
- PyPI | |
- Test PyPI | |
jobs: | |
build_wheels: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
name: [manylinux-x86_64, manylinux-aarch64, macos-x86_64, macos-arm64] | |
include: | |
- name: manylinux-x86_64 | |
os: ubuntu-latest | |
arch: x86_64 | |
- name: manylinux-aarch64 | |
os: ubuntu-24.04-arm | |
arch: aarch64 | |
shell: bash | |
- name: macos-x86_64 | |
os: macos-13 | |
macos-target: 10.13 | |
- name: macos-arm64 | |
os: macos-14 | |
macos-target: 11 | |
extra_macos_packages: "" # We can specify additional packages per architecture if needed | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# cibuildwheel requires the pyproject.toml to be present already | |
- name: Place pyproject.toml | |
run: | | |
mkdir -p ./build/python | |
cp ./python/pyproject.toml ./build/python/ | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.16.2 | |
with: | |
# Where the setup.py/pyproject.toml build infrastructure is | |
package-dir: ./build/python | |
env: | |
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" | |
CIBW_SKIP: "*-win32 *-win_amd64 *-win_arm64 *-musllinux_*" | |
CIBW_ARCHS_LINUX: ${{ matrix.arch }} | |
CIBW_BEFORE_ALL_LINUX: | | |
# Enable the devtoolset environment properly | |
source /opt/rh/devtoolset-10/enable | |
# Install necessary development packages | |
yum install -y \ | |
cmake \ | |
gcc \ | |
gcc-c++ \ | |
glibc-devel \ | |
gmp-devel \ | |
java-1.8.0-openjdk-devel \ | |
make | |
# Set library paths explicitly | |
export LD_LIBRARY_PATH="/lib64:/usr/lib64:$LD_LIBRARY_PATH" | |
export LIBRARY_PATH="/lib64:/usr/lib64:$LIBRARY_PATH" | |
CIBW_BEFORE_ALL_MACOS: | | |
brew update | |
brew install gperf ninja | |
brew install SRI-CSL/sri-csl/libpoly | |
CIBW_BEFORE_BUILD: > | |
python3 -m pip install \ | |
Cython \ | |
meson \ | |
pyparsing \ | |
pytest \ | |
setuptools \ | |
toml \ | |
wheel | |
bash {project}/ci-scripts/cibw_build_before.sh | |
CIBW_ENVIRONMENT_MACOS: > | |
DYLD_LIBRARY_PATH="$(pwd)/install/lib:$DYLD_LIBRARY_PATH" | |
MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos-target }} | |
CIBW_TEST_COMMAND: pytest {project}/tests | |
- name: Upload wheels to PyPI | |
if: > | |
github.event_name == 'release' || | |
(github.event_name == 'workflow_dispatch' && | |
github.event.inputs.deploy_target == 'PyPI') | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
python3 -m venv ./upload-env | |
source ./upload-env/bin/activate | |
python3 -m pip install twine | |
python3 -m twine upload --skip-existing wheelhouse/*.whl | |
- name: Upload wheels to TestPyPI | |
if: > | |
github.event_name == 'workflow_dispatch' && | |
github.event.inputs.deploy_target == 'Test PyPI' || | |
(github.event_name == 'push' && github.ref == 'refs/heads/setuptools') | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | |
run: | | |
python3 -m venv ./upload-env | |
source ./upload-env/bin/activate | |
python3 -m pip install twine | |
python3 -m twine upload --skip-existing --repository testpypi wheelhouse/*.whl |