Skip to content

Commit 4a10fe1

Browse files
committed
Move to own repo from posit-dev/ggsql
0 parents  commit 4a10fe1

11 files changed

Lines changed: 2754 additions & 0 deletions

File tree

.github/python.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Python
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
python: ["3.10", "3.11", "3.12", "3.13"]
16+
include:
17+
- os: ubuntu-latest
18+
delay: 140
19+
- os: macos-latest
20+
delay: 210
21+
- os: windows-latest
22+
delay: 70
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python }}
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: "22"
34+
35+
- name: Install tree-sitter-cli
36+
run: npm install -g tree-sitter-cli
37+
38+
- name: Install Rust
39+
uses: dtolnay/rust-toolchain@stable
40+
41+
- name: Stagger start by OS
42+
run: sleep ${{ matrix.delay }}s
43+
shell: bash
44+
45+
- name: Rust cache
46+
uses: Swatinem/rust-cache@v2
47+
with:
48+
shared-key: ${{ matrix.os }}-python
49+
cache-on-failure: true
50+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.python == '3.13' }}
51+
52+
- name: Set up MSVC (Windows)
53+
if: runner.os == 'Windows'
54+
uses: ilammy/msvc-dev-cmd@v1
55+
56+
- name: Check Rust formatting
57+
run: cargo fmt --package ggsql-python -- --check
58+
59+
- name: Clippy
60+
run: cargo clippy --package ggsql-python -- -D warnings
61+
62+
- name: Build wheel
63+
uses: PyO3/maturin-action@v1
64+
with:
65+
command: build
66+
args: --release
67+
sccache: false
68+
69+
- name: Install wheel and test dependencies
70+
shell: bash
71+
run: |
72+
WHEEL=$(ls target/wheels/ggsql-*.whl)
73+
pip install "${WHEEL}[test]"
74+
75+
- name: Run tests
76+
shell: bash
77+
run: pytest tests/ -v

.github/release-python.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Python Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "py/v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
env:
13+
# Must match the abi3-py3XX feature in ggsql-python/Cargo.toml.
14+
# abi3 wheels built against 3.10 are forward-compatible with all later
15+
# Python versions, so this should be the minimum supported version.
16+
PYTHON_VERSION: "3.10"
17+
18+
jobs:
19+
generate:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: "22"
27+
28+
- name: Install tree-sitter-cli
29+
run: npm install -g tree-sitter-cli
30+
31+
- name: Generate parser
32+
working-directory: tree-sitter-ggsql
33+
run: tree-sitter generate
34+
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
name: tree-sitter-generated
38+
path: tree-sitter-ggsql/src/
39+
40+
linux:
41+
needs: generate
42+
runs-on: ubuntu-latest
43+
strategy:
44+
matrix:
45+
target: [x86_64, aarch64]
46+
env:
47+
GGSQL_SKIP_GENERATE: "1"
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: tree-sitter-generated
54+
path: tree-sitter-ggsql/src/
55+
56+
- uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{ env.PYTHON_VERSION }}
59+
60+
- name: Build wheels
61+
uses: PyO3/maturin-action@v1
62+
with:
63+
target: ${{ matrix.target }}
64+
args: --release --out dist --interpreter python${{ env.PYTHON_VERSION }}
65+
# manylinux2014's cross-compiler is too old for the `ring` crate's
66+
# aarch64 assembly (missing __ARM_ARCH). 2_28 (AlmaLinux 8, gcc 8+)
67+
# provides a new enough toolchain.
68+
manylinux: 2_28
69+
# Forward GGSQL_SKIP_GENERATE into the Docker container so the
70+
# build script uses the pre-generated parser files.
71+
docker-options: -e GGSQL_SKIP_GENERATE=1
72+
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: wheels-linux-${{ matrix.target }}
76+
path: dist
77+
78+
macos:
79+
needs: generate
80+
runs-on: ${{ matrix.runner }}
81+
strategy:
82+
matrix:
83+
include:
84+
- target: x86_64
85+
runner: macos-latest
86+
- target: aarch64
87+
runner: macos-latest
88+
env:
89+
GGSQL_SKIP_GENERATE: "1"
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- uses: actions/download-artifact@v4
94+
with:
95+
name: tree-sitter-generated
96+
path: tree-sitter-ggsql/src/
97+
98+
- uses: actions/setup-python@v5
99+
with:
100+
python-version: ${{ env.PYTHON_VERSION }}
101+
102+
- name: Build wheels
103+
uses: PyO3/maturin-action@v1
104+
with:
105+
target: ${{ matrix.target }}
106+
args: --release --out dist --interpreter python${{ env.PYTHON_VERSION }}
107+
108+
- uses: actions/upload-artifact@v4
109+
with:
110+
name: wheels-macos-${{ matrix.target }}
111+
path: dist
112+
113+
windows:
114+
needs: generate
115+
runs-on: windows-latest
116+
env:
117+
GGSQL_SKIP_GENERATE: "1"
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- uses: actions/download-artifact@v4
122+
with:
123+
name: tree-sitter-generated
124+
path: tree-sitter-ggsql/src/
125+
126+
- uses: actions/setup-python@v5
127+
with:
128+
python-version: ${{ env.PYTHON_VERSION }}
129+
130+
- name: Build wheels
131+
uses: PyO3/maturin-action@v1
132+
with:
133+
target: x64
134+
args: --release --out dist --interpreter python${{ env.PYTHON_VERSION }}
135+
136+
- uses: actions/upload-artifact@v4
137+
with:
138+
name: wheels-windows-x64
139+
path: dist
140+
141+
sdist:
142+
needs: generate
143+
runs-on: ubuntu-latest
144+
env:
145+
GGSQL_SKIP_GENERATE: "1"
146+
steps:
147+
- uses: actions/checkout@v4
148+
149+
- uses: actions/download-artifact@v4
150+
with:
151+
name: tree-sitter-generated
152+
path: tree-sitter-ggsql/src/
153+
154+
- name: Build sdist
155+
uses: PyO3/maturin-action@v1
156+
with:
157+
command: sdist
158+
args: --out dist
159+
160+
- uses: actions/upload-artifact@v4
161+
with:
162+
name: wheels-sdist
163+
path: dist
164+
165+
publish:
166+
needs: [linux, macos, windows, sdist]
167+
runs-on: ubuntu-latest
168+
if: startsWith(github.ref, 'refs/tags/')
169+
environment: pypi
170+
permissions:
171+
id-token: write
172+
steps:
173+
- uses: actions/download-artifact@v4
174+
with:
175+
pattern: wheels-*
176+
merge-multiple: true
177+
path: dist
178+
179+
- name: List wheels
180+
run: ls -lh dist/
181+
182+
- name: Publish to PyPI
183+
uses: pypa/gh-action-pypi-publish@release/v1
184+
185+
github-release:
186+
needs: publish
187+
runs-on: ubuntu-latest
188+
if: startsWith(github.ref, 'refs/tags/')
189+
permissions:
190+
contents: write
191+
steps:
192+
- uses: actions/download-artifact@v4
193+
with:
194+
pattern: wheels-*
195+
merge-multiple: true
196+
path: dist
197+
198+
- name: Create GitHub Release
199+
uses: softprops/action-gh-release@v2
200+
with:
201+
files: dist/*

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Python bindings
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
MANIFEST
23+
24+
# Python virtual environments
25+
venv/
26+
env/
27+
ENV/
28+
env.bak/
29+
venv.bak/
30+
.venv/

Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "ggsql-python"
3+
version = "0.2.7"
4+
edition = "2021"
5+
authors.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
homepage.workspace = true
9+
description = "Python bindings for ggsql"
10+
11+
[lib]
12+
name = "_ggsql"
13+
crate-type = ["cdylib"]
14+
15+
[dependencies]
16+
pyo3 = { version = "0.26", features = ["extension-module", "abi3-py310"] }
17+
polars = { workspace = true, features = ["ipc"] }
18+
ggsql = { path = "../src", default-features = false, features = ["duckdb", "vegalite"] }
19+
20+
[features]
21+
default = []

0 commit comments

Comments
 (0)