Skip to content

Commit 212b179

Browse files
authored
Merge pull request #48 from TobiX/modern-py
Modernize Python build a bit
2 parents ebc5d41 + 5d69cdc commit 212b179

4 files changed

Lines changed: 40 additions & 69 deletions

File tree

.github/workflows/pypi_release.yml

Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
---
12
name: Publish to PyPI
23

34
on:
4-
workflow_dispatch:
5+
workflow_dispatch:
56

67
jobs:
78
build_wheels:
8-
name: Build wheels on ${{ matrix.os }} for ${{ matrix.cibw_python }} on ${{ matrix.cibw_arch }}
9+
name: Build wheels on ${{ matrix.os }}
910
runs-on: ${{ matrix.os }}
1011
strategy:
1112
matrix:
12-
os: [ubuntu-latest]
13-
cibw_arch: ["x86_64", "aarch64"]
13+
os: [ubuntu-latest, ubuntu-24.04-arm]
1414
env:
1515
CIBW_BEFORE_ALL_LINUX: "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y"
1616
CIBW_BUILD_VERBOSITY: "1"
@@ -19,68 +19,35 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v4
2121

22-
- name: Set up QEMU
23-
if: matrix.os == 'ubuntu-latest' && matrix.cibw_arch == 'aarch64'
24-
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
25-
with:
26-
platforms: arm64
27-
2822
- name: Build wheels
29-
uses: pypa/cibuildwheel@v2.16.2
23+
uses: pypa/cibuildwheel@v3.0
3024
env:
31-
CIBW_BUILD_VERBOSITY: 1
32-
CIBW_BUILD: ${{ matrix.cibw_python }}
33-
CIBW_ARCHS: ${{ matrix.cibw_arch }}
34-
CIBW_TEST_SKIP: "*universal2:arm64"
25+
CIBW_BUILD: "cp313-*"
3526
with:
36-
package-dir: ./python
37-
output-dir: ./python/wheelhouse
27+
package-dir: python
28+
output-dir: python/wheelhouse
3829

39-
- uses: actions/upload-artifact@v3
30+
- uses: actions/upload-artifact@v4
4031
with:
41-
name: dist
42-
path: ./python/wheelhouse/*.whl
43-
44-
build_sdist:
45-
name: Build source distribution
46-
runs-on: ubuntu-latest
47-
steps:
48-
- uses: actions/checkout@v2
32+
name: cibw-wheels-${{ matrix.os }}
33+
path: python/wheelhouse/*.whl
4934

50-
- name: Install rust
51-
uses: actions-rs/toolchain@v1
52-
with:
53-
toolchain: stable
54-
profile: minimal
55-
56-
- uses: actions/setup-python@v2
57-
name: Install Python
58-
with:
59-
python-version: "3.12"
60-
61-
- name: Build sdist
62-
run: |
63-
python -m pip install setuptools-rust setuptools wheel
64-
cd python/
65-
python setup.py sdist
66-
67-
- uses: actions/upload-artifact@v2
68-
with:
69-
name: dist
70-
path: python/dist/*.tar.*
71-
7235
release:
73-
needs: [build_wheels, build_sdist]
36+
needs: [build_wheels]
7437
runs-on: ubuntu-latest
38+
environment:
39+
name: pypi
40+
url: https://pypi.org/p/sqlite-zstd
41+
permissions:
42+
id-token: write
43+
if: github.event_name == 'push' && github.ref_type == 'tag'
7544
steps:
76-
- uses: actions/download-artifact@v3
45+
- uses: actions/download-artifact@v4
7746
with:
78-
name: dist
79-
path: python/dist/
47+
pattern: cibw-*
48+
path: dist
49+
merge-multiple: true
8050

81-
- uses: pypa/gh-action-pypi-publish@v1.8.10
51+
- uses: pypa/gh-action-pypi-publish@release/v1
8252
with:
83-
repository-url: https://pypi.org/project/sqlite-zstd-build
84-
user: __token__
85-
password: ${{ secrets.PYPI_API_TOKEN }}
86-
packages-dir: python/dist
53+
packages-dir: dist

python/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ Depending on the data, this can reduce the size of the database by 80% while kee
88
Note that a compression VFS such as https://github.com/mlin/sqlite_zstd_vfs might be suited better depending on the use case. That has very different tradeoffs and capabilities, but the end result is similar.
99

1010
## Install
11+
12+
From PyPI (if published):
1113
```bash
1214
pip install sqlite-zstd
1315
```
16+
Local:
17+
```bash
18+
pip install .
19+
```
1420

1521
## Usage
1622
```python

python/pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools>=61.2", "setuptools_scm>=6.2", "setuptools_rust"]
2+
requires = ["setuptools>=64", "setuptools-scm>=8", "setuptools-rust"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
@@ -19,3 +19,12 @@ sqlite_zstd = "lib"
1919

2020
[tool.setuptools_scm]
2121
root = ".."
22+
23+
[[tool.setuptools-rust.ext-modules]]
24+
target = "sqlite_zstd.libsqlite_zstd"
25+
path = "../Cargo.toml"
26+
binding = "NoBinding"
27+
features = ["build_extension"]
28+
29+
[tool.distutils.bdist_wheel]
30+
py_limited_api = "cp39"

python/setup.py

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

0 commit comments

Comments
 (0)