Skip to content

Commit 6240678

Browse files
authored
add python release ci (#228)
* add python release ci * add bindings option * add strip option for python * remove sdist temporarily * comment release condition temporarily * fix ci: wrong wheels path
1 parent 61a0fad commit 6240678

File tree

5 files changed

+115
-3
lines changed

5 files changed

+115
-3
lines changed

.github/workflows/python_release.yml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release Python
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- main
10+
paths:
11+
- ".github/workflows/python_release.yml"
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
windows:
19+
runs-on: ${{ matrix.platform.runner }}
20+
strategy:
21+
matrix:
22+
platform:
23+
- runner: windows-latest
24+
target: x64
25+
- runner: windows-latest
26+
target: x86
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: 3.x
32+
architecture: ${{ matrix.platform.target }}
33+
- name: Build wheels
34+
uses: PyO3/maturin-action@v1
35+
with:
36+
target: ${{ matrix.platform.target }}
37+
args: --release --out dist --bindings pyo3 --features=pyo3/extension-module
38+
sccache: "true"
39+
working-directory: "bindings/python"
40+
- name: Upload wheels
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: wheels-windows-${{ matrix.platform.target }}
44+
path: bindings/python/dist
45+
46+
macos:
47+
runs-on: ${{ matrix.platform.runner }}
48+
strategy:
49+
matrix:
50+
platform:
51+
- runner: macos-12
52+
target: x86_64
53+
- runner: macos-14
54+
target: aarch64
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: actions/setup-python@v5
58+
with:
59+
python-version: 3.x
60+
- name: Build wheels
61+
uses: PyO3/maturin-action@v1
62+
with:
63+
target: ${{ matrix.platform.target }}
64+
args: --release --out dist --bindings pyo3 --features=pyo3/extension-module
65+
sccache: "true"
66+
working-directory: "bindings/python"
67+
- name: Upload wheels
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: wheels-macos-${{ matrix.platform.target }}
71+
path: bindings/python/dist
72+
73+
release:
74+
name: Release
75+
environment: release
76+
runs-on: ubuntu-latest
77+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
78+
needs: [windows, macos]
79+
permissions:
80+
# Use to sign the release artifacts
81+
id-token: write
82+
# Used to upload release artifacts
83+
contents: write
84+
# Used to generate artifact attestation
85+
attestations: write
86+
steps:
87+
- uses: actions/download-artifact@v4
88+
- name: Generate artifact attestation
89+
uses: actions/attest-build-provenance@v1
90+
with:
91+
subject-path: "wheels-*/*"
92+
- name: Publish to PyPI
93+
if: "startsWith(github.ref, 'refs/tags/')"
94+
uses: PyO3/maturin-action@v1
95+
with:
96+
command: upload
97+
args: --non-interactive --skip-existing wheels-*/*

bindings/python/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
edition = "2021"
33
name = "tonbo-python"
44
version = "0.1.0"
5+
license = "Apache-2.0"
6+
repository = "https://github.com/tonbo-io/tonbo"
7+
readme = "README.md"
58

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

bindings/python/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ This package intends to build a native python binding for [Tonbo](https://github
44

55
Tonbo's Python bindings can be used to build data-intensive applications, including other types of databases.
66

7+
## Installation
8+
9+
```sh
10+
pip install tonbo
11+
```
12+
713
## Example
814

915
```py

bindings/python/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ classifiers = [
1111
"Programming Language :: Python :: Implementation :: CPython",
1212
"Programming Language :: Python :: Implementation :: PyPy",
1313
]
14+
description = "Tonbo Python Binding"
15+
license = { text = "Apache-2.0" }
1416
dynamic = ["version"]
1517

1618
[project.optional-dependencies]
@@ -23,3 +25,4 @@ features = ["pyo3/extension-module"]
2325

2426
module-name = "tonbo._tonbo"
2527
python-source = "python"
28+
strip = true

bindings/python/python/tonbo/__init__.pyi

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ from tonbo import error as error
44
from tonbo.fs import FsOptions
55

66
@final
7-
class Record: ...
7+
class Record:
8+
def __call__(self) -> None: ...
89

910
@final
1011
class Bound(Enum):
1112
"""Tonbo range for scan. None for unbounded"""
1213

13-
Included = auto()
14-
Excluded = auto()
14+
@staticmethod
15+
def Included(key: Any) -> Bound: ...
16+
@staticmethod
17+
def Excluded(key: Any) -> Bound: ...
1518

1619
@final
1720
class DataType(Enum):

0 commit comments

Comments
 (0)