Install & Compatibility
Where this runs
tested against v11.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
build_error
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.9s · import 0.000s · 43MB
40MB installed
● package 40MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Bag
✓ from pyslang import Bag
✗ import slang
DiagnosticEngine
✓ from pyslang import DiagnosticEngine
✗ import slang
ConstantValue
✓ from pyslang import ConstantValue
✗ import slang
This quickstart demonstrates how to initialize the `slang` library, add SystemVerilog source code, trigger compilation, and check for any errors or warnings. The `slang` library is primarily a compiler and analysis tool.
import slang
# 1. Create a library to manage SystemVerilog source files
library = slang.Library()
# 2. Add SystemVerilog source text. Multiple calls can add more files.
# You can also add files from disk using library.addSourceFile('path/to/file.sv')
sv_code = """
module MySimpleModule;
initial begin
$display("Hello from SystemVerilog in Python!");
end
endmodule;
"""
library.addSourceText(sv_code, fileName='example.sv')
# 3. Get the compiled representation (perform parsing and elaboration)
compilation = library.getCompilation()
# 4. Check for any diagnostics (errors or warnings)
diagnostics = compilation.getDiagnostics()
if diagnostics:
print("Compilation completed with diagnostics:")
for diag in diagnostics:
print(diag.toString())
else:
print("Compilation successful with no diagnostics.")
# Further operations (e.g., accessing symbols) would go here.
# For instance, finding the 'MySimpleModule' definition:
# root = compilation.getRoot()
# module = root.lookupName('MySimpleModule')
Debug
Known issues
gotchaThe PyPI package `pyslang` provides its functionality under the Python module name `slang`. Importing `pyslang` directly will result in a `ModuleNotFoundError`.fixAlways use `import slang` or `from slang import ...` instead of `import pyslang`.
affects: All versions
breakingMajor versions (e.g., v7.0, v9.0, v10.0) frequently introduce stricter compliance with the SystemVerilog Language Reference Manual (LRM). Code that previously compiled silently might now generate errors or warnings due to enhanced LRM enforcement or new static analysis checks.fixReview the `pyslang` (and underlying `slang` C++ library) release notes for changes related to LRM compliance. Update your SystemVerilog source code to adhere to the latest LRM specifications or downgrade `pyslang` if necessary for legacy code.
affects: v7.0 (IEEE 1800-2023), v9.0 (dataflow analysis), v10.0 (assertion locals definite assignment), and subsequent major releases.
gotchaCompilation errors and warnings are not raised as Python exceptions but are returned as a list of `Diagnostic` objects via `compilation.getDiagnostics()`. Failing to check this list means you might unknowingly have an invalid design.fixAfter calling `library.getCompilation()`, always retrieve and iterate through `compilation.getDiagnostics()` to properly handle any issues. Explicitly print or log these diagnostics.
affects: All versions
breakingThe underlying `slang` C++ library is actively developed, and while core APIs like `Library()` and `addSourceText()` are stable, more advanced features or introspection APIs might see changes between major `pyslang` versions.fixConsult the official GitHub repository's release notes for `pyslang` and the `slang` C++ library before upgrading major versions, especially if using advanced features beyond basic compilation.
affects: All major version upgrades (e.g., v8.x to v9.x, v9.x to v10.x)
Upgrade
Version history
11.0.0latest on PyPI · released May 15, 2026
Audit
Dependencies
No dependency data recorded yet.