Skip to content

Commit

Permalink
Major refactor:
Browse files Browse the repository at this point in the history
* Use uv for build
* Separate into submodules
* Add first test
  • Loading branch information
cboulay committed Dec 7, 2024
1 parent b62de2e commit a16d763
Show file tree
Hide file tree
Showing 29 changed files with 1,964 additions and 2,045 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Continuous Integration

on:
push:
branches: [main]
pull_request:
branches:
- main
workflow_dispatch:

env:
LSL_RELEASE_URL: "https://github.com/sccn/liblsl/releases/download/"
LSL_RELEASE: "1.16.2"

jobs:

style:
name: Check style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v1
- uses: astral-sh/ruff-action@v1
with:
args: "format --check"

test:
needs: style
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-latest", "windows-latest", "macOS-latest"]

name: Run tests (${{ matrix.os }} Python ${{ matrix.python-version }})
runs-on: ${{ matrix.config.os }}
steps:
- name: Install liblsl (MacOS)
if: matrix.os == 'macos-latest'
run: brew install labstreaminglayer/tap/lsl
- name: Install liblsl (Ubuntu)
if: startsWith(matrix.os, 'ubuntu-')
run: |
sudo apt install -y libpugixml-dev
curl -L ${LSL_RELEASE_URL}/v${LSL_RELEASE}/liblsl-${LSL_RELEASE}-$(lsb_release -sc)_amd64.deb -o liblsl.deb
sudo apt install ./liblsl.deb
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }})
- name: Build
run: uv sync --all-extras
- name: Run tests
run: uv run pytest
48 changes: 12 additions & 36 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
name: Build and publish Python 🐍 distributions 📦 to PyPI

on:
release:
types: [published]

env:
LSL_RELEASE_URL: 'https://github.com/sccn/liblsl/releases/download/v1.16.2/'
LSL_RELEASE: '1.16.2'
LSL_RELEASE_URL: "https://github.com/sccn/liblsl/releases/download/"
LSL_RELEASE: "1.16.2"

defaults:
run:
Expand All @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
config:
- name: "ubuntu-22.04"
- name: "ubuntu-24.04"
os: "ubuntu-latest"
pyarch: "x64"
- name: "windows-x64"
Expand All @@ -32,44 +32,20 @@ jobs:
arch: "i386"
pyarch: "x86"
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- name: Download liblsl (Windows)
if: matrix.config.os == 'windows-latest'
run: |
curl -L ${LSL_RELEASE_URL}/liblsl-${LSL_RELEASE}-Win_${{ matrix.config.arch}}.zip -o liblsl.zip
curl -L ${LSL_RELEASE_URL}/v${LSL_RELEASE}/liblsl-${LSL_RELEASE}-Win_${{ matrix.config.arch}}.zip -o liblsl.zip
unzip -oj liblsl.zip bin/lsl* -d pylsl/lib
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: "3.x"
architecture: ${{ matrix.config.pyarch }}
- name: Install pypa/build
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build --wheel --outdir dist/
- name: Publish using Twine (Windows)
if: matrix.config.os == 'windows-latest'
run: |
python -m twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}

# This fails because I don't have access to `pylsl` project there.
# - name: Publish distribution 📦 to Test PyPI
# if: (github.event.release.prerelease && (matrix.config.os != 'windows-latest'))
# uses: pypa/gh-action-pypi-publish@unstable/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# skip_existing: true
#
- name: Publish distribution 📦 to PyPI
if: ((matrix.config.os != 'windows-latest') && !github.event.release.prerelease)
uses: pypa/gh-action-pypi-publish@unstable/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build Package
run: uv build
- name: Publish package distributions to PyPI
run: uv publish
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ __pycache__
*.cprof
*.png
/wheelhouse/
/pylsl/include
/pylsl/lib
/pylsl/share
/src/pylsl/include
/src/pylsl/share
.DS_Store

uv.lock
/src/pylsl/__version__.py
51 changes: 0 additions & 51 deletions pylsl/__init__.py

This file was deleted.

Loading

0 comments on commit a16d763

Please sign in to comment.