mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Summary: This commit removes the dependency on `build_pytorch_libs.sh` by moving the remaining functionality that is not expressible in cmake into python. Removing the indirection through bash also removes over 300 lines of environment munging code that is incredibly hard to understand because it passes a lot of secret parameters through `os.env`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/16289 Reviewed By: ezyang Differential Revision: D13821662 Pulled By: zdevito fbshipit-source-id: d658d26925e3b1169ac1e3d44a159cf8a1f0d9b1
26 lines
994 B
Python
26 lines
994 B
Python
import argparse
|
|
import os
|
|
from os.path import dirname, abspath
|
|
import shlex
|
|
import subprocess
|
|
import sys
|
|
|
|
# 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)
|
|
|
|
# If you want to modify flags or environmental variables that is set when
|
|
# building torch, you should do it in tools/setup_helpers/configure.py.
|
|
# Please don't add it here unless it's only used in LibTorch.
|
|
from tools.build_pytorch_libs import build_caffe2
|
|
|
|
if __name__ == '__main__':
|
|
# Placeholder for future interface. For now just gives a nice -h.
|
|
parser = argparse.ArgumentParser(description='Build libtorch')
|
|
options = parser.parse_args()
|
|
|
|
build_caffe2(version=None, cmake_python_library=None,
|
|
build_python=False, rerun_cmake=True, build_dir='.')
|