Skip to content

Commit

Permalink
[Python] Fix setup.py for inplace build (apache#16214)
Browse files Browse the repository at this point in the history
Previously, `python/setup.py` missed to take the inplace build
case into account when doing file operations (such as finding
paths or copying files), which makes command `make cython` fail.

This PR fixes the issue by checking inplace builds.
  • Loading branch information
MasterJH5574 committed Dec 22, 2023
1 parent 5af4979 commit 02fb8c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
CURRENT_DIR = os.path.dirname(__file__)
FFI_MODE = os.environ.get("TVM_FFI", "auto")
CONDA_BUILD = os.getenv("CONDA_BUILD") is not None
INPLACE_BUILD = "--inplace" in sys.argv


def get_lib_path():
Expand All @@ -46,7 +47,7 @@ def get_lib_path():
libinfo = {"__file__": libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, "exec"), libinfo, libinfo)
version = libinfo["__version__"]
if not CONDA_BUILD:
if not CONDA_BUILD and not INPLACE_BUILD:
lib_path = libinfo["find_lib_path"]()
libs = [lib_path[0]]
if "runtime" not in libs[0]:
Expand Down Expand Up @@ -214,7 +215,7 @@ def is_pure(self):


setup_kwargs = {}
if not CONDA_BUILD:
if not CONDA_BUILD and not INPLACE_BUILD:
with open("MANIFEST.in", "w") as fo:
for path in LIB_LIST:
if os.path.isfile(path):
Expand Down Expand Up @@ -286,7 +287,7 @@ def long_description_contents():
)


if not CONDA_BUILD:
if not CONDA_BUILD and not INPLACE_BUILD:
# Wheel cleanup
os.remove("MANIFEST.in")
for path in LIB_LIST:
Expand Down

0 comments on commit 02fb8c6

Please sign in to comment.