Skip to content

Commit ef4b6d0

Browse files
authored
fix: packaging (#51)
* fix: packaging * fix: ci building * fix: don't do a beta * ci: switch back to stable * fix: add maturin to dev dependencies We use it in our test script * fix: ci path * nit: two lines
1 parent 5b2df1a commit ef4b6d0

File tree

11 files changed

+540
-217
lines changed

11 files changed

+540
-217
lines changed

.github/workflows/ci.yml

+6-29
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
lint-test:
15-
name: Lint and Test
14+
test:
15+
name: Test
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v3
@@ -21,33 +21,10 @@ jobs:
2121
with:
2222
components: rustfmt, clippy
2323
- uses: Swatinem/rust-cache@v2
24-
- name: cargo fmt
25-
run: cargo fmt --all --check
26-
- name: cargo clippy
27-
run: cargo clippy --tests --workspace -- -D warnings
28-
- name: cargo check
29-
run: cargo check --workspace
30-
- name: cargo test
31-
run: cargo test
32-
python-test:
33-
name: Test Python
34-
runs-on: ubuntu-latest
35-
defaults:
36-
run:
37-
working-directory: python
38-
steps:
39-
- uses: actions/checkout@v4
4024
- uses: astral-sh/setup-uv@v3
41-
with:
42-
enable-cache: true
43-
- uses: actions/setup-python@v5
44-
with:
45-
python-version-file: python/.python-version
46-
- name: Install
47-
run: uv sync --dev
48-
- name: Check
49-
run: uv run mypy . && uv run ruff check && uv run ruff format --check
25+
- name: Lint
26+
run: scripts/lint
5027
- name: Test
51-
run: uv run pytest
28+
run: scripts/test
5229
- name: CLI smoke test
53-
run: uv run cql2 < ../examples/text/example01.txt
30+
run: uv run cql2 < examples/text/example01.txt

.github/workflows/python.yml

+5-16
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@ name: Python
22

33
on:
44
push:
5-
branches:
6-
- main
75
tags:
86
- "v*"
9-
paths:
10-
- python/**
11-
pull_request:
12-
paths:
13-
- python/**
147
workflow_dispatch:
158

169
concurrency:
@@ -47,7 +40,7 @@ jobs:
4740
uses: PyO3/maturin-action@v1
4841
with:
4942
target: ${{ matrix.platform.target }}
50-
args: --release --out dist --find-interpreter -m python/Cargo.toml
43+
args: --release --out dist --find-interpreter
5144
sccache: "true"
5245
manylinux: auto
5346
- name: Upload wheels
@@ -78,7 +71,7 @@ jobs:
7871
uses: PyO3/maturin-action@v1
7972
with:
8073
target: ${{ matrix.platform.target }}
81-
args: --release --out dist --find-interpreter -m python/Cargo.toml
74+
args: --release --out dist --find-interpreter
8275
sccache: "true"
8376
manylinux: musllinux_1_2
8477
- name: Upload wheels
@@ -106,7 +99,7 @@ jobs:
10699
uses: PyO3/maturin-action@v1
107100
with:
108101
target: ${{ matrix.platform.target }}
109-
args: --release --out dist --find-interpreter -m python/Cargo.toml
102+
args: --release --out dist --find-interpreter
110103
sccache: "true"
111104
- name: Upload wheels
112105
uses: actions/upload-artifact@v4
@@ -132,7 +125,7 @@ jobs:
132125
uses: PyO3/maturin-action@v1
133126
with:
134127
target: ${{ matrix.platform.target }}
135-
args: --release --out dist --find-interpreter -m python/Cargo.toml
128+
args: --release --out dist --find-interpreter
136129
sccache: "true"
137130
- name: Upload wheels
138131
uses: actions/upload-artifact@v4
@@ -148,8 +141,7 @@ jobs:
148141
uses: PyO3/maturin-action@v1
149142
with:
150143
command: sdist
151-
args: --out dist -m python/Cargo.toml
152-
maturin-version: "v1.6.0" # pinned below 1.7 until https://github.com/PyO3/maturin/issues/2244 is resolved
144+
args: --out dist
153145
- name: Upload sdist
154146
uses: actions/upload-artifact@v4
155147
with:
@@ -162,11 +154,8 @@ jobs:
162154
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
163155
needs: [linux, musllinux, windows, macos, sdist]
164156
permissions:
165-
# Use to sign the release artifacts
166157
id-token: write
167-
# Used to upload release artifacts
168158
contents: write
169-
# Used to generate artifact attestation
170159
attestations: write
171160
steps:
172161
- uses: actions/download-artifact@v4

README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,29 @@ Responses may not match the input.
4242

4343
## Development
4444

45-
See [CONTRIBUTING.md](./CONTRIBUTING.md) for information about contributing to this project.
45+
Get [uv](https://docs.astral.sh/uv/getting-started/installation/) and [Rust](https://rustup.rs/).
46+
Then:
47+
48+
```shell
49+
git clone [email protected]:developmentseed/cql2-rs.git
50+
cd cql2-rs
51+
uv sync
52+
scripts/test
53+
```
54+
55+
To lint all files:
56+
57+
```shell
58+
scripts/lint
59+
```
60+
61+
To serve the docs locally:
62+
63+
```shell
64+
uv run mkdocs serve # http://127.0.0.1:8000/cql2-rs/
65+
```
66+
67+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing to this project.
4668

4769
## License
4870

File renamed without changes.

pyproject.toml

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
[project]
2-
name = "cql2-rs"
3-
version = "0.0.0"
4-
description = "This Python package is non-releaseable and is only used for building the documentation"
5-
requires-python = ">=3.12"
2+
name = "cql2"
3+
requires-python = ">=3.9"
4+
classifiers = [
5+
"Programming Language :: Rust",
6+
"Programming Language :: Python :: Implementation :: CPython",
7+
"Programming Language :: Python :: Implementation :: PyPy",
8+
]
9+
dynamic = ["version"]
10+
11+
[project.scripts]
12+
cql2 = "cql2:main"
613

714
[tool.uv]
815
dev-dependencies = [
16+
"maturin>=1.7.8",
917
"mike>=2.1.3",
1018
"mkdocs-material[imaging]>=9.5.39",
1119
"mkdocstrings[python]>=0.26.1",
20+
"mypy>=1.11.2",
21+
"pytest>=8.3.3",
22+
"ruff>=0.6.9",
1223
]
1324

14-
[tool.uv.sources]
15-
python = { workspace = true }
25+
[build-system]
26+
requires = ["maturin>=1.7,<2.0"]
27+
build-backend = "maturin"
1628

17-
[tool.uv.workspace]
18-
members = ["python/"]
29+
[tool.maturin]
30+
manifest-path = "python/Cargo.toml"

python/pyproject.toml

-19
This file was deleted.

python/tests/test_expr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33
from typing import Any
44

5-
import pytest
65
import cql2
6+
import pytest
77
from cql2 import Expr, ParseError, ValidationError
88

99

scripts/lint

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
cargo fmt --check
6+
cargo check --workspace
7+
cargo clippy --workspace --tests -- -D warnings
8+
uv run mypy python
9+
uv run ruff check
10+
uv run ruff format --check

scripts/test

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
cargo test
6+
uv run maturin dev --uv
7+
uv run pytest

src/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn strip_quotes(s: &str) -> &str {
8383
}
8484

8585
fn opstr(op: Pair<'_, Rule>) -> String {
86-
return normalize_op(op.as_str());
86+
normalize_op(op.as_str())
8787
}
8888

8989
fn parse_expr(expression_pairs: Pairs<'_, Rule>) -> Result<Expr, Error> {

0 commit comments

Comments
 (0)