Skip to content

Commit 91e9867

Browse files
authored
Github Actions builds for Python client (#18)
* Setup Github Actions builds for Python client * unify js and python releases (triggered by github release) * reduce build churn: run mac/win only after linux * ignore some paths in PR build trigger * name python builder workflow
1 parent b77a93f commit 91e9867

File tree

5 files changed

+175
-38
lines changed

5 files changed

+175
-38
lines changed

.github/workflows/build-js.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
name: Build the SDK
1+
name: Build JavaScript SDK
22

33
on:
44
push:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8+
paths-ignore:
9+
- 'docs/**'
10+
- 'examples/**'
11+
- '**.md'
12+
- 'python/**'
813
workflow_dispatch:
914

1015
jobs:
@@ -51,3 +56,34 @@ jobs:
5156
with:
5257
name: sdk
5358
path: dist/
59+
60+
# TODO: dedupe build steps from publish
61+
client-publish:
62+
name: Publish JavaScript SDK
63+
runs-on: ubuntu-latest
64+
if: github.event_name == 'release' && github.event.action == 'published'
65+
needs: [client-build]
66+
steps:
67+
- uses: actions/checkout@v3
68+
- uses: actions/setup-node@v3
69+
with:
70+
node-version: '19.x'
71+
registry-url: 'https://registry.npmjs.org'
72+
73+
- name: Install wasm-pack
74+
uses: jetli/wasm-pack-action@f98777369a49686b132a9e8f0fdd59837bf3c3fd
75+
with:
76+
version: v0.10.3
77+
78+
- name: Install dependencies
79+
run: |
80+
npm ci
81+
82+
- name: Run build
83+
run: |
84+
npm run build
85+
86+
- name: Publish to NPM
87+
run: npm publish
88+
env:
89+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/build-python.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Build Python SDK
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
paths-ignore:
9+
- 'docs/**'
10+
- 'examples/**'
11+
- '**.md'
12+
- 'js/**'
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
linux:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
target: [x86_64, aarch64]
24+
steps:
25+
- uses: actions/checkout@v3
26+
- uses: actions/setup-python@v4
27+
with:
28+
python-version: '3.10'
29+
- name: Build wheels
30+
uses: PyO3/maturin-action@v1
31+
with:
32+
working-directory: python
33+
target: ${{ matrix.target }}
34+
args: --release --out dist --find-interpreter
35+
sccache: 'true'
36+
manylinux: auto
37+
- name: Upload wheels
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: wheels
41+
path: python/dist
42+
43+
windows:
44+
runs-on: windows-latest
45+
needs: [linux]
46+
strategy:
47+
matrix:
48+
target: [x64]
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: actions/setup-python@v4
52+
with:
53+
python-version: '3.10'
54+
architecture: ${{ matrix.target }}
55+
- name: Build wheels
56+
uses: PyO3/maturin-action@v1
57+
with:
58+
working-directory: python
59+
target: ${{ matrix.target }}
60+
args: --release --out dist --find-interpreter
61+
sccache: 'true'
62+
- name: Upload wheels
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: wheels
66+
path: python/dist
67+
68+
macos:
69+
runs-on: macos-latest
70+
needs: [linux]
71+
strategy:
72+
matrix:
73+
target: [x86_64, aarch64]
74+
steps:
75+
- uses: actions/checkout@v3
76+
- uses: actions/setup-python@v4
77+
with:
78+
python-version: '3.10'
79+
- name: Build wheels
80+
uses: PyO3/maturin-action@v1
81+
with:
82+
working-directory: python
83+
target: ${{ matrix.target }}
84+
args: --release --out dist --find-interpreter
85+
sccache: 'false'
86+
- name: Upload wheels
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: wheels
90+
path: python/dist
91+
92+
sdist:
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@v3
96+
- name: Build sdist
97+
uses: PyO3/maturin-action@v1
98+
with:
99+
working-directory: python
100+
command: sdist
101+
args: --out dist
102+
- name: Upload sdist
103+
uses: actions/upload-artifact@v3
104+
with:
105+
name: wheels
106+
path: python/dist
107+
108+
publish:
109+
name: Publish
110+
runs-on: ubuntu-latest
111+
if: github.event_name == 'release' && github.event.action == 'published'
112+
needs: [linux, macos, windows, sdist]
113+
steps:
114+
- uses: actions/download-artifact@v3
115+
with:
116+
name: wheels
117+
- name: Publish to PyPI
118+
uses: PyO3/maturin-action@v1
119+
env:
120+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
121+
with:
122+
command: upload
123+
args: --skip-existing *

.github/workflows/publish-to-npm.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ The Node.js example shows how to use the Blyss SDK in server-side JS. Node 18+ i
9090

9191
### Python
9292

93-
The Blyss SDK for Python is still in development.
93+
1. Enter `examples/python`.
94+
2. Run `pip install blyss`.
95+
3. Run `python main.py`.
9496

9597
## Documentation
9698

@@ -100,25 +102,32 @@ All documentation is available at [docs.blyss.dev](https://docs.blyss.dev). You
100102

101103
Please feel free to open issues and pull requests! For bugs, try to provide as much context as possible. We are also always open to documentation contributions.
102104

103-
## Building
105+
## Building from source
104106

105-
Steps to building the SDK:
107+
### JavaScript / Node
106108

107109
1. Install Node with [nvm](https://github.com/nvm-sh/nvm#installing-and-updating), Rust with [rustup](https://rustup.rs/), and [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/).
108110
2. Run `npm install`.
109111
3. Run `npm run build`.
110112

111113
This will build the complete SDK, including the core Rust libraries in `lib/spiral-rs` and `lib/doublepir`
112114

113-
The SDK is structured as:
115+
### Python
116+
117+
Requires python 3.8+.
118+
1. Run `pip install .` in `python`.
119+
120+
## Repository Map
121+
122+
The Blyss SDK is structured as:
114123

115124
1. `lib/`,
116125
- `lib/server/`, a Rust project containing the open-source Blyss server.
117126
- `lib/spiral-rs/`, a Rust crate containing the core cryptographic implementation of the [Spiral PIR scheme](https://eprint.iacr.org/2022/368).
118127
- `lib/doublepir/`, a Rust crate containing the core cryptographic implementation of the [DoublePIR scheme](https://eprint.iacr.org/2022/949).
119128
2. `js/`, the TypeScript code that implements the user-facing Blyss SDK.
120129
- `js/bridge/`, a Rust "bridge" crate that exposes key functionality from `spiral-rs` and `doublepir` to the TypeScript code.
121-
3. `python/`, the Python version of the SDK (still in development)
130+
3. `python/`, the Python version of the SDK.
122131
- `python/src/lib.rs`, another Rust "bridge" crate that exposes key functionality from `spiral-rs` to the Python code.
123132

124133
## License

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["maturin>=0.13,<0.14"]
2+
requires = ["maturin>=0.14,<0.15"]
33
build-backend = "maturin"
44

55
[project]

0 commit comments

Comments
 (0)