Skip to content

Commit

Permalink
Add CI job to publish to PyPI.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylc committed Nov 25, 2023
1 parent ed6bc79 commit d2adf2e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
50 changes: 43 additions & 7 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: python

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
build_wheels:
Expand All @@ -11,7 +11,7 @@ jobs:
- os: ubuntu-latest
target: x86_64
- os: macos-latest
target: universal2-apple-darwin
target: x86_64

steps:
- name: checkout
Expand All @@ -28,30 +28,50 @@ jobs:
with:
python-version: 3.9
architecture: x64
- uses: Swatinem/rust-cache@v2
- name: build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
manylinux: auto
args: --release -m crates/optik-py/Cargo.toml --out dist
sccache: true
- name: delocate wheel (macOS)
if: runner.os == 'macOS'
run: |
pip install delocate
delocate-wheel -v dist/*.whl
- name: install built wheel
run: |
pip install optik_py --no-index --find-links dist
pip install optik --no-index --find-links dist
python -c "import optik"
- name: upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

upload_release:
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path crates/optik-py/Cargo.toml
- name: upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

prerelease:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
concurrency:
group: push-${{ github.ref_name }}-prerelease
cancel-in-progress: true
needs: [build_wheels]
needs: [build_wheels, sdist]
steps:
- uses: dev-drprasad/[email protected]
with:
Expand All @@ -75,3 +95,19 @@ jobs:
removeArtifacts: true
replacesArtifacts: true
artifacts: "wheels/*"

public:
name: publish to PyPI
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [build_wheels, sdist]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Timing is of a single inverse kinematics solve.

### Python

``` sh
python3 -m pip install optik
```

Or, to install a prerelease version:

1. Download a recent `.whl` from [GitHub Releases](https://github.com/kylc/optik/releases)
2. Run `pip install optik<...>.whl` (replace `<...>` with the actual filename)
3. Test it: `python -c 'import optik'`
Expand Down
25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[project]
name = "optik"
version = "0.1.0"
description = "An optimizing IK solver based on the Lie group of rigid transforms SE(3)"
readme = "README.md"
requires-python = ">=3.8"
license = "MIT OR Apache-2.0"
authors = [
{email = "[email protected]"},
{name = "Kyle Cesare"}
]
classifiers = [
"Topic :: Scientific/Engineering"
]
dependencies = []

[project.urls]
homepage = "https://github.com/kylc/optik"

[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.maturin]
manifest-path = "crates/optik-py/Cargo.toml"

0 comments on commit d2adf2e

Please sign in to comment.