feat: add Python SDK including core modules, tests, examples, and CI … #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python SDK | ||
| 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/* | ||