Skip to content

sysmlpy

A pure Python implementation for parsing, analyzing, and rendering SysML v2.0 models. Uses the ANTLR4 parser for full SysML v2 grammar support.

Current release: v0.77.0 — see CHANGELOG.

Highlights

  • 123/123 OMG XPect parse conformance and 143/143 grammar round-trip tests
  • Semantic analysis with 31 rule codes: symbol resolution, imports, OCL well-formedness, type- and unit-checked expressions, *// unit-dimension derivation, state machines, requirements, traceability
  • 17 PlantUML views + Java-free boxes rendering (Unicode-braille text and SVG)
  • CLI suite: parse, analyze, diff, view, format, trace, export/import, eval, sim, xlsx — CI-friendly exit codes
  • Storage backends: memory, NetworkX, Kùzu (Cypher), Cayley (HTTP)
  • State-machine simulation with real guard evaluation
  • Semantic model diff between SysML files

Getting started

  • Tutorial — comprehensive guide with class mapping tables
  • Quick Start — basic usage examples

Reference

Tooling

  • LSP — language server for editors
  • LSP Editor Setup — per-editor integration guides
  • PlantUML Examples — rendered view gallery
  • Stable Element Identities — scoping for idempotent interchange: parse uuid4 vs interchange uuid5 today, and the L2/L3 options (content-addressed ids, source-carried ids) for projects that need identity to survive edits and cross-document matching

Archive

  • Archive — historical documents (PySysML2 comparison, completed development plan, reference analyses). No longer maintained.

Installation

pip install sysmlpy

Optional extras:

pip install sysmlpy[graph]    # NetworkX graph analysis
pip install sysmlpy[kuzu]     # Kùzu embedded graph database
pip install sysmlpy[cayley]   # Cayley graph database client
pip install sysmlpy[xlsx]     # Excel export
pip install sysmlpy[sim]      # State-machine simulation

Basic Usage

from sysmlpy import loads, Part, Attribute

model = loads("""
package Vehicle {
    part def Engine;
    part engine1 : Engine { attribute mass = 100 [kg]; }
}
""")

engine = model.find_one("engine1")
print(engine.dump())

# Semantic analysis
from sysmlpy import analyze
issues = analyze(model)
print(issues.summary())

Command line:

sysmlpy analyze model.sysml     # semantic gate with CI exit codes
sysmlpy view model.sysml        # PlantUML / Markdown / HTML views
sysmlpy diff old.sysml new.sysml

See the README for the complete CLI table.