Skip to content

Commit

Permalink
Fix python cmake sequencing.
Browse files Browse the repository at this point in the history
  • Loading branch information
stellaraccident committed Mar 13, 2024
1 parent c60084d commit 74837be
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions python_projects/runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ def getenv_bool(key, default_value="OFF"):
return value.upper() in ["ON", "1", "TRUE"]


class CMakeBuildPy(_build_py):
class CMakeBuilder:
def run(self):
super().run()
print("*****************************", file=sys.stderr)
print("* Building base runtime *", file=sys.stderr)
print("*****************************", file=sys.stderr)
Expand Down Expand Up @@ -85,7 +84,6 @@ def cmake_build(self):
)

def cmake_install(self):
(CMAKE_INSTALL_DIR / "__init__.py").touch()
with open(CMAKE_INSTALL_DIR / "version.py", "wt") as f:
f.write(f"py_version = '{VERSION}'\n")
# TODO: Add ROCM version, etc
Expand All @@ -96,19 +94,18 @@ def cmake_install(self):
)


class CustomBuild(_build):
def run(self):
self.run_command("build_py")
self.run_command("build_ext")
self.run_command("build_scripts")


packages = find_packages(where=".")
print("Found packages:", packages)

CMAKE_INSTALL_DIR.mkdir(parents=True, exist_ok=True)
(CMAKE_INSTALL_DIR / "__init__.py").touch()
CMAKE_BUILD_DIR.mkdir(parents=True, exist_ok=True)

# In order to reliably package the built files, it is best to run the build
# prior to setup. All built artifacts go into the _therock top level
# package so that source and built trees are distinct.
CMakeBuilder().run()

setup(
name=f"TheRock-runtime{SUFFIX}",
version=f"{VERSION}", # TODO: Get from env var.
Expand All @@ -126,8 +123,6 @@ def run(self):
url="https://github.com/nod-ai/TheRock",
python_requires=">=3.6",
cmdclass={
"build": CustomBuild,
"build_py": CMakeBuildPy,
"bdist_wheel": bdist_wheel,
},
zip_safe=False,
Expand Down

0 comments on commit 74837be

Please sign in to comment.