mirror of
https://github.com/ROCm/ROCm.git
synced 2026-04-05 03:01:17 -04:00
[BUILD] Use a persistent directory for cmake (#1548)
Fixes #1545 `build_temp` is a temporary directory which `distutils` used to keep in the `./build` directory, but when `pyproject.toml` is present `pip` now puts it in `/tmp` and removes it at the end of the build. Instead, this creates a new permanent directory like `python/build/cmake.linux_x86_64-cpython-3.8` (the old name but with cmake instead of temp). While I was looking at the verbose pip output, I also noticed a bunch of warnings like ``` Python recognizes 'triton/runtime.backends' as an importable package, but it is not listed in the `packages` configuration of setuptools. 'triton/runtime.backends' has been automatically added to the distribution only because it may contain data files, but this behavior is likely to change in future versions of setuptools (and therefore is considered deprecated). ``` So I've also added these to the packages list. --------- Co-authored-by: Keren Zhou <kerenzhou@openai.com>
This commit is contained in:
@@ -161,6 +161,14 @@ class CMakeBuild(build_ext):
|
||||
for ext in self.extensions:
|
||||
self.build_extension(ext)
|
||||
|
||||
def get_cmake_dir(self):
|
||||
plat_name = sysconfig.get_platform()
|
||||
python_version = sysconfig.get_python_version()
|
||||
dir_name = f"cmake.{plat_name}-{sys.implementation.name}-{python_version}"
|
||||
cmake_dir = Path(self.base_dir) / "python" / "build" / dir_name
|
||||
cmake_dir.mkdir(parents=True, exist_ok=True)
|
||||
return cmake_dir
|
||||
|
||||
def build_extension(self, ext):
|
||||
lit_dir = shutil.which('lit')
|
||||
user_home = os.getenv("HOME") or os.getenv("USERPROFILE") or \
|
||||
@@ -212,8 +220,9 @@ class CMakeBuild(build_ext):
|
||||
"-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld"]
|
||||
|
||||
env = os.environ.copy()
|
||||
subprocess.check_call(["cmake", self.base_dir] + cmake_args, cwd=self.build_temp, env=env)
|
||||
subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=self.build_temp)
|
||||
cmake_dir = self.get_cmake_dir()
|
||||
subprocess.check_call(["cmake", self.base_dir] + cmake_args, cwd=cmake_dir, env=env)
|
||||
subprocess.check_call(["cmake", "--build", "."] + build_args, cwd=cmake_dir)
|
||||
|
||||
|
||||
download_and_copy_ptxas()
|
||||
@@ -236,6 +245,10 @@ setup(
|
||||
"triton/ops",
|
||||
"triton/ops/blocksparse",
|
||||
"triton/runtime",
|
||||
"triton/runtime/backends",
|
||||
"triton/third_party/cuda/bin",
|
||||
"triton/third_party/cuda/include",
|
||||
"triton/third_party/cuda/lib",
|
||||
"triton/tools",
|
||||
],
|
||||
install_requires=[
|
||||
|
||||
Reference in New Issue
Block a user