Skip to main content

merman Python Package

Experimental Python bindings for Merman through UniFFI.

Merman renders Mermaid diagrams without a browser. It can parse Mermaid source, return semantic JSON, compute layout JSON, and render SVG through a headless Rust engine. See the project README, Python binding notes, and diagram coverage status for the main library contract.

API

import merman

engine = merman.MermanEngine()
assert engine.abi_version() == 1
print(engine.package_version())

source = "flowchart TD\nA[Hello] --> B[World]"
svg = engine.render_svg(source, None)
ascii_text = engine.render_ascii(source, None)
semantic_json = engine.parse_json(source, None)
layout_json = engine.layout_json(source, None)
validation = engine.validate(source, None)
diagrams = engine.supported_diagrams()
themes = engine.supported_themes()
host_presets = engine.supported_host_theme_presets()

try:
    engine.render_svg(source, "{")
except merman.MermanError.Binding as error:
    print(error.code_name, error.message)

options_json is optional. Pass None for defaults, or a JSON string with parse, layout, and svg options. The shared schema is documented in docs/bindings/OPTIONS_JSON.md.

Generate Locally

This directory intentionally does not commit generated binding source or native libraries. Generate them from a local merman-uniffi cdylib:

cargo build -p merman-uniffi --features bindgen-smoke
cargo run -p merman-uniffi --features bindgen-smoke --example generate_python_package -- \
  --package-dir platforms/python/merman

The generator writes:

  • src/merman/merman_uniffi.py
  • src/merman/merman_uniffi.dll on Windows
  • src/merman/libmerman_uniffi.so on Linux
  • src/merman/libmerman_uniffi.dylib on macOS

The native library must sit beside the generated module because UniFFI's Python loader resolves the library relative to the generated file.

After generation, a local smoke can import the package by putting src on PYTHONPATH:

PYTHONPATH=platforms/python/merman/src python -c "import merman; print(merman.MermanEngine().render_svg('flowchart TD\nA[Hello]', None)[:4])"

Or run the example script:

PYTHONPATH=platforms/python/merman/src python platforms/python/merman/examples/smoke.py

Build a local platform wheel and run an install smoke:

python3 scripts/build-python-uniffi-wheel.py --run-smoke

The wheel is platform-specific because it bundles merman-uniffi as a native .so, .dylib, or .dll. Tag releases run release-python.yml, attach platform wheels to the GitHub Release, and publish the merman distribution to PyPI when Trusted Publishing is configured.

License

This package is dual-licensed under either Apache-2.0 or MIT. See LICENSE for the full license texts. Mermaid compatibility and upstream Mermaid MIT attribution are documented in THIRD_PARTY_NOTICES.md.

Metadata

Release files for merman 0.7.0

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

Built distributions (wheels)

Table of built distributions (wheels) for merman 0.7.0
File Interpreter ABI Platform
merman-0.7.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details
merman-0.7.0-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details

Total release size: 57.4 MB

Release files / merman-0.7.0-py3-none-win_amd64.whl

Download URL merman-0.7.0-py3-none-win_amd64.whl
Size 8.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
7b64c567aa3454a058c566915a9f550d9838fbfcb1a7bb434b6c2a7f6ccbdeb1
BLAKE2b-256 checksum
How to use checksums
6453c04928cb0493847ac04b05337c0c7768b06e0b844c7a2fb5cabae090db10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 9, 2026.

Transparency log

Release files / merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl

Download URL merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl
Size 38.9 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
a1d252294041b1ee254c02c313ece381ea625a48ae0315b744d69029b09c1bd3
BLAKE2b-256 checksum
How to use checksums
f5081ac6a136192615459682d9694a90256f13110d5ee40ce401b48978acbe99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 9, 2026.

Transparency log

Release files / merman-0.7.0-py3-none-macosx_11_0_universal2.whl

Download URL merman-0.7.0-py3-none-macosx_11_0_universal2.whl
Size 10.5 MB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
5319c6dbed4597030a59fcf02605bcd2275138f52604659877a8efa776380559
BLAKE2b-256 checksum
How to use checksums
88da1999b989cf8643f27ea923f1b4c2c33428b00572c9e66e67823464ca405c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 9, 2026.

Transparency log
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