Skip to main content

rpiclang (Python)

Python bindings for rpic — the pic graphics language rendered to SVG / PNG / PDF, with animation manifests.

rpic is a Rust reimplementation of Brian W. Kernighan's pic language. Its grammar and behaviour follow dpic by J. D. (Dwight) Aplevich, the reference implementation of pic, and its circuit library is modelled on his circuit_macros.

An independent project, not affiliated with, maintained by or endorsed by the authors of pic, dpic, circuit_macros or pikchr.

pip install rpiclang        # distribution name; you `import rpic`
import rpic

svg = rpic.render_svg('box "hi"; arrow; circle "x"')
open("out.png", "wb").write(rpic.render_png("box \"hi\"", scale=2.0))
open("out.pdf", "wb").write(rpic.render_pdf("box \"hi\""))

# circuit library (or write `copy "circuits"` in the source itself):
svg = rpic.render_svg('A:(0,0); B:(2,0)\nresistor(A,B)', circuits=True)

# TeX math labels, exactly like `rpic -t`:
svg = rpic.render_svg('box "$-\\frac{T}{2}$" fit', texlabels=True)

# the parsed bundle: svg + animation manifest + diagnostics + warnings
bundle = rpic.compile('box\nanimate last box with "pop"')
bundle["animations"]   # [{"id": "s0", "effect": "pop", ...}]
bundle["diagnostics"]  # lines emitted by pic `print`
bundle["warnings"]     # structured warnings (ignored attributes, ...)
bundle["objects"]      # per-object geometry: {"id": "s0", "kind": "box",
                       #   "bbox": {x,y,w,h} | None, "line", "col", ...}
                       #   + "link" when `link "<url>"` set one
# only when the source uses them (same keys as `rpic --json`):
#   "interactions" ([{"id", "kind": "drag", "inertia"?, "bounds"?, "axis"?}]
#   for `draggable`), "places", "passthrough", "scroll"
# (compile_json returns the same as a JSON string)

# the scene: the resolved draw list as device-independent JSON
# (inches, y-up, cubic curves, descriptor style — see docs/scene.md)
# maps: the drawing georeferenced (docs/geopic.md)
fc  = rpic.geo.to_geojson('geo_lon = -34.88\ngeo_lat = -8.05\ngeo_scale = 400\nB: box "hub"')
out = rpic.geo.compile(src, anchor=(-34.88, -8.05), frame="mercator")  # geojson, warnings, registration
gdf = rpic.geo.to_geodataframe(src)      # pip install "rpiclang[geo]"

scene = rpic.scene('geo_lon = -34.88\nB: box "hub"\narrow right from B.e')
scene["vars"]["geo_lon"]      # -34.88 — every variable's final value
scene["items"][1]["kind"]     # "arrow", in draw order, ids matching the SVG
scene = rpic.scene(src, flatten=1e-3)   # curves as polylines
bundle = rpic.compile(src, scene=True)  # or riding the bundle ("scene" key)

# `copy "file"` includes resolve relative to `base`:
svg = rpic.render_svg('copy "shim.pic"\nbox', base="path/to/dir")

# compiling untrusted source? fence or disable filesystem includes
# ("sandboxed" = only files inside `base`; "deny" = none at all;
#  the embedded `copy "circuits"` library always works):
svg = rpic.render_svg(user_source, base="jobs/42", include_policy="sandboxed")

# you can also cap evaluator work for pasted/shared documents:
svg = rpic.render_svg(user_source, max_loop_iterations=10_000, max_shapes=50_000)

Compile errors raise rpic.CompileError (a ValueError subclass, so old except ValueError code keeps working). str(exc) is the readable message; exc.info is the structured diagnostic for editors:

try:
    rpic.render_svg("bxo", circuits=True)
except rpic.CompileError as exc:
    exc.info  # {"message": ..., "line": 1, "col": 1, "end_col": 4,
              #  "file": None, "kind": "expected_token", "found": "`bxo`",
              #  "expected": "an object", "hint": "did you mean `box`?"}

Positions are always relative to your source — with circuits=True an error on your line 1 reports line 1, and a problem inside a copy include names it in info["file"] (None means your own input).

Test

maturin develop --release && pytest tests -q

Build

pip install maturin
cd bindings/python
maturin develop --release     # installs into the current environment
# or: maturin build --release  → wheels in target/wheels/

Metadata

Release files for rpiclang 0.19.1

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

Source distribution (sdist)

Source distribution for rpiclang 0.19.1
File Size Uploaded Provenance Actions
rpiclang-0.19.1.tar.gz 762.2 kB With provenance Details for rpiclang-0.19.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rpiclang 0.19.1
File Interpreter ABI Platform Actions
rpiclang-0.19.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for rpiclang-0.19.1-cp39-abi3-win_amd64.whl
rpiclang-0.19.1-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for rpiclang-0.19.1-cp39-abi3-manylinux_2_28_x86_64.whl
rpiclang-0.19.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for rpiclang-0.19.1-cp39-abi3-macosx_11_0_arm64.whl

Total release size: 21.0 MB

Release files / rpiclang-0.19.1.tar.gz

Download URL rpiclang-0.19.1.tar.gz
Size 762.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e947a93a4901d37f5d80e90ce1bd31c145f9ba8d76dfaad43419887643032caf
BLAKE2b-256 checksum
How to use checksums
463ae3e154f825e897eb2e5ca4c4bb49bfffbce3a928224155aa8f499b5535e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / rpiclang-0.19.1-cp39-abi3-win_amd64.whl

Download URL rpiclang-0.19.1-cp39-abi3-win_amd64.whl
Size 6.4 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
78cacd82e80dd6a9ca5d69603b818d3a7c3af1aa4c98b1e75c66ec07e53e762f
BLAKE2b-256 checksum
How to use checksums
a0cd96cce19438055bbd68e553266ce3e16c259ea61e19a6c1f01ec7500be8c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / rpiclang-0.19.1-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL rpiclang-0.19.1-cp39-abi3-manylinux_2_28_x86_64.whl
Size 7.2 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b6a0da9046a395caf86392680efb2cc215bfe2268fd3cc4fa636d3f8f4c601b6
BLAKE2b-256 checksum
How to use checksums
73e478ab377c1e78852741d783509e0b3991f09fcd34e8dd969aeefa11a75ada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / rpiclang-0.19.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL rpiclang-0.19.1-cp39-abi3-macosx_11_0_arm64.whl
Size 6.6 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
07a047bea694fbea5c7c0247b9de0851bcef4b3849ad23b506c0077cc30150b4
BLAKE2b-256 checksum
How to use checksums
155fa5dda10e1ff3bb3882f20ac40b0630e9eb2a748f41630e60ceec05e2560c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for rpiclang 0.19.1

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.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for rpiclang-0.19.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

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.19.1 This release

4 release files Full 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