Skip to content

Update to liblsl 1.17.4 and bundle libs on more targets #24

Update to liblsl 1.17.4 and bundle libs on more targets

Update to liblsl 1.17.4 and bundle libs on more targets #24

Workflow file for this run

name: Build and publish Python 🐍 distributions 📦 to PyPI
on:
release:
types: [published]
pull_request:
branches:
- main
workflow_dispatch:
env:
LSL_RELEASE_URL: "https://github.com/sccn/liblsl/releases/download/v1.17.4"
LSL_RELEASE: "1.17.4"
defaults:
run:
shell: bash
jobs:
# Build pure Python wheel (no bundled library) as fallback
build-pure:
name: Build pure Python wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools-scm
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build pure Python wheel
run: uv build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-pure
path: dist/*
# Build platform-specific wheels with bundled liblsl
build-platform:
name: Build ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: "Windows x64"
os: windows-latest
arch: amd64
pyarch: x64
asset: "liblsl-${LSL_RELEASE}-Win_amd64.zip"
extract: "unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
- name: "Windows x86"
os: windows-latest
arch: i386
pyarch: x86
asset: "liblsl-${LSL_RELEASE}-Win_i386.zip"
extract: "unzip -oj liblsl.zip '*/bin/lsl.dll' -d src/pylsl/lib"
- name: "macOS universal"
os: macos-latest
arch: universal
pyarch: x64
asset: "lsl.xcframework.1.17.zip"
extract: |
unzip xcframework.zip
cp lsl.xcframework/macos-arm64_x86_64/lsl.framework/Versions/A/lsl src/pylsl/lib/liblsl.dylib
- name: "Linux x86_64"
os: ubuntu-latest
arch: x86_64
pyarch: x64
asset: "liblsl-${LSL_RELEASE}-noble_amd64.tar.gz"
extract: |
tar -xzf liblsl.tar.gz
cp liblsl-${LSL_RELEASE}-noble_amd64/lib/liblsl.so* src/pylsl/lib/
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for setuptools-scm
- name: Download liblsl
run: |
ASSET="${{ matrix.config.asset }}"
ASSET="${ASSET//\$\{LSL_RELEASE\}/$LSL_RELEASE}"
if [[ "$ASSET" == *xcframework* ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o xcframework.zip
elif [[ "$ASSET" == *.zip ]]; then
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.zip
else
curl -L "${LSL_RELEASE_URL}/${ASSET}" -o liblsl.tar.gz
fi
- name: Extract liblsl
run: |
mkdir -p src/pylsl/lib
${{ matrix.config.extract }}
- name: List bundled library
run: ls -la src/pylsl/lib/
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
architecture: ${{ matrix.config.pyarch }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build wheel
run: uv build --wheel
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.config.os }}-${{ matrix.config.arch }}
path: dist/*.whl
# Publish all wheels to PyPI
publish:
name: Publish to PyPI
needs: [build-pure, build-platform]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
path: dist
pattern: wheels-*
merge-multiple: true
- name: List wheels
run: ls -la dist/
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Publish to PyPI
if: github.event_name == 'release'
run: uv publish dist/*