A clean, modern SMI/MIB compiler
Project description
trishul-smi
A clean, modern SNMP MIB compiler written in Python.
trishul-smi fetches, parses, and compiles SNMP MIB definitions (SMIv1 and SMIv2)
into structured JSON or pysnmp-compatible Python modules.
It resolves transitive imports automatically, caches compiled modules on disk,
and ships a CLI that works out-of-the-box with no SNMP toolchain required.
Features
- Full import closure — resolves every transitive dependency automatically
- Full OID resolution — all objects carry absolute numeric OID paths after compile
- Two output formats — structured JSON and pysnmp-compatible Python
- Atomic JSON modules + optional sidecars — each module JSON is usable on its own;
manifest.jsonandoid_index.jsonare additive when enabled via the Python API - Versioned JSON IR metadata — module JSON and optional sidecars carry
schema_version,producer_version,generated_by, andgenerated_at - Deterministic sidecars — optional
manifest.jsonandoid_index.jsondescribe the final emitted JSON file set, so overlapping alias inputs do not duplicate or self-poison bundle metadata - Real-world parser compatibility — wrapped inline comment continuations and
SNMPv2-PDUcompatibility forms seen in the IETF corpus now compile cleanly - Tagged ASN.1 type support — explicit base MIBs such as
SNMPv2-SMIcompile correctly, including application-tagged types likeIpAddressandCounter32 - pysmi-parity pysnmp output — MibTableColumn detection, full TC subtypeSpec, setIndexNames, setOrganization, setRevisions, inline constraint wrappers
- Reverse conversion —
tsmi convert FILE.pyconverts a compiled PySNMP module back to JSON - Directory compile mode —
tsmi compile -d /path/to/mibsauto-discovers and compiles every MIB file - Concurrent fetching — parallel async HTTP with retry and timeout; parse waves stay deterministic on real MIB corpora
- Pluggable readers —
FileReader,HttpReader,ZipReader, composable viaReaderChain - Disk cache — compiled modules cached with mtime-based TTL; atomic writes
- Cycle detection — Kahn's algorithm with actionable error messages
- SMIv1 + SMIv2 — separate Lark grammars, auto-detected per MIB
Installation
pip install trishul-smi
Requires Python ≥ 3.10.
Quick Start
# Compile from a local MIB directory
tsmi compile IF-MIB --mib-dir /usr/share/snmp/mibs
# Fetch from the internet and compile to JSON + pysnmp
tsmi compile IF-MIB IP-MIB -f json -f pysnmp --online -o ./out
Python API:
import asyncio
from pathlib import Path
from trishul_smi.compiler import MibCompiler
from trishul_smi.config import CompilerConfig
from trishul_smi.reader import FileReader, HttpReader
async def main():
config = CompilerConfig(output_dir=Path("./out"))
compiler = MibCompiler(config).add_reader(FileReader("/usr/share/snmp/mibs"))
# optionally add HTTP: async with HttpReader(*config.sources) as http: compiler.add_reader(http)
results = await compiler.compile("IF-MIB", "IP-MIB")
for r in results:
print(r.name, r.status, r.output_paths)
asyncio.run(main())
Each emitted MODULE.json is a valid standalone artifact. For downstream bundle metadata,
set emit_manifest=True and/or emit_oid_index=True on CompilerConfig. When enabled,
sidecars describe the final emitted JSON file set for that compile run.
Documentation
- CLI Reference — all commands, options, and output format examples
- Python API — embedding
trishul-smias a library - Configuration —
CompilerConfigfields and defaults - JSON Bundle Contract — atomic module JSON, optional sidecars, and runtime guarantees
- Architecture — package structure, data flow, design principles
- Roadmap — planned features and known limitations
- Changelog — version history
Repository
- Contributing — dev setup, quality gates, and repo conventions
- Contributors — maintainer and contributor credits
- Release Checklist — maintainer release process
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trishul_smi-0.4.1.tar.gz.
File metadata
- Download URL: trishul_smi-0.4.1.tar.gz
- Upload date:
- Size: 122.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e551638df1d40b2afcff78c787f29ea88ed887ed81c0d8981981df295050fa19
|
|
| MD5 |
d9b95dc7b35561e92e43fda4c8b39348
|
|
| BLAKE2b-256 |
74e75833fe209fed41b803ea7fb3c9bd48d3207e6e80a929bee8d426d07fabea
|
Provenance
The following attestation bundles were made for trishul_smi-0.4.1.tar.gz:
Publisher:
release.yml on tosumitdhaka/trishul-smi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trishul_smi-0.4.1.tar.gz -
Subject digest:
e551638df1d40b2afcff78c787f29ea88ed887ed81c0d8981981df295050fa19 - Sigstore transparency entry: 1461686366
- Sigstore integration time:
-
Permalink:
tosumitdhaka/trishul-smi@db726c624ebe8d4db951d1b030418ea8177eb6b6 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/tosumitdhaka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db726c624ebe8d4db951d1b030418ea8177eb6b6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file trishul_smi-0.4.1-py3-none-any.whl.
File metadata
- Download URL: trishul_smi-0.4.1-py3-none-any.whl
- Upload date:
- Size: 65.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28c0f2aa44c93518ff2c00fa2108c9d769a076432e8005bbc2455d53cd02f5a5
|
|
| MD5 |
75b793552620347053ce74f2609f548e
|
|
| BLAKE2b-256 |
9e490fd8c28b99f1310022cdc2fc4fe847675406b4a47d07f258719ee0ce2173
|
Provenance
The following attestation bundles were made for trishul_smi-0.4.1-py3-none-any.whl:
Publisher:
release.yml on tosumitdhaka/trishul-smi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trishul_smi-0.4.1-py3-none-any.whl -
Subject digest:
28c0f2aa44c93518ff2c00fa2108c9d769a076432e8005bbc2455d53cd02f5a5 - Sigstore transparency entry: 1461686425
- Sigstore integration time:
-
Permalink:
tosumitdhaka/trishul-smi@db726c624ebe8d4db951d1b030418ea8177eb6b6 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/tosumitdhaka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@db726c624ebe8d4db951d1b030418ea8177eb6b6 -
Trigger Event:
push
-
Statement type: