Files
pytorch/tools/build_libtorch.py
PyTorch MergeBot 475656fd9c Revert "[BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374)"
This reverts commit 2293fe1024812d6349f6e2b3b7de82c6b73f11e4.

Reverted https://github.com/pytorch/pytorch/pull/129374 on behalf of https://github.com/malfet due to failing internal ROCM builds with error: ModuleNotFoundError: No module named hipify ([comment](https://github.com/pytorch/pytorch/pull/129374#issuecomment-2562973920))
2024-12-26 17:32:23 +00:00

35 lines
1.1 KiB
Python

import argparse
import sys
from os.path import abspath, dirname
# By appending pytorch_root to sys.path, this module can import other torch
# modules even when run as a standalone script. i.e., it's okay either you
# do `python build_libtorch.py` or `python -m tools.build_libtorch`.
pytorch_root = dirname(dirname(abspath(__file__)))
sys.path.append(pytorch_root)
from tools.build_pytorch_libs import build_pytorch
from tools.setup_helpers.cmake import CMake
if __name__ == "__main__":
# Placeholder for future interface. For now just gives a nice -h.
parser = argparse.ArgumentParser(description="Build libtorch")
parser.add_argument("--rerun-cmake", action="store_true", help="rerun cmake")
parser.add_argument(
"--cmake-only",
action="store_true",
help="Stop once cmake terminates. Leave users a chance to adjust build options",
)
options = parser.parse_args()
build_pytorch(
version=None,
cmake_python_library=None,
build_python=False,
rerun_cmake=options.rerun_cmake,
cmake_only=options.cmake_only,
cmake=CMake(),
)