Inkpython
Python runtime for ink (ported from inkjs) that loads compiled .ink.json files and plays them in pure Python.
Table of contents
Installation
From PyPI: pip install inkpython
Dependencies:
- Runtime: none
- Tests:
pytest
Quickstart
from pathlib import Path
from inkpython import Story
story_json = Path("path/to/story.ink.json").read_text(encoding="utf-8-sig")
story = Story(story_json)
print(story.ContinueMaximally())
Working with a JSON file
Inkpython runs compiled ink JSON output (from inklecate or the official ink compiler).
If you load from disk, make sure to strip the BOM or read with utf-8-sig:
from pathlib import Path
from inkpython import Story
text = Path("story.ink.json").read_text(encoding="utf-8-sig")
story = Story(text)
CLI player
A simple CLI player is included:
inkpython path/to/story.ink.json
It prints output, lists choices, and lets you pick by number.
External functions
You can bind external functions via BindExternalFunction:
story.BindExternalFunction("message", lambda arg: print("MESSAGE:", arg))
If you need the text output from a function call, use EvaluateFunction(..., True):
result = story.EvaluateFunction("my_func", [1, 2], True)
# result == {"returned": <value>, "output": "text\n"}
Tests
pytest -q
License
MIT. See LICENSE.
Metadata
Release files for inkpython 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| inkpython-0.1.0.tar.gz | 53.6 kB | Without provenance | Details for inkpython-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| inkpython-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for inkpython-0.1.0-py3-none-any.whl |
Total release size: 118.4 kB
Release files / inkpython-0.1.0.tar.gz
| Download URL | inkpython-0.1.0.tar.gz |
|---|---|
| Size | 53.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad7ac4391a68eb29da6245a9edcacca9a5aa95ffa46691201833a1337f41cae6
|
|
BLAKE2b-256 checksum How to use checksums |
e5d00644f17f4652e98e9f99630e4987f7aeac29267ede71ddb4edd556745d12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / inkpython-0.1.0-py3-none-any.whl
| Download URL | inkpython-0.1.0-py3-none-any.whl |
|---|---|
| Size | 64.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92bbeef7ffe55f5c9dc3c8c696c62887d6d73918cdaa2590a81de64c2a06dd0f
|
|
BLAKE2b-256 checksum How to use checksums |
430106c691594eb810edd9fcdd0e2f4f674e95d8c173b82544aab0b4fcd4c57f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for inkpython 0.1.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.