This is an automated email from the ASF dual-hosted git repository.

tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 1b94055eb6 Fix #18714: [Docs]  python -c "import tvm; print(tvm.file)" 
fail (#19407)
1b94055eb6 is described below

commit 1b94055eb67f6c3269cfcb404dee7c8722151905
Author: Zakir Jiwani <[email protected]>
AuthorDate: Wed Apr 15 13:15:17 2026 -0400

    Fix #18714: [Docs]  python -c "import tvm; print(tvm.file)" fail (#19407)
    
    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 <[email protected]>
---
 docs/install/from_source.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/docs/install/from_source.rst b/docs/install/from_source.rst
index 329ba219c1..4e0f7cf6db 100644
--- a/docs/install/from_source.rst
+++ b/docs/install/from_source.rst
@@ -163,7 +163,8 @@ Leaving the build environment ``tvm-build-venv``, there are 
two ways to install
 .. code-block:: bash
 
     export TVM_HOME=/path-to-tvm
-    export PYTHONPATH=$TVM_HOME/python:$PYTHONPATH
+    pip install $TVM_HOME/3rdparty/tvm-ffi
+    export 
PYTHONPATH=$TVM_HOME/python:$TVM_HOME/3rdparty/tvm-ffi/python:$PYTHONPATH
 
 - Install via pip local project
 

Reply via email to