mirror of
https://github.com/LLVMParty/llvm-nanobind
synced 2026-06-21 13:43:38 +00:00
5f59fa3b9239d172f4b0b133fd2eaefdf9f398e0
llvm-nanobind
LLVM-C Python bindings with nanobind.
⚠️ This project is still in a very early design phase and not remotely usable.
Local development
Set the CMake prefix path environment variable to point to the LLVM prefix:
export CMAKE_PREFIX_PATH=$(brew --prefix llvm)
Configure the bindings:
cmake -B build -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
Build the bindings:
cmake --build build
Run the example:
uv run playground.py
Testing
Run the golden master tests (C++ and Python bindings):
uv run python run_tests.py
Run the vendored llvm-c-test integration tests:
uv run python run_llvm_c_tests.py # Run all tests
uv run python run_llvm_c_tests.py -v # Verbose output
Type Checking
Check type correctness of Python code:
uvx ty check # Check all Python files
uvx ty check llvm_c_test/ # Check specific directory
Code Coverage
Generate code coverage reports:
uv run coverage run test_factorial.py # Run test with coverage
uv run coverage report # Show coverage summary
uv run coverage html # Generate HTML report (htmlcov/)
To combine coverage from multiple test runs:
uv run coverage run --data-file=.coverage.test1 test_factorial.py
uv run coverage run --data-file=.coverage.test2 test_module.py
uv run coverage combine # Combine all .coverage.* files
uv run coverage report # Show combined report
For comprehensive coverage including test runners and all subprocess tests:
uv run coverage run --data-file=.coverage.run_tests run_tests.py
uv run coverage run --data-file=.coverage.run_llvm_c_tests run_llvm_c_tests.py
uv run coverage combine # Combine all coverage files
uv run coverage report # Show comprehensive report
uv run coverage html # Generate HTML report
Languages
C++
45.1%
Python
32.8%
C
16.3%
HTML
2.6%
LLVM
2.3%
Other
0.9%