Fetch TORCH_PYTHON_SRCS filelists from build_variables (#37267)
Summary:
In build-variables.bzl split filelist into `libtorch_python_core_sources` and `libtorch_python_distributed_sources`
Move jit passes from `glob_libtorch_python_sources()` to `libtorch_core_jit_sources` filelist
Validated that original `TORCH_PYTHON_SRCS` filelist matches one in `build_varaiables.bzl` by running the following script:
```
import os
def read_file(path):
with open(path) as f:
return f.read()
def get_cmake_torch_python_srcs():
caffe2_cmake = read_file("torch/CMakeLists.txt")
start = caffe2_cmake.find("set(TORCH_PYTHON_SRCS")
end = caffe2_cmake.find(")", start)
return caffe2_cmake[start:end+1]
def get_cmake_torch_python_srcs_list():
_srcs = get_cmake_torch_python_srcs()
unfiltered_list = [x.strip() for x in _srcs.split("\n") if len(x.strip())>0]
return [x.replace("${TORCH_SRC_DIR}/","torch/") for x in unfiltered_list if 'TORCH_SRC_DIR' in x]
import imp
build_variables = imp.load_source('build_variables', 'tools/build_variables.bzl')
libtorch_python_sources = set(build_variables.libtorch_python_core_sources)
torch_python_srcs = set(get_cmake_torch_python_srcs_list())
print(set.difference(libtorch_python_sources, torch_python_srcs))
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37267
Test Plan: CI
Differential Revision: D21258292
Pulled By: malfet
fbshipit-source-id: bb6d7ee73c97cbe149a9021756b9a4c9fb3ce50e