Commit 1b94055
Closes #18714
## Before
Following the source installation docs, users who set up `PYTHONPATH`
with only `$TVM_HOME/python` would hit an
`importlib.metadata.PackageNotFoundError: apache-tvm-ffi` when running
`python -c "import tvm"`. This happened because `tvm_ffi/__init__.py`
calls `libinfo.load_lib_ctypes("apache-tvm-ffi", ...)`, which uses
`importlib.metadata.distribution("apache-tvm-ffi")` to locate the shared
library — a lookup that requires the `apache-tvm-ffi` package to be
registered in the Python environment, not just present on `PYTHONPATH`.
## After
The `tvm-ffi` package at `3rdparty/tvm-ffi` is installed into the active
Python environment via `pip install` before any `import tvm` is
attempted. The `PYTHONPATH` export in `docs/install/from_source.rst` is
also updated to include `$TVM_HOME/3rdparty/tvm-ffi/python` alongside
`$TVM_HOME/python`, matching the environment layout expected by the FFI
loader.
## Changes
- **`docs/install/from_source.rst` (line ~165–166):** Added `pip install
$TVM_HOME/3rdparty/tvm-ffi` step before the `export PYTHONPATH` line in
the "set environment variable" path. Updated the `PYTHONPATH` export to
append `$TVM_HOME/3rdparty/tvm-ffi/python`, ensuring both the package
metadata (from the pip install) and the Python sources are resolvable.
## Testing
Manual verification on a from-source build with the updated
instructions:
```
$ pip install $TVM_HOME/3rdparty/tvm-ffi
$ export PYTHONPATH=$TVM_HOME/python:$TVM_HOME/3rdparty/tvm-ffi/python:$PYTHONPATH
$ python -c "import tvm; print(tvm.__file__)"
/path-to-tvm/python/tvm/__init__.py
```
No `PackageNotFoundError` is raised;
`importlib.metadata.distribution("apache-tvm-ffi")` resolves correctly
after the pip install step.
---
*This PR was created with AI assistance (Claude). The changes were
reviewed by quality gates and a critic model before submission.*
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 14751b3 commit 1b94055
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
| 167 | + | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| |||
0 commit comments