Skip to content

Commit db55b79

Browse files
vacu9708Youngsik Yang
authored andcommitted
[Install] Fix error during python/tvm installation
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()
1 parent 6365a30 commit db55b79

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

python/setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ def _remove_path(path):
129129
LIB_LIST, __version__ = get_lib_path()
130130
__version__ = git_describe_version(__version__)
131131

132+
if not CONDA_BUILD and not INPLACE_BUILD:
133+
# Wheel cleanup
134+
for path in LIB_LIST:
135+
libname = os.path.basename(path)
136+
_remove_path(f"tvm/{libname}")
137+
132138

133139
def config_cython():
134140
"""Try to configure cython and return cython configuration"""
@@ -260,5 +266,5 @@ def long_description_contents():
260266
# Wheel cleanup
261267
os.remove("MANIFEST.in")
262268
for path in LIB_LIST:
263-
_, libname = os.path.split(path)
269+
libname = os.path.basename(path)
264270
_remove_path(f"tvm/{libname}")

python/tvm/_ffi/libinfo.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,18 @@ def find_lib_path(name=None, search_path=None, optional=False):
143143
]
144144

145145
name = lib_dll_names + runtime_dll_names + ext_lib_dll_names
146-
lib_dll_path = [os.path.join(p, name) for name in lib_dll_names for p in dll_path]
147-
runtime_dll_path = [os.path.join(p, name) for name in runtime_dll_names for p in dll_path]
146+
lib_dll_path = [
147+
os.path.join(p, name)
148+
for name in lib_dll_names
149+
for p in dll_path
150+
if not p.endswith("python/tvm")
151+
]
152+
runtime_dll_path = [
153+
os.path.join(p, name)
154+
for name in runtime_dll_names
155+
for p in dll_path
156+
if not p.endswith("python/tvm")
157+
]
148158
ext_lib_dll_path = [os.path.join(p, name) for name in ext_lib_dll_names for p in dll_path]
149159
if not use_runtime:
150160
# try to find lib_dll_path

0 commit comments

Comments
 (0)