256
256
import setuptools .command .sdist
257
257
from setuptools import Extension , find_packages , setup
258
258
from setuptools .dist import Distribution
259
- from tools .build_pytorch_libs import build_caffe2
259
+ from tools .build_pytorch_libs import build_pytorch
260
260
from tools .generate_torch_version import get_torch_version
261
261
from tools .setup_helpers .cmake import CMake
262
262
from tools .setup_helpers .env import build_type , IS_DARWIN , IS_LINUX , IS_WINDOWS
@@ -339,7 +339,6 @@ def report(*args):
339
339
cwd = os .path .dirname (os .path .abspath (__file__ ))
340
340
lib_path = os .path .join (cwd , "torch" , "lib" )
341
341
third_party_path = os .path .join (cwd , "third_party" )
342
- caffe2_build_dir = os .path .join (cwd , "build" )
343
342
344
343
# CMAKE: full path to python library
345
344
if IS_WINDOWS :
@@ -484,7 +483,7 @@ def build_deps():
484
483
check_submodules ()
485
484
check_pydep ("yaml" , "pyyaml" )
486
485
build_python = not BUILD_LIBTORCH_WHL
487
- build_caffe2 (
486
+ build_pytorch (
488
487
version = version ,
489
488
cmake_python_library = cmake_python_library ,
490
489
build_python = build_python ,
@@ -730,47 +729,6 @@ def run(self):
730
729
731
730
def build_extensions (self ):
732
731
self .create_compile_commands ()
733
- # The caffe2 extensions are created in
734
- # tmp_install/lib/pythonM.m/site-packages/caffe2/python/
735
- # and need to be copied to build/lib.linux.... , which will be a
736
- # platform dependent build folder created by the "build" command of
737
- # setuptools. Only the contents of this folder are installed in the
738
- # "install" command by default.
739
- # We only make this copy for Caffe2's pybind extensions
740
- caffe2_pybind_exts = [
741
- "caffe2.python.caffe2_pybind11_state" ,
742
- "caffe2.python.caffe2_pybind11_state_gpu" ,
743
- "caffe2.python.caffe2_pybind11_state_hip" ,
744
- ]
745
- if BUILD_LIBTORCH_WHL :
746
- caffe2_pybind_exts = []
747
- i = 0
748
- while i < len (self .extensions ):
749
- ext = self .extensions [i ]
750
- if ext .name not in caffe2_pybind_exts :
751
- i += 1
752
- continue
753
- fullname = self .get_ext_fullname (ext .name )
754
- filename = self .get_ext_filename (fullname )
755
- report (f"\n Copying extension { ext .name } " )
756
-
757
- relative_site_packages = (
758
- sysconfig .get_path ("purelib" )
759
- .replace (sysconfig .get_path ("data" ), "" )
760
- .lstrip (os .path .sep )
761
- )
762
- src = os .path .join ("torch" , relative_site_packages , filename )
763
- if not os .path .exists (src ):
764
- report (f"{ src } does not exist" )
765
- del self .extensions [i ]
766
- else :
767
- dst = os .path .join (os .path .realpath (self .build_lib ), filename )
768
- report (f"Copying { ext .name } from { src } to { dst } " )
769
- dst_dir = os .path .dirname (dst )
770
- if not os .path .exists (dst_dir ):
771
- os .makedirs (dst_dir )
772
- self .copy_file (src , dst )
773
- i += 1
774
732
775
733
# Copy functorch extension
776
734
for i , ext in enumerate (self .extensions ):
@@ -1060,9 +1018,7 @@ def make_relative_rpath_args(path):
1060
1018
################################################################################
1061
1019
1062
1020
extensions = []
1063
- excludes = ["tools" , "tools.*" ]
1064
- if not cmake_cache_vars ["BUILD_CAFFE2" ]:
1065
- excludes .extend (["caffe2" , "caffe2.*" ])
1021
+ excludes = ["tools" , "tools.*" , "caffe2" , "caffe2.*" ]
1066
1022
if not cmake_cache_vars ["BUILD_FUNCTORCH" ]:
1067
1023
excludes .extend (["functorch" , "functorch.*" ])
1068
1024
packages = find_packages (exclude = excludes )
@@ -1082,18 +1038,6 @@ def make_relative_rpath_args(path):
1082
1038
1083
1039
# These extensions are built by cmake and copied manually in build_extensions()
1084
1040
# inside the build_ext implementation
1085
- if cmake_cache_vars ["BUILD_CAFFE2" ]:
1086
- extensions .append (
1087
- Extension (name = "caffe2.python.caffe2_pybind11_state" , sources = []),
1088
- )
1089
- if cmake_cache_vars ["USE_CUDA" ]:
1090
- extensions .append (
1091
- Extension (name = "caffe2.python.caffe2_pybind11_state_gpu" , sources = []),
1092
- )
1093
- if cmake_cache_vars ["USE_ROCM" ]:
1094
- extensions .append (
1095
- Extension (name = "caffe2.python.caffe2_pybind11_state_hip" , sources = []),
1096
- )
1097
1041
if cmake_cache_vars ["BUILD_FUNCTORCH" ]:
1098
1042
extensions .append (
1099
1043
Extension (name = "functorch._C" , sources = []),
@@ -1109,8 +1053,6 @@ def make_relative_rpath_args(path):
1109
1053
1110
1054
entry_points = {
1111
1055
"console_scripts" : [
1112
- "convert-caffe2-to-onnx = caffe2.python.onnx.bin.conversion:caffe2_to_onnx" ,
1113
- "convert-onnx-to-caffe2 = caffe2.python.onnx.bin.conversion:onnx_to_caffe2" ,
1114
1056
"torchrun = torch.distributed.run:main" ,
1115
1057
],
1116
1058
"torchrun.logs_specs" : [
@@ -1429,14 +1371,6 @@ def main():
1429
1371
"lib/*.lib" ,
1430
1372
]
1431
1373
)
1432
- if get_cmake_cache_vars ()["BUILD_CAFFE2" ]:
1433
- torch_package_data .extend (
1434
- [
1435
- "include/caffe2/**/*.h" ,
1436
- "include/caffe2/utils/*.h" ,
1437
- "include/caffe2/utils/**/*.h" ,
1438
- ]
1439
- )
1440
1374
if get_cmake_cache_vars ()["USE_TENSORPIPE" ]:
1441
1375
torch_package_data .extend (
1442
1376
[
@@ -1477,9 +1411,6 @@ def main():
1477
1411
1478
1412
if not BUILD_LIBTORCH_WHL :
1479
1413
package_data ["torchgen" ] = torchgen_package_data
1480
- package_data ["caffe2" ] = [
1481
- "python/serialized_test/data/operator_test/*.zip" ,
1482
- ]
1483
1414
else :
1484
1415
# no extensions in BUILD_LIBTORCH_WHL mode
1485
1416
extensions = []
0 commit comments