Skip to content

Commit

Permalink
Python package restructuring (#77)
Browse files Browse the repository at this point in the history
* use uv and mkdocs, add dependencies to pyproject.toml, restructured source, added stub

* fix python extension package test

* changes to pyproject.toml

* more examples and info in docs, removed SIArray1 in favor of python functions, updated stubs, fixed typos

* fix merge conflict

* changed root Cargo.toml (removed workspace), renamed array1 to array, added correct installation docs

* fix import

* updated release gh-action and fixed typo in mkdocs config

* add crates back as workspace members

* write extend_quantity as declarative pyo3 module

* Remove doctests from CI

* split release workflow

* readd win32 and use matrix for macos

* fix matrix

* also update pypi release workflow

---------

Co-authored-by: Philipp Rehner <[email protected]>
  • Loading branch information
g-bauer and prehner authored Dec 26, 2024
1 parent bc9a097 commit 7f895e7
Show file tree
Hide file tree
Showing 33 changed files with 1,215 additions and 726 deletions.
140 changes: 0 additions & 140 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,143 +22,3 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: publish

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Build Wheels
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-linux-x86_64
path: dist

macos-x86_64:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- name: Build wheels - x86_64
uses: PyO3/maturin-action@v1
with:
target: x86_64
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-macos-x86_64
path: dist

macos-aarch64:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: arm64
- name: Build wheels - aarch64
uses: PyO3/maturin-action@v1
with:
target: aarch64
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-aarch64-apple-darwin
path: dist

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: x64
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-windows-x64
path: dist

deploy-pypi:
name: Publish wheels to PyPI and TestPyPI
runs-on: ubuntu-latest
needs: [linux, windows, macos-x86_64, macos-aarch64]
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheel-*
path: wheels
merge-multiple: true
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install --upgrade twine
twine upload --skip-existing wheels/*
build-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install python dependencies
run: |
pip install sphinx sphinx-rtd-theme numpydoc
- name: Build Wheels
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
args: --release --out dist -m si-units/Cargo.toml
- name: Install module
run: |
pip install si-units --no-index --find-links dist --force-reinstall
- name: Build documentation
run: sphinx-build si-units/docs/ public/ -b html
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: public

release-documentation:
needs: [build-documentation]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: documentation
path: public
- name: Deploy documentation to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
49 changes: 49 additions & 0 deletions .github/workflows/release_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release Documentation

on:
push:
branches: [master]

jobs:
build-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install python dependencies
run: |
pip install mkdocs-material mkdocstrings-python
- name: Build Wheels
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
args: --release --out dist -m si-units/Cargo.toml
- name: Install module
run: |
pip install si-units --no-index --find-links dist --force-reinstall
- name: Build documentation
run: mkdocs build -f si-units/mkdocs.yml -d ../public
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: documentation
path: public

release-documentation:
needs: [build-documentation]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: documentation
path: public
- name: Deploy documentation to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
90 changes: 90 additions & 0 deletions .github/workflows/release_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release PyPI

on:
push:
tags: ["s-units-v*"]

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Build Wheels
uses: PyO3/maturin-action@v1
with:
manylinux: auto
command: build
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-linux-x86_64
path: dist

macos:
strategy:
matrix:
target: [ {arch: x64, target: x86_64}, {arch: arm64, target: aarch64} ]
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: ${{ matrix.target.arch }}
- name: Build wheels - ${{ matrix.target.target }}
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target.target }}
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-macos-${{ matrix.target.target }}
path: dist

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist -m si-units/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-windows-${{ matrix.target }}
path: dist

deploy-pypi:
name: Publish wheels to PyPI and TestPyPI
runs-on: ubuntu-latest
needs: [linux, windows, macos]
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheel-*
path: wheels
merge-multiple: true
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
pip install --upgrade twine
twine upload --skip-existing wheels/*
34 changes: 0 additions & 34 deletions .github/workflows/test_documentation.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -30,6 +30,7 @@ jobs:
maturin build --release --out dist
pip install extend_quantity --no-index --find-links dist --force-reinstall
- name: Build wheels for si-units
working-directory: ./si-units
run: |
maturin build --release --out dist
pip install si-units --no-index --find-links dist --force-reinstall
Expand Down
Loading

0 comments on commit 7f895e7

Please sign in to comment.