Skip to content

Commit

Permalink
fix: packaging (#51)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gadomski authored Dec 9, 2024
1 parent 5b2df1a commit ef4b6d0
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 217 deletions.
35 changes: 6 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ concurrency:
cancel-in-progress: true

jobs:
lint-test:
name: Lint and Test
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -21,33 +21,10 @@ jobs:
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
run: cargo fmt --all --check
- name: cargo clippy
run: cargo clippy --tests --workspace -- -D warnings
- name: cargo check
run: cargo check --workspace
- name: cargo test
run: cargo test
python-test:
name: Test Python
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version-file: python/.python-version
- name: Install
run: uv sync --dev
- name: Check
run: uv run mypy . && uv run ruff check && uv run ruff format --check
- name: Lint
run: scripts/lint
- name: Test
run: uv run pytest
run: scripts/test
- name: CLI smoke test
run: uv run cql2 < ../examples/text/example01.txt
run: uv run cql2 < examples/text/example01.txt
21 changes: 5 additions & 16 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ name: Python

on:
push:
branches:
- main
tags:
- "v*"
paths:
- python/**
pull_request:
paths:
- python/**
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -47,7 +40,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m python/Cargo.toml
args: --release --out dist --find-interpreter
sccache: "true"
manylinux: auto
- name: Upload wheels
Expand Down Expand Up @@ -78,7 +71,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m python/Cargo.toml
args: --release --out dist --find-interpreter
sccache: "true"
manylinux: musllinux_1_2
- name: Upload wheels
Expand Down Expand Up @@ -106,7 +99,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m python/Cargo.toml
args: --release --out dist --find-interpreter
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v4
Expand All @@ -132,7 +125,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -m python/Cargo.toml
args: --release --out dist --find-interpreter
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v4
Expand All @@ -148,8 +141,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist -m python/Cargo.toml
maturin-version: "v1.6.0" # pinned below 1.7 until https://github.com/PyO3/maturin/issues/2244 is resolved
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
Expand All @@ -162,11 +154,8 @@ jobs:
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
needs: [linux, musllinux, windows, macos, sdist]
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/download-artifact@v4
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,29 @@ Responses may not match the input.

## Development

See [CONTRIBUTING.md](./CONTRIBUTING.md) for information about contributing to this project.
Get [uv](https://docs.astral.sh/uv/getting-started/installation/) and [Rust](https://rustup.rs/).
Then:

```shell
git clone [email protected]:developmentseed/cql2-rs.git
cd cql2-rs
uv sync
scripts/test
```

To lint all files:

```shell
scripts/lint
```

To serve the docs locally:

```shell
uv run mkdocs serve # http://127.0.0.1:8000/cql2-rs/
```

See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing to this project.

## License

Expand Down
File renamed without changes.
28 changes: 20 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
[project]
name = "cql2-rs"
version = "0.0.0"
description = "This Python package is non-releaseable and is only used for building the documentation"
requires-python = ">=3.12"
name = "cql2"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]

[project.scripts]
cql2 = "cql2:main"

[tool.uv]
dev-dependencies = [
"maturin>=1.7.8",
"mike>=2.1.3",
"mkdocs-material[imaging]>=9.5.39",
"mkdocstrings[python]>=0.26.1",
"mypy>=1.11.2",
"pytest>=8.3.3",
"ruff>=0.6.9",
]

[tool.uv.sources]
python = { workspace = true }
[build-system]
requires = ["maturin>=1.7,<2.0"]
build-backend = "maturin"

[tool.uv.workspace]
members = ["python/"]
[tool.maturin]
manifest-path = "python/Cargo.toml"
19 changes: 0 additions & 19 deletions python/pyproject.toml

This file was deleted.

2 changes: 1 addition & 1 deletion python/tests/test_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from pathlib import Path
from typing import Any

import pytest
import cql2
import pytest
from cql2 import Expr, ParseError, ValidationError


Expand Down
10 changes: 10 additions & 0 deletions scripts/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh

set -e

cargo fmt --check
cargo check --workspace
cargo clippy --workspace --tests -- -D warnings
uv run mypy python
uv run ruff check
uv run ruff format --check
7 changes: 7 additions & 0 deletions scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh

set -e

cargo test
uv run maturin dev --uv
uv run pytest
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn strip_quotes(s: &str) -> &str {
}

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

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

0 comments on commit ef4b6d0

Please sign in to comment.