Skip to content

Start development of 5.0 #171

Start development of 5.0

Start development of 5.0 #171

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.9", "3.10", "3.11", "3.12", "3.13"]
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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- uses: nuget/setup-nuget@a21f25cd3998bf370fde17e3f1b4c12c175172f9 # v2.0.0
if: always() && runner.os == 'Windows'
with:
nuget-version: "latest"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
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/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3
with:
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ env.CIBW_BUILD_IDENTIFIER }}
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ENVIRONMENT_MACOS:
MACOSX_DEPLOYMENT_TARGET=11
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 -fastproxy -olddefs ./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@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
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@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Set up Python 3.9
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
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/[email protected] # v4.1.7
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)"