Skip to content

feat: add Python SDK including core modules, tests, examples, and CI … #1

feat: add Python SDK including core modules, tests, examples, and CI …

feat: add Python SDK including core modules, tests, examples, and CI … #1

Workflow file for this run

name: Python SDK

Check failure on line 1 in .github/workflows/python-sdk.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/python-sdk.yml

Invalid workflow file

(Line: 29, Col: 5): 'runs-on' is already defined, (Line: 35, Col: 5): 'steps' is already defined
on:
push:
branches: [ main ]
tags:
- 'python-v*'
pull_request:
paths:
- 'sdk/python/**'
- 'crates/**'
- 'Cargo.toml'
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install maturin pytest pytest-cov
- name: Build extension
run: |
cd sdk/python
maturin develop
- name: Run tests
run: |
cd sdk/python
pytest tests/ -v --cov=lnmp --cov-report=term-missing
build:
name: Build wheels
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install maturin
- name: Build wheels
run: |
cd sdk/python
maturin build --release
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: sdk/python/target/wheels/*.whl
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install maturin twine
- name: Build and publish
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
cd sdk/python
maturin publish --non-interactive --skip-existing dist/*