Skip to content

Commit

Permalink
PyO3 bindings and CD (spruceid#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbihel authored Mar 8, 2022
1 parent 8aaa1ee commit 84b0961
Show file tree
Hide file tree
Showing 13 changed files with 1,186 additions and 1 deletion.
171 changes: 171 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: Release

on:
push:
tags:
- v*
branches:
- feat/pyo3

jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels - x86_64
uses: messense/maturin-action@v1
with:
target: x86_64
args: --release --out dist
- name: Install built wheel - x86_64
run: |
pip install didkit --no-index --find-links dist --force-reinstall
python -c "import didkit"
- name: Build wheels - universal2
uses: messense/maturin-action@v1
with:
args: --release --universal2 --out dist --no-sdist
- name: Install built wheel - universal2
run: |
pip install didkit --no-index --find-links dist --force-reinstall
python -c "import didkit"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --no-sdist
- name: Install built wheel
run: |
pip install didkit --no-index --find-links dist --force-reinstall
python -c "import didkit"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, i686]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: x64
- name: Build Wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist --no-sdist
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
pip install didkit --no-index --find-links dist --force-reinstall
python -c "import didkit"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

linux-cross:
runs-on: ubuntu-latest
strategy:
matrix:
target: [aarch64, armv7, s390x, ppc64le, ppc64]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build Wheels
uses: messense/maturin-action@v1
env:
PYO3_CROSS_LIB_DIR: /opt/python/cp39-cp39/lib
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist --no-sdist
# TODO Cannot find wheels, probably due to wrong Python version?
# - uses: uraimo/[email protected]
# if: matrix.target != 'ppc64'
# name: Install built wheel
# with:
# arch: ${{ matrix.target }}
# distro: ubuntu18.04
# githubToken: ${{ github.token }}
# # Mount the dist directory as /artifacts in the container
# dockerRunArgs: |
# --volume "${PWD}/dist:/artifacts"
# install: |
# apt-get update
# apt-get install -y --no-install-recommends python3 python3-pip
# pip3 install -U pip
# run: |
# ls -lrth /artifacts
# pip3 install didkit --no-index --find-links /artifacts --force-reinstall
# python3 -c "import didkit"
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

# TODO Add pypy

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, linux, linux-cross ] # windows,
steps:
- uses: actions/download-artifact@v2
with:
name: wheels
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install --upgrade twine
twine upload --skip-existing *
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
Cargo.lock
__pycache__/
54 changes: 54 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[package]
name = "didkit"
version = "0.3.0"
authors = ["Spruce Systems, Inc."]
edition = "2018"
description = "Library for Verifiable Credentials and Decentralized Identifiers."
license = "Apache-2.0"
license-file = "LICENSE"
homepage = "https://spruceid.dev/docs/didkit/"
repository = "https://github.com/spruceid/didkit/"
documentation = "https://docs.rs/didkit/"
keywords = ["ssi", "did", "python"]
readme = "README.md"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
didkit_core = { version = "0.4", default-features = false, features = ["secp256k1", "p256", "no-ring"], package = "didkit" }
serde_json = "1.0"

pyo3 = { version = "0.15", features = ["extension-module"] }
pyo3-asyncio = { version = "0.15", features = ["tokio-runtime"] }
tokio = "1.17"

[build-dependencies]
pyo3-build-config = "0.16"

[package.metadata.maturin]
classifier = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Security",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]

[package.metadata.maturin.project-url]
"Source Code" = "https://github.com/spruceid/didkit-python/"
"Bug Tracker" = "https://github.com/spruceid/didkit-python/issues"
"Documentation" = "https://github.com/spruceid/didkit-python/"

[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
Loading

0 comments on commit 84b0961

Please sign in to comment.