Registry / llm-agents / llvmlite

llvmlite

JSON →
library0.49.0pypypi✓ verified 25d ago

llvmlite is a lightweight Python binding to LLVM, primarily used for just-in-time (JIT) compilation. It allows Python code to construct LLVM Intermediate Representation (IR) in pure Python, which is then passed to LLVM for compilation and optimization. Maintained by the Numba team, it releases several times a year, often in conjunction with Numba updates and LLVM version bumps. The current stable version is 0.46.0.

pip install llvmlite
INSTALL
IMPORT
SIG · LLVMLITE
L
llvmlite
llm-agentspythonv0.49.0
Install
3.0s avg
Import
14ms
Disk
179MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.49.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
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.0s · import 0.014s · 190MB
179MB installed
● package 179MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ir
from llvmlite import ir
Used for building LLVM Intermediate Representation (IR) in pure Python.
binding
import llvmlite.binding as llvm
Used for interacting with the LLVM runtime, including parsing IR, creating execution engines, and JIT compilation.

This example demonstrates how to define a simple floating-point addition function using `llvmlite.ir`, compile it using `llvmlite.binding`, and execute it via `ctypes`. It covers IR construction, module parsing, execution engine setup, and function invocation.

from ctypes import CFUNCTYPE, c_double from llvmlite import ir import llvmlite.binding as llvm # All these initializations are required for JIT compilation llvm.initialize_native_target() llvm.initialize_native_asmprinter() # Define the LLVM IR for a simple function (double fpadd(double a, double b) { return a + b; }) double = ir.DoubleType() fnty = ir.FunctionType(double, (double, double)) module = ir.Module(name=__file__) func = ir.Function(module, fnty, name="fpadd") block = func.append_basic_block(name="entry") builder = ir.IRBuilder(block) a, b = func.args result = builder.fadd(a, b, name="res") builder.ret(result) # Convert textual LLVM IR into in-memory representation llvm_module = llvm.parse_assembly(str(module)) llvm_module.verify() # Create an ExecutionEngine suitable for JIT code generation target = llvm.Target.from_default_triple() target_machine = target.create_target_machine() engine = llvm.create_mcjit_compiler(llvm_module, target_machine) # Finalize the engine to make the function available engine.finalize_object() engine.run_static_constructors() # Look up the function pointer and cast it to a C function func_ptr = engine.get_function_address("fpadd") cfunc = CFUNCTYPE(c_double, c_double, c_double)(func_ptr) # Run the function res = cfunc(1.0, 2.5) print(f"Result of fpadd(1.0, 2.5): {res}") # Expected: 3.5
Debug
Known issues
breakingThe `llvm.binding.initialize()` function, previously used to initialize LLVM, is deprecated and removed. In `llvmlite` 0.45.x, it raises a `RuntimeError`, and in 0.46.x it is completely removed. LLVM core initialization is now automatic.
fix
Remove any calls to `llvm.binding.initialize()` from your code.
affects: >=0.45.0
breakingSupport for Typed Pointers in the binding layer was removed in `llvmlite` 0.45.0. Future versions (>=0.46, specifically >=0.47) will make Opaque Pointers the default for the IR layer and eventually remove Typed Pointer support entirely, aligning with LLVM 17+. Code relying on Typed Pointers will break if not migrated.
fix
Migrate code to use Opaque Pointers. Refer to the llvmlite documentation's migration guide for specifics on updating existing code.
affects: >=0.45.0
gotchaEach `llvmlite` version is specifically targeted and compatible with particular LLVM feature versions. Using a mismatched LLVM version (e.g., when building from source or with dynamic linking) can lead to build failures or runtime issues. Consult the `llvmlite` documentation for the compatibility matrix. For example, `llvmlite` 0.45.0+ requires LLVM 20.x.x.
fix
Ensure your LLVM installation (if explicitly managed) matches the version required by your `llvmlite` installation. Using pre-built binaries (pip wheels or conda packages) often avoids this issue as they bundle compatible LLVM versions.
affects: *
gotchaBuilding `llvmlite` from source is a complex process requiring specific development tools (C++ compiler, CMake, LLVM development libraries). It is generally recommended to install pre-built binaries via `pip` or `conda` unless you have specific reasons to build from source.
fix
Prefer `pip install llvmlite` or `conda install llvmlite` for most use cases to leverage pre-compiled binaries.
affects: *
deprecatedOfficial support for Python 3.9 was dropped with `llvmlite` 0.44.0. The minimum supported Python version is now 3.10.
fix
Upgrade your Python environment to Python 3.10 or newer.
affects: >=0.44.0
Errors
Common errors & fixes
FileNotFoundError: [Errno 2] No such file or directory: 'llvm-config'
This error occurs during `llvmlite` installation (especially when building from source) because the `llvm-config` executable, which is used to locate LLVM libraries and headers, cannot be found in the system's PATH or at the location specified by the `LLVM_CONFIG` environment variable. This often happens on systems without a proper LLVM development installation or when `pip` attempts to build `llvmlite` from a source distribution due to an unsupported Python version or architecture.
fix
Ensure that LLVM development packages are installed and `llvm-config` is in your system's PATH. If using `pip`, try `pip install llvmlite` and if it fails, consider using `conda install llvmlite` as it typically provides pre-built binaries that include a compatible LLVM. If building from source, set the `LLVM_CONFIG` environment variable to the full path of your `llvm-config` executable (e.g., `export LLVM_CONFIG=/usr/local/opt/llvm/bin/llvm-config`).
ImportError: Numba requires at least version X.Y.Z of llvmlite. Installed version is A.B.C. Please update llvmlite.
This error arises when the installed versions of `Numba` and `llvmlite` are incompatible. `Numba` has a strict dependency on specific `llvmlite` versions, and if `llvmlite` is older than required, this error is raised.
fix
Update `llvmlite` to the version specified or a compatible one with your `Numba` installation, usually by running `pip install --upgrade llvmlite` or `conda update llvmlite`. It's often best to let `conda` manage both, e.g., `conda install numba llvmlite`.
RuntimeError: Building llvmlite requires LLVM X.Y+ Be sure to set LLVM_CONFIG to the right executable path.
This indicates that `llvmlite` could not find a suitable LLVM installation (specifically version X.Y or newer) during its build process. It explicitly suggests setting the `LLVM_CONFIG` environment variable to point to the correct `llvm-config` executable.
fix
Install the required LLVM version (e.g., via your system's package manager, Homebrew, or by compiling from source) and then set the `LLVM_CONFIG` environment variable to the absolute path of the `llvm-config` executable for that LLVM installation before attempting to install `llvmlite` again. For example: `export LLVM_CONFIG=/path/to/llvm-X.Y/bin/llvm-config` followed by `pip install llvmlite`.
OSError: Could not find/load shared object file
This error occurs when `llvmlite`'s Python bindings (specifically `llvmlite.binding`) cannot find or load the underlying shared library (`libllvmlite.so`, `.dll`, or `.dylib`). This often points to a failed or incomplete build of `llvmlite` itself, or an incompatibility with the system's LLVM libraries if `llvmlite` was not statically linked or linked against a mismatched LLVM version.
fix
Reinstall `llvmlite` using a reliable method, preferably `conda install llvmlite` to leverage pre-built, statically linked packages. If using `pip` and encountering issues, ensure you have the necessary build tools (like `cmake`, `g++`, Visual Studio on Windows) and a compatible LLVM installation (as referenced by `LLVM_CONFIG`) for your system and Python version.
ModuleNotFoundError: No module named 'llvmlite'
This error means that the Python interpreter cannot find the `llvmlite` package. This typically happens if `llvmlite` was not successfully installed, was installed in a different Python environment, or the current environment's `PYTHONPATH` does not include the installation directory.
fix
Install `llvmlite` using `pip install llvmlite` or `conda install llvmlite`. Ensure you are installing it into the correct Python environment that you are currently using. If it was already installed, verify the environment or check your `PYTHONPATH`.
Upgrade
Version history
0.49.0latest on PyPI · released Aug 11, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.10 or newer (Python 3.9 support dropped in 0.44.0).
LLVMoptionalllvmlite packages from Numba maintainers statically link LLVM. However, if building from source or using dynamically-linked packages (e.g., from conda-forge), a compatible LLVM installation (including development files and C++ compiler/CMake) is required. llvmlite 0.45.0+ requires LLVM 20.x.x.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
llvmlite — pip install llvmlite · libregistry