rufee 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,88 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_call: # release.yml runs the full suite before building and publishing
8
+
9
+ env:
10
+ CARGO_TERM_COLOR: always
11
+
12
+ jobs:
13
+ rust:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: dtolnay/rust-toolchain@stable
18
+ with:
19
+ components: rustfmt, clippy
20
+ - uses: Swatinem/rust-cache@v2
21
+ - run: cargo fmt --check
22
+ - run: cargo clippy -- -D warnings
23
+ - run: cargo test
24
+
25
+ python:
26
+ runs-on: ubuntu-latest
27
+ strategy:
28
+ matrix:
29
+ python: ["3.11", "3.12", "3.13"]
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ - uses: dtolnay/rust-toolchain@stable
33
+ - uses: Swatinem/rust-cache@v2
34
+ - uses: astral-sh/setup-uv@v5
35
+ with:
36
+ python-version: ${{ matrix.python }}
37
+ - run: uv venv --clear .venv
38
+ - run: uv pip install -p .venv/bin/python -e ".[dev]"
39
+ - run: VIRTUAL_ENV=$PWD/.venv .venv/bin/maturin develop --release
40
+ - run: .venv/bin/python -m pytest -q
41
+
42
+ peewee-suite:
43
+ # peewee's own test-suite through rufee.Context. safe must be green;
44
+ # strict reports the coverage pass rate.
45
+ runs-on: ubuntu-latest
46
+ services:
47
+ mysql:
48
+ image: mysql:8
49
+ env:
50
+ MYSQL_ROOT_PASSWORD: peewee
51
+ MYSQL_DATABASE: peewee_test
52
+ ports: ["33306:3306"]
53
+ options: >-
54
+ --health-cmd "mysqladmin ping -uroot -ppeewee --silent"
55
+ --health-interval 2s --health-timeout 2s --health-retries 30
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+ - uses: dtolnay/rust-toolchain@stable
59
+ - uses: Swatinem/rust-cache@v2
60
+ - uses: astral-sh/setup-uv@v5
61
+ with:
62
+ python-version: "3.11"
63
+ - run: uv venv --clear .venv
64
+ - run: uv pip install -p .venv/bin/python -e ".[dev]"
65
+ - run: VIRTUAL_ENV=$PWD/.venv .venv/bin/maturin develop --release
66
+ - run: make peewee-src
67
+ - name: sqlite safe (must pass)
68
+ run: .venv/bin/python scripts/run_peewee_tests.py -e sqlite --safe
69
+ - name: mysql safe (must pass)
70
+ run: .venv/bin/python scripts/run_peewee_tests.py -e mysql --safe
71
+ - name: sqlite strict (coverage report)
72
+ run: .venv/bin/python scripts/run_peewee_tests.py -e sqlite --strict --json strict-sqlite.json | tail -40
73
+ - name: mysql strict (coverage report)
74
+ run: .venv/bin/python scripts/run_peewee_tests.py -e mysql --strict --json strict-mysql.json | tail -40
75
+ - name: strict pass rate to job summary
76
+ run: |
77
+ python3 - <<'PY' >> "$GITHUB_STEP_SUMMARY"
78
+ import json
79
+ print("| engine | strict pass rate | pass | unsupported | fail | error |")
80
+ print("|---|---|---|---|---|---|")
81
+ for e in ("sqlite", "mysql"):
82
+ d = json.load(open(f"strict-{e}.json")); c = d["counts"]
83
+ print(f"| {e} | {d['pass_rate']:.1%} | {c['pass']} | {c['unsupported']} | {c['fail']} | {c['error']} |")
84
+ PY
85
+ - uses: actions/upload-artifact@v4
86
+ with:
87
+ name: strict-reports
88
+ path: strict-*.json
@@ -0,0 +1,96 @@
1
+ name: Release
2
+
3
+ # Push a v* tag to build wheels + sdist and publish to PyPI.
4
+ #
5
+ # Publishing uses PyPI trusted publishing (OIDC), so there is no API token.
6
+ # The trusted publisher on PyPI must match: owner yoshonabee, repo rufee,
7
+ # workflow release.yml (this file), environment pypi. The publish job must
8
+ # stay in this file: PyPI checks the top-level workflow, not reusable ones.
9
+
10
+ on:
11
+ push:
12
+ tags: ["v*"]
13
+
14
+ jobs:
15
+ ci:
16
+ uses: ./.github/workflows/ci.yml
17
+
18
+ wheels:
19
+ needs: [ci]
20
+ strategy:
21
+ matrix:
22
+ include:
23
+ - os: ubuntu-latest
24
+ target: x86_64
25
+ - os: ubuntu-latest
26
+ target: aarch64
27
+ - os: macos-latest
28
+ target: aarch64
29
+ runs-on: ${{ matrix.os }}
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+ - uses: PyO3/maturin-action@v1
33
+ with:
34
+ target: ${{ matrix.target }}
35
+ args: --release --out dist
36
+ manylinux: auto
37
+ - uses: actions/upload-artifact@v4
38
+ with:
39
+ name: wheels-${{ matrix.os }}-${{ matrix.target }}
40
+ path: dist
41
+
42
+ sdist:
43
+ needs: [ci]
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - name: tag matches pyproject version
48
+ run: |
49
+ version=$(python3 -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
50
+ test "v$version" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME != pyproject version $version"; exit 1; }
51
+ - uses: PyO3/maturin-action@v1
52
+ with:
53
+ command: sdist
54
+ args: --out dist
55
+ - uses: actions/upload-artifact@v4
56
+ with:
57
+ name: wheels-sdist
58
+ path: dist
59
+
60
+ publish:
61
+ needs: [wheels, sdist]
62
+ runs-on: ubuntu-latest
63
+ environment:
64
+ name: pypi
65
+ url: https://pypi.org/p/rufee
66
+ permissions:
67
+ id-token: write
68
+ steps:
69
+ - uses: actions/download-artifact@v4
70
+ with:
71
+ pattern: wheels-*
72
+ merge-multiple: true
73
+ path: dist
74
+ - run: ls -l dist
75
+ - uses: pypa/gh-action-pypi-publish@release/v1
76
+
77
+ github-release:
78
+ # Attach the same files to the GitHub release. Works whether the tag came
79
+ # from publishing a release in the UI (release exists) or from a plain
80
+ # `git push` of the tag (release is created here).
81
+ needs: [publish]
82
+ runs-on: ubuntu-latest
83
+ permissions:
84
+ contents: write
85
+ env:
86
+ GH_TOKEN: ${{ github.token }}
87
+ GH_REPO: ${{ github.repository }}
88
+ steps:
89
+ - uses: actions/download-artifact@v4
90
+ with:
91
+ pattern: wheels-*
92
+ merge-multiple: true
93
+ path: dist
94
+ - name: create release if missing
95
+ run: gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1 || gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes
96
+ - run: gh release upload "$GITHUB_REF_NAME" dist/* --clobber
rufee-0.2.0/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /target
2
+ /.venv
3
+ /dist
4
+ /build
5
+ /wheels
6
+ __pycache__/
7
+ *.py[cod]
8
+ *.so
9
+ *.egg-info/
10
+ .pytest_cache/
11
+ .hypothesis/
12
+ /peewee-src/
13
+ /.worktrees/
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ **Targets peewee 4.5.3. peewee 3.x is no longer supported**; stay on rufee
6
+ 0.1.0 for peewee 3.17. The version gate turns rufee into a pass-through on any
7
+ peewee other than 4.5.x.
8
+
9
+ Renders peewee 4.5.3's whole test-suite byte-identically on sqlite and MySQL 8
10
+ with fallback off, including peewee's asyncio tests.
11
+
12
+ Rendering changes, matching peewee 4:
13
+
14
+ - `State(scope, parentheses, settings)` constructor and the read-only
15
+ `Insert._query_type` property.
16
+ - `Ordering`: `COLLATE` before the direction.
17
+ - Window names, entity names: quoted and escaped per part at render time.
18
+ - `value_literals` escapes `'` as `''`.
19
+ - Compound selects: member styles (flat / parenthesised / `SELECT * FROM (...)`),
20
+ `CSQ_PARENTHESES_GROUPED`, alias scoping for correlated compound subqueries,
21
+ `EXISTS(compound)`.
22
+ - Sub-selects keep their parentheses in function and `CASE` arguments, in
23
+ `UPDATE ... SET` values and `ON CONFLICT` updates; default `Model.select()`
24
+ used as a source keeps its columns; `IN (VALUES ...)`.
25
+ - `FOR UPDATE` as a `ForUpdate` node, including `SKIP LOCKED`.
26
+ - MySQL string concatenation as `CONCAT(a, b)` (`use_concat_function`).
27
+ - Empty inserts backfill python-side defaults; `Table.insert(select)` without
28
+ columns; unbound on-conflict inserts raise peewee's `InterfaceError`.
29
+ - JSON path nodes (`peewee.JSONPath`, playhouse `JSONPath` / `JSONBPath`).
30
+
31
+ Other:
32
+
33
+ - Works with `playhouse.pwasyncio` async databases with no extra code
34
+ (`context_class = rufee.Context`); covered by tests.
35
+ - Test harness: `--baseline` mode, known-failure lists that fail the run when a
36
+ listed test starts passing, faster local MySQL container.
37
+
38
+ ## 0.1.0
39
+
40
+ First release: renders peewee 3.17.9's test-suite byte-identically.
rufee-0.2.0/Cargo.lock ADDED
@@ -0,0 +1,132 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "heck"
7
+ version = "0.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
10
+
11
+ [[package]]
12
+ name = "libc"
13
+ version = "0.2.189"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
16
+
17
+ [[package]]
18
+ name = "once_cell"
19
+ version = "1.21.4"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
22
+
23
+ [[package]]
24
+ name = "portable-atomic"
25
+ version = "1.15.0"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
28
+
29
+ [[package]]
30
+ name = "proc-macro2"
31
+ version = "1.0.107"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
34
+ dependencies = [
35
+ "unicode-ident",
36
+ ]
37
+
38
+ [[package]]
39
+ name = "pyo3"
40
+ version = "0.29.2"
41
+ source = "registry+https://github.com/rust-lang/crates.io-index"
42
+ checksum = "4688ddedf473e32662b9b067670129a8afb8c18e351482c70d62ba4a88171e8b"
43
+ dependencies = [
44
+ "libc",
45
+ "once_cell",
46
+ "portable-atomic",
47
+ "pyo3-build-config",
48
+ "pyo3-ffi",
49
+ "pyo3-macros",
50
+ ]
51
+
52
+ [[package]]
53
+ name = "pyo3-build-config"
54
+ version = "0.29.2"
55
+ source = "registry+https://github.com/rust-lang/crates.io-index"
56
+ checksum = "f41027e41b4bd03f6e60f9f417fe24a6341a6bb744edd62b6f709f2a52ea30e9"
57
+ dependencies = [
58
+ "target-lexicon",
59
+ ]
60
+
61
+ [[package]]
62
+ name = "pyo3-ffi"
63
+ version = "0.29.2"
64
+ source = "registry+https://github.com/rust-lang/crates.io-index"
65
+ checksum = "e591a95526fead067432c3b3a33fc74770b87b1e04e73671090d9c2055a2b327"
66
+ dependencies = [
67
+ "libc",
68
+ "pyo3-build-config",
69
+ ]
70
+
71
+ [[package]]
72
+ name = "pyo3-macros"
73
+ version = "0.29.2"
74
+ source = "registry+https://github.com/rust-lang/crates.io-index"
75
+ checksum = "73225868fc1cd84eef2c3c230ddb91273bf1de46aeb8a4248da76d32a0924a1c"
76
+ dependencies = [
77
+ "proc-macro2",
78
+ "pyo3-macros-backend",
79
+ "quote",
80
+ "syn",
81
+ ]
82
+
83
+ [[package]]
84
+ name = "pyo3-macros-backend"
85
+ version = "0.29.2"
86
+ source = "registry+https://github.com/rust-lang/crates.io-index"
87
+ checksum = "571575aa3749fa6216757dd47d2a3e7ef360f329a40f0666a9fbd14889024952"
88
+ dependencies = [
89
+ "heck",
90
+ "proc-macro2",
91
+ "quote",
92
+ "syn",
93
+ ]
94
+
95
+ [[package]]
96
+ name = "quote"
97
+ version = "1.0.47"
98
+ source = "registry+https://github.com/rust-lang/crates.io-index"
99
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
100
+ dependencies = [
101
+ "proc-macro2",
102
+ ]
103
+
104
+ [[package]]
105
+ name = "rufee"
106
+ version = "0.2.0"
107
+ dependencies = [
108
+ "pyo3",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "syn"
113
+ version = "2.0.119"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
116
+ dependencies = [
117
+ "proc-macro2",
118
+ "quote",
119
+ "unicode-ident",
120
+ ]
121
+
122
+ [[package]]
123
+ name = "target-lexicon"
124
+ version = "0.13.5"
125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
126
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
127
+
128
+ [[package]]
129
+ name = "unicode-ident"
130
+ version = "1.0.24"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
rufee-0.2.0/Cargo.toml ADDED
@@ -0,0 +1,25 @@
1
+ [package]
2
+ name = "rufee"
3
+ version = "0.2.0"
4
+ edition = "2021"
5
+ license = "MIT"
6
+ description = "peewee's SQL rendering Context, implemented in Rust"
7
+ repository = "https://github.com/yoshonabee/rufee"
8
+ readme = "README.md"
9
+
10
+ [lib]
11
+ name = "rufee"
12
+ crate-type = ["cdylib", "rlib"]
13
+
14
+ [dependencies]
15
+ # `extension-module` is enabled by maturin (see pyproject.toml) so that
16
+ # `cargo test` can still link against libpython.
17
+ pyo3 = { version = "0.29", features = ["abi3-py311", "py-clone"] }
18
+
19
+ [features]
20
+ extension-module = ["pyo3/extension-module"]
21
+
22
+ [profile.release]
23
+ opt-level = 3
24
+ lto = "fat"
25
+ codegen-units = 1
rufee-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chieh-Han Tu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
rufee-0.2.0/Makefile ADDED
@@ -0,0 +1,38 @@
1
+ PY ?= .venv/bin/python
2
+ PEEWEE_TAG ?= 4.5.3
3
+
4
+ .PHONY: venv dev test cargo-test lint peewee-src peewee-tests mysql-up mysql-down clean
5
+
6
+ venv: ## create .venv (Python 3.11) with dev deps
7
+ uv venv -p 3.11 .venv
8
+ uv pip install -p $(PY) -e ".[dev]"
9
+
10
+ dev: ## build the extension into .venv (release)
11
+ VIRTUAL_ENV=$(CURDIR)/.venv .venv/bin/maturin develop --release
12
+
13
+ test: cargo-test ## rust + python tests
14
+ $(PY) -m pytest -q
15
+
16
+ cargo-test: ## needs a Python to link against; PYO3_PYTHON points at the venv interpreter
17
+ PYO3_PYTHON=$(CURDIR)/$(PY) cargo test --quiet
18
+
19
+ lint:
20
+ cargo fmt --check
21
+ cargo clippy --quiet -- -D warnings
22
+
23
+ peewee-src: ## check out peewee's test-suite at PEEWEE_TAG into peewee-src/
24
+ @test -d peewee-src/.git || git clone -q --no-checkout https://github.com/coleifer/peewee.git peewee-src
25
+ @git -C peewee-src fetch -q --depth 1 origin tag $(PEEWEE_TAG)
26
+ @git -C peewee-src checkout -q $(PEEWEE_TAG)
27
+
28
+ peewee-tests: peewee-src ## run peewee's own suite through rufee (ARGS: -e sqlite|mysql, RUFEE_FALLBACK=0|1)
29
+ $(PY) scripts/run_peewee_tests.py $(ARGS)
30
+
31
+ mysql-up:
32
+ docker compose up -d --wait mysql
33
+
34
+ mysql-down:
35
+ docker compose down -v
36
+
37
+ clean:
38
+ rm -rf target dist build .pytest_cache