Skip to content

build: support both Apple Silicon and macOS x86 #116

build: support both Apple Silicon and macOS x86

build: support both Apple Silicon and macOS x86 #116

Workflow file for this run

name: build
on: [push, pull_request]
jobs:
build-and-test-ubuntu:
name: Ubuntu (python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ libxerces-c-dev
- name: Install package
run: pip install .
- name: Install pytest
run: pip install pytest
- name: Run tests
run: python -m pytest tests
build-and-test-windows:
name: Windows (python ${{ matrix.python-version }})
runs-on: windows-2019
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: pye57
channels: conda-forge
miniconda-version: "latest"
- name: Install Dependencies
shell: pwsh
run: |
conda install -y xerces-c
- name: Configure MSVC console
uses: ilammy/msvc-dev-cmd@v1
- name: Install package
shell: pwsh
run: pip install .
- name: Install pytest
shell: pwsh
run: pip install pytest
- name: Run tests
shell: pwsh
run: python -m pytest tests
build-and-test-macos:
name: macOS (python ${{ matrix.python-version }})
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install build dependencies
working-directory: ./scripts
run: |
bash install_xerces_c.sh
- name: Install package
run: pip install .
- name: Install pytest
run: pip install pytest
- name: Run tests
run: python -m pytest tests
build_wheels:
name: Build wheels
runs-on: ${{ matrix.os }}
needs:
- build-and-test-ubuntu
- build-and-test-windows
- build-and-test-macos
strategy:
matrix:
os: ["ubuntu-latest", "windows-2019", "macos-latest"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install cibuildwheel
run: |
python -m pip install -U pip
python -m pip install cibuildwheel
- name: Build wheels (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
python -m cibuildwheel --platform linux --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_LINUX: "bash scripts/install_xerces_c.sh"
CIBW_BUILD: "cp*-manylinux_x86_64"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8, <3.13"
- name: Build wheels (Windows)
if: matrix.os == 'windows-2019'
run: |
python -m cibuildwheel --platform windows --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_WINDOWS: "powershell scripts/install_xerces_c.ps1"
CIBW_BUILD: "cp*-win_amd64*"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8, <3.13"
- name: Build wheels (macOS)
if: matrix.os == 'macos-latest'
run: |
python -m cibuildwheel --platform macos --output-dir wheelhouse
env:
CIBW_BEFORE_ALL_MACOS: "bash scripts/install_xerces_c.sh"
CIBW_BUILD: "cp*-macosx*"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8, <3.13"
CIBW_ARCHS_MACOS: "universal2"
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: wheelhouse/*.whl
make_sdist:
name: Make sdist
runs-on: ubuntu-latest
needs:
- build-and-test-ubuntu
- build-and-test-windows
- build-and-test-macos
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build SDist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
test_built_wheels:
name: Test Built Wheels
runs-on: ${{ matrix.os }}
needs: build_wheels
strategy:
matrix:
os: [ "ubuntu-latest", "windows-2019", "macos-latest" ]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: dist
- name: Install wheel
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
python_version=$(python -c "import sys; print('cp{}{}'.format(sys.version_info.major, sys.version_info.minor))")
wheel_file=$(ls dist/*$python_version*.whl)
pip install $wheel_file
- name: Install wheel(Windows)
if: matrix.os == 'windows-2019'
shell: pwsh
run: |
$python_version = (python -c "import sys; print('cp{}{}'.format(sys.version_info.major, sys.version_info.minor))").Trim()
$wheel_file = Get-ChildItem -Path dist -Filter "*$python_version*.whl" | Select-Object -First 1
python -m pip install $wheel_file.FullName
- name: Verify installation
run: |
pip install pytest
python -m pytest tests
upload_all:
name: Upload to pypi
needs: [build_wheels, make_sdist]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
name: wheels-ubuntu-latest
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels-windows-2019
path: dist
- uses: actions/download-artifact@v4
with:
name: wheels-macos-latest
path: dist
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.pypi_password }}