Caffe2 - Python API
A deep learning, cross platform ML framework
build_libtorch.py
1 import argparse
2 import os
3 from os.path import dirname, abspath
4 import shlex
5 import subprocess
6 import sys
7 
8 # By appending pytorch_root to sys.path, this module can import other torch
9 # modules even when run as a standalone script. i.e., it's okay either you
10 # do `python build_libtorch.py` or `python -m tools.build_libtorch`.
11 pytorch_root = dirname(dirname(abspath(__file__)))
12 sys.path.append(pytorch_root)
13 
14 # If you want to modify flags or environmental variables that is set when
15 # building torch, you should do it in tools/setup_helpers/configure.py.
16 # Please don't add it here unless it's only used in LibTorch.
17 from tools.build_pytorch_libs import build_caffe2
18 
19 if __name__ == '__main__':
20  # Placeholder for future interface. For now just gives a nice -h.
21  parser = argparse.ArgumentParser(description='Build libtorch')
22  options = parser.parse_args()
23 
24  build_caffe2(version=None, cmake_python_library=None,
25  build_python=False, rerun_cmake=True, build_dir='.')