yara-orm 0.1.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.
Files changed (63) hide show
  1. yara_orm-0.1.0/.github/dependabot.yml +39 -0
  2. yara_orm-0.1.0/.github/workflows/benchmark.yml +78 -0
  3. yara_orm-0.1.0/.github/workflows/ci.yml +71 -0
  4. yara_orm-0.1.0/.github/workflows/release.yml +69 -0
  5. yara_orm-0.1.0/.gitignore +14 -0
  6. yara_orm-0.1.0/Cargo.lock +1660 -0
  7. yara_orm-0.1.0/Cargo.toml +34 -0
  8. yara_orm-0.1.0/LICENSE.md +21 -0
  9. yara_orm-0.1.0/Makefile +51 -0
  10. yara_orm-0.1.0/PKG-INFO +316 -0
  11. yara_orm-0.1.0/README.md +276 -0
  12. yara_orm-0.1.0/benchmarks/README.md +122 -0
  13. yara_orm-0.1.0/benchmarks/bench.py +495 -0
  14. yara_orm-0.1.0/examples/basic.py +88 -0
  15. yara_orm-0.1.0/examples/features.py +133 -0
  16. yara_orm-0.1.0/pyproject.toml +110 -0
  17. yara_orm-0.1.0/python/yara_orm/__init__.py +74 -0
  18. yara_orm-0.1.0/python/yara_orm/__main__.py +112 -0
  19. yara_orm-0.1.0/python/yara_orm/_engine.pyi +35 -0
  20. yara_orm-0.1.0/python/yara_orm/aggregations.py +64 -0
  21. yara_orm-0.1.0/python/yara_orm/connection.py +367 -0
  22. yara_orm-0.1.0/python/yara_orm/dialects.py +621 -0
  23. yara_orm-0.1.0/python/yara_orm/exceptions.py +27 -0
  24. yara_orm-0.1.0/python/yara_orm/fields.py +615 -0
  25. yara_orm-0.1.0/python/yara_orm/migrations.py +1163 -0
  26. yara_orm-0.1.0/python/yara_orm/models.py +688 -0
  27. yara_orm-0.1.0/python/yara_orm/prefetch.py +155 -0
  28. yara_orm-0.1.0/python/yara_orm/queryset.py +930 -0
  29. yara_orm-0.1.0/python/yara_orm/registry.py +85 -0
  30. yara_orm-0.1.0/python/yara_orm/relations.py +647 -0
  31. yara_orm-0.1.0/python/yara_orm/signals.py +191 -0
  32. yara_orm-0.1.0/python/yara_orm/transactions.py +50 -0
  33. yara_orm-0.1.0/rust/src/backend/mod.rs +81 -0
  34. yara_orm-0.1.0/rust/src/backend/postgres.rs +179 -0
  35. yara_orm-0.1.0/rust/src/backend/sqlite.rs +271 -0
  36. yara_orm-0.1.0/rust/src/engine.rs +243 -0
  37. yara_orm-0.1.0/rust/src/error.rs +43 -0
  38. yara_orm-0.1.0/rust/src/lib.rs +21 -0
  39. yara_orm-0.1.0/rust/src/value.rs +449 -0
  40. yara_orm-0.1.0/tests/conftest.py +54 -0
  41. yara_orm-0.1.0/tests/test_aggregation.py +109 -0
  42. yara_orm-0.1.0/tests/test_cov_cli.py +80 -0
  43. yara_orm-0.1.0/tests/test_cov_connection.py +145 -0
  44. yara_orm-0.1.0/tests/test_cov_extra.py +258 -0
  45. yara_orm-0.1.0/tests/test_cov_fields.py +133 -0
  46. yara_orm-0.1.0/tests/test_cov_final.py +141 -0
  47. yara_orm-0.1.0/tests/test_cov_final2.py +156 -0
  48. yara_orm-0.1.0/tests/test_cov_migrations.py +269 -0
  49. yara_orm-0.1.0/tests/test_cov_models.py +145 -0
  50. yara_orm-0.1.0/tests/test_cov_queryset.py +154 -0
  51. yara_orm-0.1.0/tests/test_cov_relations.py +160 -0
  52. yara_orm-0.1.0/tests/test_crud.py +205 -0
  53. yara_orm-0.1.0/tests/test_descriptions.py +53 -0
  54. yara_orm-0.1.0/tests/test_enum.py +62 -0
  55. yara_orm-0.1.0/tests/test_filtering.py +78 -0
  56. yara_orm-0.1.0/tests/test_manual_sql.py +52 -0
  57. yara_orm-0.1.0/tests/test_migrations.py +188 -0
  58. yara_orm-0.1.0/tests/test_prefetch.py +129 -0
  59. yara_orm-0.1.0/tests/test_relations.py +225 -0
  60. yara_orm-0.1.0/tests/test_signals.py +89 -0
  61. yara_orm-0.1.0/tests/test_sqlite.py +150 -0
  62. yara_orm-0.1.0/tests/test_transactions.py +99 -0
  63. yara_orm-0.1.0/tests/test_two_databases.py +77 -0
@@ -0,0 +1,39 @@
1
+ # Keep dependencies up to date across the three ecosystems in this repo.
2
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates
3
+ version: 2
4
+ updates:
5
+ # GitHub Actions used by the CI / release / benchmark workflows.
6
+ - package-ecosystem: github-actions
7
+ directory: /
8
+ schedule:
9
+ interval: weekly
10
+ commit-message:
11
+ prefix: ci
12
+ groups:
13
+ actions:
14
+ patterns:
15
+ - "*"
16
+
17
+ # Python dependencies (declared in pyproject.toml).
18
+ - package-ecosystem: pip
19
+ directory: /
20
+ schedule:
21
+ interval: weekly
22
+ commit-message:
23
+ prefix: deps
24
+ groups:
25
+ python:
26
+ patterns:
27
+ - "*"
28
+
29
+ # Rust crates for the native engine (Cargo.toml at the repo root).
30
+ - package-ecosystem: cargo
31
+ directory: /
32
+ schedule:
33
+ interval: weekly
34
+ commit-message:
35
+ prefix: deps
36
+ groups:
37
+ rust:
38
+ patterns:
39
+ - "*"
@@ -0,0 +1,78 @@
1
+ name: Benchmark
2
+
3
+ # Runs the 4-way ORM benchmark (yara-orm vs Tortoise / SQLAlchemy / Pony) on
4
+ # PostgreSQL and SQLite. Manual or weekly; results land in the job summary and
5
+ # as an artifact. Python 3.12 because Pony's decompiler doesn't support 3.13+.
6
+ on:
7
+ workflow_dispatch:
8
+ inputs:
9
+ n:
10
+ description: "Bulk rows (BENCH_N)"
11
+ default: "5000"
12
+ repeat:
13
+ description: "Runs per ORM, median (BENCH_REPEAT)"
14
+ default: "5"
15
+ schedule:
16
+ - cron: "0 6 * * 1" # Mondays 06:00 UTC
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ benchmark:
23
+ runs-on: ubuntu-latest
24
+ services:
25
+ postgres:
26
+ image: postgres:16
27
+ env:
28
+ POSTGRES_USER: postgres
29
+ POSTGRES_PASSWORD: postgres
30
+ POSTGRES_DB: orm_bench
31
+ ports:
32
+ - 5432:5432
33
+ options: >-
34
+ --health-cmd pg_isready
35
+ --health-interval 10s
36
+ --health-timeout 5s
37
+ --health-retries 5
38
+ env:
39
+ ORM_TEST_DB: postgres://postgres:postgres@localhost:5432/orm_bench
40
+ BENCH_N: ${{ github.event.inputs.n || '5000' }}
41
+ BENCH_REPEAT: ${{ github.event.inputs.repeat || '5' }}
42
+ steps:
43
+ - uses: actions/checkout@v7
44
+ - uses: actions/setup-python@v6
45
+ with:
46
+ python-version: "3.12"
47
+ - uses: dtolnay/rust-toolchain@stable
48
+ - uses: Swatinem/rust-cache@v2
49
+ - name: Install ORMs and drivers
50
+ run: |
51
+ python -m pip install -U pip maturin
52
+ pip install tortoise-orm "sqlalchemy[asyncio]" asyncpg aiosqlite pony psycopg2-binary
53
+ - name: Build and install the Rust engine
54
+ run: |
55
+ maturin build --release --out dist --interpreter python
56
+ pip install --no-index --find-links dist yara-orm
57
+ - name: PostgreSQL benchmark
58
+ run: |
59
+ {
60
+ echo "## PostgreSQL"
61
+ echo '```'
62
+ python benchmarks/bench.py
63
+ echo '```'
64
+ } | tee bench_postgres.txt >> "$GITHUB_STEP_SUMMARY"
65
+ - name: SQLite benchmark
66
+ env:
67
+ BENCH_BACKEND: sqlite
68
+ run: |
69
+ {
70
+ echo "## SQLite"
71
+ echo '```'
72
+ python benchmarks/bench.py
73
+ echo '```'
74
+ } | tee bench_sqlite.txt >> "$GITHUB_STEP_SUMMARY"
75
+ - uses: actions/upload-artifact@v7
76
+ with:
77
+ name: benchmark-results
78
+ path: bench_*.txt
@@ -0,0 +1,71 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: ci-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ lint:
14
+ name: Lint (ruff + ty)
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v7
18
+ - uses: actions/setup-python@v6
19
+ with:
20
+ python-version: "3.12"
21
+ - name: Install lint tools
22
+ run: pip install ruff ty
23
+ - name: ruff check
24
+ run: ruff check python tests benchmarks examples
25
+ - name: ruff format --check
26
+ run: ruff format --check python tests benchmarks examples
27
+ - name: ty
28
+ run: ty check python/yara_orm
29
+
30
+ test:
31
+ name: Tests (py${{ matrix.python-version }})
32
+ runs-on: ubuntu-latest
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ python-version: ["3.12", "3.13", "3.14"]
37
+ services:
38
+ postgres:
39
+ image: postgres:16
40
+ env:
41
+ POSTGRES_USER: postgres
42
+ POSTGRES_PASSWORD: postgres
43
+ POSTGRES_DB: orm_test
44
+ ports:
45
+ - 5432:5432
46
+ options: >-
47
+ --health-cmd pg_isready
48
+ --health-interval 10s
49
+ --health-timeout 5s
50
+ --health-retries 5
51
+ env:
52
+ ORM_TEST_DB: postgres://postgres:postgres@localhost:5432/orm_test
53
+ ORM_TEST_DB2: postgres://postgres:postgres@localhost:5432/orm_test2
54
+ PGPASSWORD: postgres
55
+ steps:
56
+ - uses: actions/checkout@v7
57
+ - uses: actions/setup-python@v6
58
+ with:
59
+ python-version: ${{ matrix.python-version }}
60
+ - uses: dtolnay/rust-toolchain@stable
61
+ - uses: Swatinem/rust-cache@v2
62
+ - name: Create the second test database (two-database tests)
63
+ run: psql "$ORM_TEST_DB" -c 'CREATE DATABASE orm_test2;'
64
+ - name: Install Python deps
65
+ run: pip install maturin pytest pytest-asyncio pytest-cov
66
+ - name: Build and install the Rust engine
67
+ run: |
68
+ maturin build --release --out dist --interpreter python
69
+ pip install --no-index --find-links dist yara-orm
70
+ - name: Run tests with 100% coverage gate
71
+ run: pytest -q --cov=yara_orm --cov-branch --cov-report=term-missing
@@ -0,0 +1,69 @@
1
+ name: Release
2
+
3
+ # Build wheels + sdist on a version tag and publish to PyPI.
4
+ # Trigger by pushing a tag like `v0.1.0`.
5
+ on:
6
+ push:
7
+ tags: ["v*"]
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ wheels:
15
+ name: Wheels (${{ matrix.os }} · py${{ matrix.python-version }})
16
+ runs-on: ${{ matrix.os }}
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ # ubuntu = manylinux x86_64, macos-latest = arm64 (Apple Silicon).
21
+ # macos-13 (Intel x86_64) dropped — scarce runners; Intel-Mac users
22
+ # build from the sdist. Re-add "macos-13" here to ship x86_64 wheels.
23
+ os: [ubuntu-latest, macos-latest, windows-latest]
24
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
25
+ steps:
26
+ - uses: actions/checkout@v7
27
+ - uses: actions/setup-python@v6
28
+ with:
29
+ python-version: ${{ matrix.python-version }}
30
+ - name: Build wheel
31
+ uses: PyO3/maturin-action@v1
32
+ with:
33
+ command: build
34
+ args: --release --out dist --interpreter python${{ matrix.python-version }}
35
+ manylinux: auto
36
+ - uses: actions/upload-artifact@v7
37
+ with:
38
+ name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
39
+ path: dist
40
+
41
+ sdist:
42
+ name: Source distribution
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@v7
46
+ - name: Build sdist
47
+ uses: PyO3/maturin-action@v1
48
+ with:
49
+ command: sdist
50
+ args: --out dist
51
+ - uses: actions/upload-artifact@v7
52
+ with:
53
+ name: sdist
54
+ path: dist
55
+
56
+ publish:
57
+ name: Publish to PyPI
58
+ needs: [wheels, sdist]
59
+ runs-on: ubuntu-latest
60
+ steps:
61
+ - uses: actions/download-artifact@v8
62
+ with:
63
+ path: dist
64
+ merge-multiple: true
65
+ - name: Publish
66
+ uses: pypa/gh-action-pypi-publish@release/v1
67
+ with:
68
+ packages-dir: dist
69
+ password: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,14 @@
1
+ /target
2
+ /.venv
3
+ /.venv*
4
+ __pycache__/
5
+ *.py[cod]
6
+ *.so
7
+ *.egg-info/
8
+ /build
9
+ /dist
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .coverage
13
+ htmlcov/
14
+ Cargo.lock