in setup.py [0:0]
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# required for auto-detection of auxiliary "native" libs
if not extdir.endswith(os.path.sep):
extdir += os.path.sep
if "DEBUG" in os.environ:
# TODO: is there any better approach?
cfg = "Debug" if os.environ["DEBUG"] == "1" else "Release"
else:
cfg = "Debug" if self.debug else "Release"
cmake_args = [
f"-DCMAKE_BUILD_TYPE={cfg}",
# f"-DCMAKE_PREFIX_PATH={torch.utils.cmake_prefix_path}",
f"-DCMAKE_INSTALL_PREFIX={extdir}",
# "-DCMAKE_VERBOSE_MAKEFILE=ON",
# f"-DPython_INCLUDE_DIR={distutils.sysconfig.get_python_inc()}",
"-DVELOX_CODEGEN_SUPPORT=OFF",
"-DVELOX_BUILD_MINIMAL=ON",
]
build_args = ["--target", "install"]
# Default to Ninja
if "CMAKE_GENERATOR" not in os.environ:
cmake_args += ["-GNinja"]
# Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level
# across all generators.
if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ:
# self.parallel is a Python 3 only way to set parallel jobs by hand
# using -j in the build_ext call, not supported by pip or PyPA-build.
if hasattr(self, "parallel") and self.parallel:
# CMake 3.12+ only.
build_args += ["-j{}".format(self.parallel)]
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
subprocess.check_call(
["cmake", str(ROOT_DIR)] + cmake_args, cwd=self.build_temp
)
subprocess.check_call(
["cmake", "--build", "."] + build_args, cwd=self.build_temp
)