Skip to content

Feat/pecos deps

Feat/pecos deps #562

Workflow file for this run

name: Python Artifacts
env:
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
on:
push:
branches:
- main
- dev
- development
- master
tags:
- 'py-*'
pull_request:
branches:
- main
- dev
- development
- master
workflow_dispatch:
inputs:
sha:
description: Commit SHA
type: string
dry_run:
description: 'Dry run (build but not publish)'
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
check_pr_push:
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' && github.event.action != 'closed' ||
github.event_name == 'push' && contains(fromJSON('["main", "master", "dev", "development"]'), github.ref_name) ||
github.event_name == 'push' && startsWith(github.ref, 'refs/tags/py-')
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- name: Check if should run on PR push
id: check
run: |
# Always run on tag pushes (py-* tags trigger releases)
if [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref }}" == refs/tags/py-* ]]; then
echo "run=true" >> $GITHUB_OUTPUT
# Always run on pushes to main branches
elif [ "${{ github.event_name }}" = "push" ] && [[ "${{ github.ref_name }}" =~ ^(main|master|dev|development)$ ]]; then
echo "run=true" >> $GITHUB_OUTPUT
# For PRs, check the TRIGGER_ON_PR_PUSH setting
elif [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ env.TRIGGER_ON_PR_PUSH }}" = "true" ]; then
echo "run=true" >> $GITHUB_OUTPUT
else
echo "run=false" >> $GITHUB_OUTPUT
fi
build_wheelspecos_rslib:
needs: check_pr_push
if: needs.check_pr_push.result == 'success' && needs.check_pr_push.outputs.run == 'true'
runs-on: ${{ matrix.runner || matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
architecture: x86_64
- os: ubuntu-latest
architecture: aarch64
runner: ubuntu-latest
- os: macos-14
architecture: aarch64
- os: macos-15-intel
architecture: x86_64
- os: windows-2022
architecture: x86_64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
submodules: recursive
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: python/pecos-rslib
output-dir: wheelhouse
env:
# Build configuration
CIBW_BUILD: "cp310-*"
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux*"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux_2_28"
# Linux configuration
CIBW_ENVIRONMENT_LINUX: >
PATH=$HOME/.cargo/bin:$HOME/.pecos/llvm/bin:$PATH
LLVM_SYS_140_PREFIX=$HOME/.pecos/llvm
CIBW_BEFORE_ALL_LINUX: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
dnf install libffi-devel -y
cargo run --release -p pecos-dev -- llvm install --force
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
auditwheel repair -w {dest_dir} {wheel} &&
pipx run abi3audit --strict --report {wheel}
# macOS configuration
CIBW_ENVIRONMENT_MACOS: >
PATH=$HOME/.cargo/bin:$HOME/.pecos/llvm/bin:$PATH
LLVM_SYS_140_PREFIX=$HOME/.pecos/llvm
MACOSX_DEPLOYMENT_TARGET=13.2
CIBW_BEFORE_ALL_MACOS: |
curl -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
rustup update
cargo run --release -p pecos-dev -- llvm install --force
# Create a codesign wrapper that strips DYLD_LIBRARY_PATH to prevent
# crashes on macOS 15 when bundled libc++ conflicts with system libc++
mkdir -p $HOME/.pecos/bin
printf '#!/bin/bash\nunset DYLD_LIBRARY_PATH\nexec /usr/bin/codesign "$@"\n' > $HOME/.pecos/bin/codesign
chmod +x $HOME/.pecos/bin/codesign
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
PATH=$HOME/.pecos/bin:$PATH DYLD_LIBRARY_PATH=$HOME/.pecos/llvm/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
pipx run abi3audit --strict --report {wheel}
# Windows configuration
CIBW_ENVIRONMENT_WINDOWS: >
PATH="C:\\Users\\runneradmin\\.pecos\\llvm\\bin;$PATH"
LLVM_SYS_140_PREFIX="C:\\Users\\runneradmin\\.pecos\\llvm"
CIBW_BEFORE_ALL_WINDOWS: >
echo "=== Installing LLVM using pecos-dev ===" &&
rustup update &&
echo "=== Running pecos-llvm install ===" &&
cargo run --release -p pecos-dev -- llvm install --force &&
echo "=== Checking LLVM installation ===" &&
(test -d "C:\\Users\\runneradmin\\.pecos\\llvm" && echo "LLVM directory exists" && ls -la "C:\\Users\\runneradmin\\.pecos\\llvm" && (ls -la "C:\\Users\\runneradmin\\.pecos\\llvm\\bin" || echo "bin directory not found")) || (echo "ERROR: LLVM directory not found!" && exit 1) &&
echo "=== Verifying LLVM_SYS_140_PREFIX ===" &&
echo "LLVM_SYS_140_PREFIX will be set to: C:\\Users\\runneradmin\\.pecos\\llvm"
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
delvewheel repair -w {dest_dir} {wheel} &&
pipx run abi3audit --strict --report {wheel}
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-pecos-rslib-${{ matrix.os }}-${{ matrix.architecture }}
path: ./wheelhouse/*.whl
test_abi3_wheels:
needs: build_wheelspecos_rslib
if: |
always() &&
needs.build_wheelspecos_rslib.result == 'success'
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
platform:
- runner: ubuntu-latest
os: ubuntu-latest
architecture: x86_64
- runner: windows-latest
os: windows-2022
architecture: x86_64
- runner: macos-15-intel
os: macos-15-intel
architecture: x86_64
- runner: macos-14
os: macos-14
architecture: aarch64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download abi3 wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-${{ matrix.platform.os }}-${{ matrix.platform.architecture }}
path: ./pecos-rslib-wheel
- name: Test abi3 wheel with Python ${{ matrix.python-version }}
run: |
echo "Testing abi3 wheel with Python ${{ matrix.python-version }}"
python --version
pip install --force-reinstall --verbose ./pecos-rslib-wheel/*.whl
python -c 'import pecos_rslib; print(f"pecos_rslib version: {pecos_rslib.__version__}")'
python -c 'import sys; print(f"Python version: {sys.version}")'
build_sdist_quantum_pecos:
needs: build_wheelspecos_rslib
if: |
always() &&
needs.build_wheelspecos_rslib.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64
path: ./pecos-rslib-wheel
- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl
- name: Install build dependencies
run: pip install build
- name: Build quantum-pecos SDist
run: |
cd python/quantum-pecos
python -m build --sdist --outdir dist
- name: Test quantum-pecos SDist
run: |
pip install python/quantum-pecos/dist/*.tar.gz
python -c 'import pecos; print(pecos.__version__)'
- name: Upload quantum-pecos SDist
uses: actions/upload-artifact@v4
with:
name: sdist-quantum-pecos
path: python/quantum-pecos/dist/*.tar.gz
build_wheels_quantum_pecos:
needs: build_wheelspecos_rslib
if: |
always() &&
needs.build_wheelspecos_rslib.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha || github.sha }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Download pecos-rslib wheel
uses: actions/download-artifact@v4
with:
name: wheel-pecos-rslib-ubuntu-latest-x86_64
path: ./pecos-rslib-wheel
- name: Install pecos-rslib
run: pip install ./pecos-rslib-wheel/*.whl
- name: Install build dependencies
run: pip install build
- name: Build quantum-pecos wheel
run: |
cd python/quantum-pecos
python -m build --wheel --outdir dist
- name: Test quantum-pecos wheel
run: |
pip install python/quantum-pecos/dist/*.whl
python -c 'import pecos; print(pecos.__version__)'
- name: Upload quantum-pecos wheel
uses: actions/upload-artifact@v4
with:
name: wheel-quantum-pecos
path: python/quantum-pecos/dist/*.whl
collect_artifacts:
needs: [build_wheelspecos_rslib, build_sdist_quantum_pecos, build_wheels_quantum_pecos, test_abi3_wheels]
if: |
needs.build_wheelspecos_rslib.result == 'success' &&
needs.build_sdist_quantum_pecos.result == 'success' &&
needs.build_wheels_quantum_pecos.result == 'success' &&
needs.test_abi3_wheels.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Create distribution directories
run: |
mkdir -p dist/pecos-rslib
mkdir -p dist/quantum-pecos
# Download artifacts into temp directory first
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: temp-artifacts/
- name: Organize distribution files
run: |
# Debug: Show what we downloaded
echo "=== Downloaded artifacts structure ==="
ls -la temp-artifacts/
# Move pecos-rslib wheels to distribution directory
for artifact in temp-artifacts/wheel-pecos-rslib-*/; do
if [ -d "$artifact" ]; then
echo "Processing $artifact"
mv "$artifact"*.whl dist/pecos-rslib/ 2>/dev/null || true
fi
done
# Move quantum-pecos files to distribution directory
for artifact in temp-artifacts/*-quantum-pecos*/; do
if [ -d "$artifact" ]; then
echo "Processing $artifact"
mv "$artifact"*.whl dist/quantum-pecos/ 2>/dev/null || true
mv "$artifact"*.tar.gz dist/quantum-pecos/ 2>/dev/null || true
fi
done
# Clean up
rm -rf temp-artifacts
- name: List all collected artifacts
run: |
echo "=== pecos-rslib artifacts ==="
ls -la dist/pecos-rslib/
echo ""
echo "=== quantum-pecos artifacts ==="
ls -la dist/quantum-pecos/
echo ""
echo "=== Summary ==="
echo "pecos-rslib wheels: $(ls -1 dist/pecos-rslib/*.whl 2>/dev/null | wc -l)"
echo "quantum-pecos distributions: $(ls -1 dist/quantum-pecos/* 2>/dev/null | wc -l)"
- name: Upload distribution bundle
uses: actions/upload-artifact@v4
with:
name: pecos-distribution
path: dist/