You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "mshr-h (via GitHub)" <gi...@apache.org> on 2026/07/12 07:04:44 UTC

[PR] [PYTHON] Find libraries in wheel-tagged build directories [tvm]

mshr-h opened a new pull request, #19987:
URL: https://github.com/apache/tvm/pull/19987

   #19656 changed the scikit-build build directory from `build` to`build/{wheel_tag}`.
   
   That change moved editable-build libraries from `build/lib` to paths such as `build/py3-none-macosx_15_0_arm64/lib`. However, `tvm.libinfo.package_lib_paths()` continued to search only `build/lib`. As a result, `import tvm` could not find `libtvm_runtime` after an editable
   build:
   
   ```text
   RuntimeError: Cannot find library libtvm_runtime.dylib, libtvm_runtime.so
   ```
   
   This PR adds `build/*/lib` to the library search paths. It preserves the existing priority of `TVM_LIBRARY_PATH`, wheel-installed libraries, and `build/lib`.
   
   Verified with:
   
   ```bash
   pre-commit run --files python/tvm/libinfo.py
   uv run python -c "import tvm"
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [PYTHON] Find libraries in wheel-tagged build directories [tvm]

Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h commented on PR #19987:
URL: https://github.com/apache/tvm/pull/19987#issuecomment-4953926148

   Closing as #19990 got merged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [PYTHON] Find libraries in wheel-tagged build directories [tvm]

Posted by "tlopex (via GitHub)" <gi...@apache.org>.
tlopex commented on PR #19987:
URL: https://github.com/apache/tvm/pull/19987#issuecomment-4952737862

   @tqchen agreed. would send a pr to remove the wheel tag


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [PYTHON] Find libraries in wheel-tagged build directories [tvm]

Posted by "mshr-h (via GitHub)" <gi...@apache.org>.
mshr-h closed pull request #19987: [PYTHON] Find libraries in wheel-tagged build directories
URL: https://github.com/apache/tvm/pull/19987


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [PYTHON] Find libraries in wheel-tagged build directories [tvm]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #19987:
URL: https://github.com/apache/tvm/pull/19987#discussion_r3565844188


##########
python/tvm/libinfo.py:
##########
@@ -39,18 +39,21 @@ def package_lib_paths() -> list[Path]:
 
     Anchored on this file's location (``python/tvm/libinfo.py``), the list
     covers the wheel-install layout (``python/tvm/lib/``) and the in-tree dev
-    build layouts (``<worktree>/build/lib/`` and ``<worktree>/lib/``).
+    build layouts (``<worktree>/build/lib/``,
+    ``<worktree>/build/<wheel-tag>/lib/``, and ``<worktree>/lib/``).
     ``TVM_LIBRARY_PATH`` is prepended when set so it takes priority. Callers
     pick the basenames they want (e.g. ``libtvm_runtime.so``) and the load
     mode; this function only returns the search path.
     """
     pkg = _rel_top_directory()  # python/tvm/
+    build = _dev_top_directory() / "build"
     paths: list[Path] = []
     if os.environ.get("TVM_LIBRARY_PATH"):
         paths.append(Path(os.environ["TVM_LIBRARY_PATH"]))
     paths += [
         pkg / "lib",  # wheel layout
-        _dev_top_directory() / "build" / "lib",  # dev: <worktree>/build/lib
+        build / "lib",  # dev: <worktree>/build/lib
+        *sorted(build.glob("*/lib")),  # dev: <worktree>/build/<wheel-tag>/lib
         _dev_top_directory() / "lib",  # dev: <worktree>/lib
     ]

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Unconditionally calling `build.glob("*/lib")` can be inefficient and potentially problematic in non-development environments (e.g., when TVM is installed as a wheel and the `build` directory does not exist or refers to an unrelated system path). Since `glob` is evaluated immediately when `package_lib_paths()` is called (which happens during `import tvm`), we should guard this with `build.is_dir()` to avoid unnecessary filesystem scanning. Additionally, we can cache the result of `_dev_top_directory()` to avoid calling it twice.
   
   ```suggestion
       dev_top = _dev_top_directory()
       build = dev_top / "build"
       paths: list[Path] = []
       if os.environ.get("TVM_LIBRARY_PATH"):
           paths.append(Path(os.environ["TVM_LIBRARY_PATH"]))
       paths += [
           pkg / "lib",  # wheel layout
           build / "lib",  # dev: <worktree>/build/lib
           *(sorted(build.glob("*/lib")) if build.is_dir() else []),  # dev: <worktree>/build/<wheel-tag>/lib
           dev_top / "lib",  # dev: <worktree>/lib
       ]
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [PYTHON] Find libraries in wheel-tagged build directories [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #19987:
URL: https://github.com/apache/tvm/pull/19987#issuecomment-4950341438

   i see, i think in this case, it is perhaps better to simply remove wheel_tag from build dir. While wheel tag helps to distinguish multiple build, i dpn't think it is needed if we isolate CIBW for each wheel matrix, cc @tlopex 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org