Skip to main content

Ren’Py Relations

English · 简体中文

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

In a Python application:

uv add renpy-relations

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.

For SQL sorting, aggregation, and joins over facts and derived relations, see query_sql().

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.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for renpy-relations 0.4.0
File Size Uploaded Provenance
renpy_relations-0.4.0.tar.gz 730.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for renpy-relations 0.4.0
File Interpreter ABI Platform
renpy_relations-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 750.6 kB

Release files / renpy_relations-0.4.0.tar.gz

Download URL renpy_relations-0.4.0.tar.gz
Size 730.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9daa499f46945eff165b003040b9fbdb30c79b37404aefb1d3d05bf84088d2c3
BLAKE2b-256 checksum
How to use checksums
99c9febbf16be12b7b80e0ffe32d87ef63bd57dfeb2fa3973068ffc9a2e46965
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.4.0-py3-none-any.whl

Download URL renpy_relations-0.4.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b840092113b3635312f9adc956ffe48e659aeffd6c5efee4d0d63307c247b4da
BLAKE2b-256 checksum
How to use checksums
87a074e10abaf40cc59cc6f5c7fc97c9ebb9937b8481e3c13ce920e2bb4fca9b
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}

Security for renpy-relations 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page