Ren’Py Relations
An embeddable Python library for relational facts and compiled Logica rules, with optional Ren’Py integration.
Story conditions often recur across encounters: access to a place, knowledge of a secret, or an earlier choice. Ren’Py Relations lets you name and compose those conditions as rules. Actions change facts; scripts query which actions or encounters are available. The same core works in ordinary Python applications.
Logica compiles rules to SQL during development. SQLite or DuckDB stores facts and evaluates queries at runtime. The Ren’Py adapter connects fact snapshots to save, load, and rollback.
A small example
The shipped Palace rules derive archive access from sponsorship or faction membership:
from renpy_relations import LogicDB
logic = LogicDB("examples/palace/game/relations.rules.json")
try:
logic.add("Sponsor", character="hero", location="archive")
print(logic.query("CanEnter", character="hero"))
# [{'character': 'hero', 'location': 'archive'}]
finally:
logic.close()
Run from the source root after the quickstart setup. No hand-written SQL is needed for this example.
world.l + schema.json
│ renpy-relations-compile (during development)
▼
backend-specific JSON rule bundle
│ LogicDB (during the game)
▼
facts → derived answers → script choices and effects
│ Ren’Py adapter publishes fact snapshots
▼
Ren’Py snapshot variable → save / load / rollback
The runtime uses cached mode by default: it builds derived relations when first queried and invalidates affected results after fact changes. SQLite and DuckDB are available, with separate compiled bundles for each. The reference explains the other query modes and their tradeoffs.
Choose a starting point
| Goal | Read |
|---|---|
| Embed the core in an ordinary Python application | Python guide |
| Learn the concepts and run Palace in Python and Ren’Py | Quickstart |
| Integrate the runtime or check compiler, snapshot, and reload contracts | Reference |
| Play or study a complete Chinese-language narrative example | Tidelight |
| Understand workloads and reproduce a small performance run | Benchmarks |
| Change, verify, stage, or release the project | Maintenance |
Installation
From a source checkout:
uv sync --locked
Follow the Python guide to install a wheel or embed the library, or the Ren’Py quickstart to stage a game. Development uses Python 3.12; supported environments and driver versions are listed in the reference.
Project layout
| Directory | Contents |
|---|---|
src/renpy_relations/ |
Python package: runtime, compiler and Ren’Py adapter. |
docs/ |
Tutorials, reference and maintenance guide. |
examples/ |
Python permissions, Palace and Tidelight samples. |
tools/ |
Game staging, engine checks and release tooling. |
tests/, benchmarks/ |
Automated checks and performance experiments. |
Foundations and license
Learn more through the official Logica user guide and SQLite overview. Logica compiles rules during development; games run the compiled SQL and do not need the Logica compiler.
Project code, example scripts, documentation, and original example data use the MIT license. Dependencies, the Tidelight font, and distributed Ren’Py runtimes retain their own licenses; see third-party notices.
Metadata
Release files for renpy-relations 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| renpy_relations-0.3.0.tar.gz | 723.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| renpy_relations-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 743.2 kB
Release files / renpy_relations-0.3.0.tar.gz
| Download URL | renpy_relations-0.3.0.tar.gz |
|---|---|
| Size | 723.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92c817a2a8b64b40c0f7497d07de74ac62bf056f2136336f417cf1b3faf32f88
|
|
BLAKE2b-256 checksum How to use checksums |
ae0506c0fbb84650bc235fbbe68a017c8ba2228a4fa4b0b76079106e2a700552
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / renpy_relations-0.3.0-py3-none-any.whl
| Download URL | renpy_relations-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
351d2e75bc9c15f668cb4925e03782e5ba5d1bb730e458d8116b9e92fd9559fa
|
|
BLAKE2b-256 checksum How to use checksums |
5d09cc551923392052cd020fbd2af9ea88a9a9e991b1f3a014defa1073b56be2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|