Skip to main content

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inkpython-0.1.0.tar.gz (53.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inkpython-0.1.0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file inkpython-0.1.0.tar.gz.

File metadata

  • Download URL: inkpython-0.1.0.tar.gz
  • Upload date:
  • Size: 53.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for inkpython-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ad7ac4391a68eb29da6245a9edcacca9a5aa95ffa46691201833a1337f41cae6
MD5 8667f0dbb250fe88a87516ad4cb0f1b7
BLAKE2b-256 e5d00644f17f4652e98e9f99630e4987f7aeac29267ede71ddb4edd556745d12

See more details on using hashes here.

File details

Details for the file inkpython-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: inkpython-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 64.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for inkpython-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92bbeef7ffe55f5c9dc3c8c696c62887d6d73918cdaa2590a81de64c2a06dd0f
MD5 3fc064a64d835dc6fb56f5fa184e8a86
BLAKE2b-256 430106c691594eb810edd9fcdd0e2f4f674e95d8c173b82544aab0b4fcd4c57f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page