tree: ee4222caa8e1d32b3247b26e01eca0bf632cc6d2
  1. python/
  2. src/
  3. CMakeLists.txt
  4. pyproject.toml
  5. README.md
  6. run_example.py
examples/python_packaging/README.md

TVM FFI Packaging Example

This is an example project that packages a tvm-ffi based library into a Python ABI-agnostic wheel.

This example can also serve as a guideline for general packaging as well.

  • Source-level build for cross-compilation support in CMake
  • Registration via global function table

Install the wheel

Use uv pip (the same tooling used in CI) to build and install the example wheel:

cd examples/python_packaging
uv pip install --reinstall --verbose .

Note on build and auditwheel

Note: When running the auditwheel process, make sure to skip libtvm_ffi.so as they are shipped via the tvm_ffi package.

Run the example

After installing the my_ffi_extension example package, you can run the following example.

python run_example.py

This runs four flows: calling add_two via the TVM-FFI ABI, calling add_one via the global registry, calling raise_error to demonstrate error propagation, and constructing/using the IntPair object.