Skip to content

Squashed commit of the following: #108

Squashed commit of the following:

Squashed commit of the following: #108

name: Python Wheel Build
on:
push:
# Trigger the workflow on push, but only for the develop-pypi and master branch
branches: [develop-pypi, master]
# globals
env:
PACKAGE_NAME: verovio
CHECK_INSTALL_DIR: check_install_dir
CIBW_BUILD_IDENTIFIER: ""
jobs:
#===============================================#
# BUILD WHEEL DISTRIBUTION #
#===============================================#
build_wheels:
name: Build wheels (${{ matrix.python-version }}, ${{ matrix.os }}-${{ matrix.architecture }})
runs-on: ${{ matrix.os }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
# Build the wheels for Linux, Windows and macOS
matrix:
os: [macos-13, macos-14, windows-latest, ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
architecture: [x86, x64, arm64]
include:
- os: macos-13
architecture: x64
platform_id: macosx_x86_64
- os: macos-14
architecture: arm64
platform_id: macosx_arm64
- os: windows-latest
architecture: x64
platform_id: win_amd64
- os: windows-latest
architecture: x86
platform_id: win32
- os: ubuntu-latest
architecture: x64
platform_id: manylinux_x86_64
exclude:
- os: macos-13
architecture: x86
- os: macos-13
architecture: arm64
- os: macos-14
architecture: x86
- os: macos-14
architecture: x64
- os: ubuntu-latest
architecture: x86
- os: ubuntu-latest
architecture: arm64
- os: windows-latest
architecture: arm64
steps:
#===============================================#
# Set up
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nuget/setup-nuget@v1
if: always() && runner.os == 'Windows'
with:
nuget-version: "latest"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
#===============================================#
# Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install importlib_resources twine
#===============================================#
# Prepare identifier
- name: Set CIBW_BUILD_IDENTIFIER
shell: bash
run: |
# Remove dot from python-version for CIBW and prefix with cp
id=cp$(echo ${{ matrix.python-version }} | sed -e 's/\.//g')-${{ matrix.platform_id }}
echo CIBW_BUILD_IDENTIFIER=$id >> $GITHUB_ENV
echo $id
#===============================================#
# wheels
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ env.CIBW_BUILD_IDENTIFIER }}
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ENVIRONMENT_MACOS:
MACOSX_DEPLOYMENT_TARGET=10.15
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_BEFORE_ALL_MACOS: brew update && brew install swig
CIBW_BEFORE_ALL_WINDOWS: choco install swig -f -y
CIBW_BEFORE_BUILD: swig -version && bash -c 'cd tools; ./get_git_commit.sh' && swig -c++ -python -py3 ./bindings/python/verovio.i
#===============================================#
# Check build
# TODO: Can be removed when everything is set up
- name: "List result"
working-directory: wheelhouse
run: ls -R
- name: Check with Twine
working-directory: wheelhouse
run: twine check *.whl
- name: Install from wheel on Linux
if: always() && runner.os == 'Linux'
working-directory: wheelhouse
run: python -m pip install ./*.whl
# Install only the x86_64 wheel on macOS
- name: Install from wheel on macOS
working-directory: wheelhouse
if: always() && runner.os == 'macOS'
run: python -m pip install ./*.whl
# Wildcard use is different with PowerShell
# cf. https://stackoverflow.com/a/43900040
- name: Install from wheel on Windows
working-directory: wheelhouse
if: always() && runner.os == 'Windows'
run: python -m pip install (get-item .\*.whl).FullName
- name: Check wheel installation
working-directory: wheelhouse
run: python -c "import verovio; tk = verovio.toolkit(); v = tk.getVersion(); print('verovio.toolkit.getVersion():', v)"
#===============================================#
# Upload artifacts
- uses: actions/upload-artifact@v3
with:
name: cibuildwheel-${{ runner.os }}-python-${{ matrix.python-version }}-${{ matrix.architecture }}
path: ./wheelhouse/*.whl
#===============================================#
# BUILD SOURCE DISTRIBUTION #
#===============================================#
build_sdist:
name: Build sdist
runs-on: [ubuntu-latest]
steps:
#===============================================#
# Set up
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.9"
#===============================================#
# Swig
- name: Install swig
if: runner.os == 'Linux'
run: |
sudo apt update -q
sudo apt install swig
- name: Verify swig
run: swig -version
#===============================================#
# Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools wheel twine
#===============================================#
# sdist
- name: Build ext
run: python setup.py build_ext
- name: Build source distribution
run: python setup.py sdist
#===============================================#
# Check build
# TODO: Can be removed when everything is set up
- name: List result
working-directory: dist
run: ls -R
- name: Check with Twine
working-directory: dist
run: twine check *.tar.gz
- name: Create install dir
shell: bash
run: mkdir - p ${{ env.CHECK_INSTALL_DIR }}
- name: Install from source
working-directory: ${{ env.CHECK_INSTALL_DIR }}
run: python -m pip install ../dist/*.tar.gz
- name: Check source installation
working-directory: ${{ env.CHECK_INSTALL_DIR }}
run: python -c "import verovio; tk = verovio.toolkit(); v = tk.getVersion(); print('verovio.toolkit.getVersion():', v)"
#===============================================#
# Upload artifact
- uses: actions/upload-artifact@v3
with:
name: sdist-${{ runner.os }}-python-3.9
path: dist/*.tar.gz
#===============================================#
# UPLOAD TO PACKAGE INDEX #
#===============================================#
upload_testpypi:
name: Upload to TestPyPi
needs: [build_wheels, build_sdist]
runs-on: [ubuntu-latest]
steps:
#===============================================#
# Set up
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
architecture: "x64"
#===============================================#
# Dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install twine
#===============================================#
# Prepare artifacts
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bindings/python/artifacts/
# TODO: Can be removed when everything is set up
- name: Display structure of downloaded files
working-directory: bindings/python/artifacts/
run: ls -R
- name: Copy artifacts to dist folder
working-directory: bindings/python/
run: |
mkdir -p ./dist
cp artifacts/*/* dist/
# TODO: Can be removed when everything is set up
- name: Verify dist folder
working-directory: bindings/python/dist/
run: ls -R
#===============================================#
# Upload to package test index
- name: Upload to TestPyPi
working-directory: bindings/python
env:
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }}
run: twine upload --repository testpypi dist/*
#===============================================#
# Check test build
- name: Create install dir
shell: bash
run: |
mkdir - p ${{ env.CHECK_INSTALL_DIR }}
cd ${{ env.CHECK_INSTALL_DIR }}
python -m pip install --index-url https://test.pypi.org/simple/ --pre ${{ env.PACKAGE_NAME }}
python -c "import verovio; tk = verovio.toolkit(); v = tk.getVersion(); print('verovio.toolkit.getVersion():', v)"