This is an automated email from the ASF dual-hosted git repository.
mshr 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 4790798d5d [Install] Fix error during python/tvm installation (#17808)
4790798d5d is described below
commit 4790798d5dad31e2b98fcfa2750379451eea5b3a
Author: yys <[email protected]>
AuthorDate: Mon Apr 14 10:48:45 2025 +0900
[Install] Fix error during python/tvm installation (#17808)
This PR fixes a bug where running "pip install -e /path-to-tvm/python" fails
if installation files remain in python/tvm.
The fix includes:
- Preventing libraries from `python/tvm` from being appended to the library
list,
resolving the shutil.SameFileError exception raised by shutil.copy()
- Adding cleanup logic earlier in case it was not executed due to a
previous pip installation failure,
resolving the FileExistsError exception raised by shutil.copytree()
---
python/setup.py | 8 +++++++-
python/tvm/_ffi/libinfo.py | 14 ++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/python/setup.py b/python/setup.py
index ad0ef6ffde..7f76a7b9f2 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -129,6 +129,12 @@ def _remove_path(path):
LIB_LIST, __version__ = get_lib_path()
__version__ = git_describe_version(__version__)
+if not CONDA_BUILD and not INPLACE_BUILD:
+ # Wheel cleanup
+ for path in LIB_LIST:
+ libname = os.path.basename(path)
+ _remove_path(f"tvm/{libname}")
+
def config_cython():
"""Try to configure cython and return cython configuration"""
@@ -260,5 +266,5 @@ if not CONDA_BUILD and not INPLACE_BUILD:
# Wheel cleanup
os.remove("MANIFEST.in")
for path in LIB_LIST:
- _, libname = os.path.split(path)
+ libname = os.path.basename(path)
_remove_path(f"tvm/{libname}")
diff --git a/python/tvm/_ffi/libinfo.py b/python/tvm/_ffi/libinfo.py
index e7b256d7ec..242093b547 100644
--- a/python/tvm/_ffi/libinfo.py
+++ b/python/tvm/_ffi/libinfo.py
@@ -143,8 +143,18 @@ def find_lib_path(name=None, search_path=None,
optional=False):
]
name = lib_dll_names + runtime_dll_names + ext_lib_dll_names
- lib_dll_path = [os.path.join(p, name) for name in lib_dll_names for p
in dll_path]
- runtime_dll_path = [os.path.join(p, name) for name in
runtime_dll_names for p in dll_path]
+ lib_dll_path = [
+ os.path.join(p, name)
+ for name in lib_dll_names
+ for p in dll_path
+ if not p.endswith("python/tvm")
+ ]
+ runtime_dll_path = [
+ os.path.join(p, name)
+ for name in runtime_dll_names
+ for p in dll_path
+ if not p.endswith("python/tvm")
+ ]
ext_lib_dll_path = [os.path.join(p, name) for name in
ext_lib_dll_names for p in dll_path]
if not use_runtime:
# try to find lib_dll_path