blob: 3b85d415d0273d696cc61a7aeee9fe6429f76278 [file] [log] [blame]
Anders Papitto130881f2018-08-16 07:57:00 -07001import argparse
Anders Papitto130881f2018-08-16 07:57:00 -07002import sys
Huy Do347b0362022-07-13 07:59:20 +00003from os.path import abspath, dirname
Anders Papitto130881f2018-08-16 07:57:00 -07004
Derek Kimec8b1c92019-01-16 23:52:37 -08005# By appending pytorch_root to sys.path, this module can import other torch
6# modules even when run as a standalone script. i.e., it's okay either you
7# do `python build_libtorch.py` or `python -m tools.build_libtorch`.
8pytorch_root = dirname(dirname(abspath(__file__)))
9sys.path.append(pytorch_root)
10
Zachary DeVito9477a5d2019-01-25 15:57:09 -080011from tools.build_pytorch_libs import build_caffe2
Hong Xub811b6d2019-06-14 08:10:18 -070012from tools.setup_helpers.cmake import CMake
Anders Papitto130881f2018-08-16 07:57:00 -070013
Edward Z. Yanga11c1bb2022-04-20 08:51:02 -040014if __name__ == "__main__":
Anders Papitto130881f2018-08-16 07:57:00 -070015 # Placeholder for future interface. For now just gives a nice -h.
Edward Z. Yanga11c1bb2022-04-20 08:51:02 -040016 parser = argparse.ArgumentParser(description="Build libtorch")
17 parser.add_argument("--rerun-cmake", action="store_true", help="rerun cmake")
18 parser.add_argument(
19 "--cmake-only",
20 action="store_true",
21 help="Stop once cmake terminates. Leave users a chance to adjust build options",
22 )
Peter Goldsborough130d55a2018-09-12 16:40:30 -070023 options = parser.parse_args()
Anders Papitto130881f2018-08-16 07:57:00 -070024
Edward Z. Yanga11c1bb2022-04-20 08:51:02 -040025 build_caffe2(
26 version=None,
27 cmake_python_library=None,
28 build_python=False,
29 rerun_cmake=options.rerun_cmake,
30 cmake_only=options.cmake_only,
31 cmake=CMake(),
32 )