Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standalone_crt/ to be part of the wheel package, when available. #9005

Merged
merged 1 commit into from
Sep 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,22 @@ def get_lib_path():
if not CONDA_BUILD:
lib_path = libinfo["find_lib_path"]()
libs = [lib_path[0]]
if libs[0].find("runtime") == -1:
if "runtime" not in libs[0]:
for name in lib_path[1:]:
if name.find("runtime") != -1:
if "runtime" in name:
libs.append(name)
break

# Add standalone_crt, if present
for name in lib_path:
candidate_path = os.path.join(os.path.dirname(name), "standalone_crt")
if os.path.isdir(candidate_path):
libs.append(candidate_path)
break

else:
libs = None

return libs, version


Expand Down Expand Up @@ -154,9 +163,16 @@ def is_pure(self):
if wheel_include_libs:
with open("MANIFEST.in", "w") as fo:
for path in LIB_LIST:
shutil.copy(path, os.path.join(CURRENT_DIR, "tvm"))
_, libname = os.path.split(path)
fo.write("include tvm/%s\n" % libname)
if os.path.isfile(path):
shutil.copy(path, os.path.join(CURRENT_DIR, "tvm"))
_, libname = os.path.split(path)
fo.write(f"include tvm/{libname}%s")

if os.path.isdir(path):
_, libname = os.path.split(path)
shutil.copytree(path, os.path.join(CURRENT_DIR, "tvm", libname))
fo.write(f"recursive-include tvm/{libname} *\n")

setup_kwargs = {"include_package_data": True}

if include_libs:
Expand Down Expand Up @@ -206,4 +222,10 @@ def get_package_data_files():
os.remove("MANIFEST.in")
for path in LIB_LIST:
_, libname = os.path.split(path)
os.remove("tvm/%s" % libname)
path_to_be_removed = f"tvm/{libname}"
leandron marked this conversation as resolved.
Show resolved Hide resolved

if os.path.isfile(path_to_be_removed):
os.remove(path_to_be_removed)

if os.path.isdir(path_to_be_removed):
shutil.rmtree(path_to_be_removed)