| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 1 | # Welcome to the PyTorch setup.py. |
| 2 | # |
| srib | 53d2612 | 2018-04-16 14:29:45 -0500 | [diff] [blame] | 3 | # Environment variables you are probably interested in: |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 4 | # |
| 5 | # DEBUG |
| 6 | # build with -O0 and -g (debug symbols) |
| 7 | # |
| Zachary DeVito | 788d2e8 | 2018-11-21 06:36:26 -0800 | [diff] [blame] | 8 | # REL_WITH_DEB_INFO |
| 9 | # build with optimizations and -g (debug symbols) |
| 10 | # |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 11 | # MAX_JOBS |
| 12 | # maximum number of compile jobs we should use to compile your code |
| 13 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 14 | # USE_CUDA=0 |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 15 | # disables CUDA build |
| 16 | # |
| 17 | # CFLAGS |
| 18 | # flags to apply to both C and C++ files to be compiled (a quirk of setup.py |
| 19 | # which we have faithfully adhered to in our build system is that CFLAGS |
| Hong Xu | 1a9334e | 2019-08-07 16:18:12 -0700 | [diff] [blame] | 20 | # also applies to C++ files (unless CXXFLAGS is set), in contrast to the |
| 21 | # default behavior of autogoo and cmake build systems.) |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 22 | # |
| 23 | # CC |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 24 | # the C/C++ compiler to use |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 25 | # |
| 26 | # Environment variables for feature toggles: |
| 27 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 28 | # USE_CUDNN=0 |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 29 | # disables the cuDNN build |
| 30 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 31 | # USE_FBGEMM=0 |
| Daya S Khudia | 18de330 | 2018-11-06 15:37:30 -0800 | [diff] [blame] | 32 | # disables the FBGEMM build |
| 33 | # |
| Ilia Cherniavskii | e34992e | 2021-01-22 00:06:18 -0800 | [diff] [blame] | 34 | # USE_KINETO=0 |
| 35 | # disables usage of libkineto library for profiling |
| Ilia Cherniavskii | f2da18a | 2020-11-21 20:18:40 -0800 | [diff] [blame] | 36 | # |
| Hong Xu | 240d62f | 2019-06-06 08:11:17 -0700 | [diff] [blame] | 37 | # USE_NUMPY=0 |
| 38 | # disables the NumPy build |
| 39 | # |
| Vishwak Srinivasan | 9e69703 | 2019-02-22 17:03:49 -0800 | [diff] [blame] | 40 | # BUILD_TEST=0 |
| Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 41 | # disables the test build |
| 42 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 43 | # USE_MKLDNN=0 |
| Gu, Jinghui | d01cb70 | 2018-11-08 11:16:33 -0800 | [diff] [blame] | 44 | # disables use of MKLDNN |
| 45 | # |
| Nathan John Sircombe | bf00d26 | 2021-05-20 07:42:48 -0700 | [diff] [blame] | 46 | # USE_MKLDNN_ACL |
| 47 | # enables use of Compute Library backend for MKLDNN on Arm; |
| 48 | # USE_MKLDNN must be explicitly enabled. |
| 49 | # |
| pinzhenx | bd604cb | 2020-03-26 22:01:21 -0700 | [diff] [blame] | 50 | # MKLDNN_CPU_RUNTIME |
| Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 51 | # MKL-DNN threading mode: TBB or OMP (default) |
| Ilia Cherniavskii | 481b6d0 | 2019-05-06 19:25:55 -0700 | [diff] [blame] | 52 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 53 | # USE_NNPACK=0 |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 54 | # disables NNPACK build |
| 55 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 56 | # USE_QNNPACK=0 |
| Marat Dukhan | 5e73b82 | 2018-10-25 22:13:18 -0700 | [diff] [blame] | 57 | # disables QNNPACK build (quantized 8-bit operators) |
| 58 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 59 | # USE_DISTRIBUTED=0 |
| Orion Reblitz-Richardson | dda8402 | 2018-09-06 08:40:57 -0700 | [diff] [blame] | 60 | # disables distributed (c10d, gloo, mpi, etc.) build |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 61 | # |
| Rong Rong (AI Infra) | f58f7b7 | 2021-03-05 14:37:24 -0800 | [diff] [blame] | 62 | # USE_TENSORPIPE=0 |
| 63 | # disables distributed Tensorpipe backend build |
| 64 | # |
| 65 | # USE_GLOO=0 |
| 66 | # disables distributed gloo backend build |
| 67 | # |
| 68 | # USE_MPI=0 |
| 69 | # disables distributed MPI backend build |
| 70 | # |
| Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 71 | # USE_SYSTEM_NCCL=0 |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 72 | # disables use of system-wide nccl (we will use our submoduled |
| Edward Z. Yang | eb18a2f | 2018-03-27 22:09:20 -0400 | [diff] [blame] | 73 | # copy in third_party/nccl) |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 74 | # |
| Vishwak Srinivasan | 9e69703 | 2019-02-22 17:03:49 -0800 | [diff] [blame] | 75 | # BUILD_CAFFE2_OPS=0 |
| Orion Reblitz-Richardson | a175282 | 2018-09-10 17:11:16 -0700 | [diff] [blame] | 76 | # disable Caffe2 operators build |
| 77 | # |
| Michael Suo | 18253f4 | 2020-10-01 14:56:59 -0700 | [diff] [blame] | 78 | # BUILD_CAFFE2=0 |
| 79 | # disable Caffe2 build |
| 80 | # |
| Hong Xu | 8a026d4 | 2019-09-10 04:31:31 -0700 | [diff] [blame] | 81 | # USE_IBVERBS |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 82 | # toggle features related to distributed support |
| 83 | # |
| Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 84 | # USE_OPENCV |
| 85 | # enables use of OpenCV for additional operators |
| 86 | # |
| Ilia Cherniavskii | 481b6d0 | 2019-05-06 19:25:55 -0700 | [diff] [blame] | 87 | # USE_OPENMP=0 |
| 88 | # disables use of OpenMP for parallelization |
| 89 | # |
| Orion Reblitz-Richardson | 25bd7fe | 2018-10-10 18:07:58 -0700 | [diff] [blame] | 90 | # USE_FFMPEG |
| 91 | # enables use of ffmpeg for additional operators |
| 92 | # |
| Orion Reblitz-Richardson | a175282 | 2018-09-10 17:11:16 -0700 | [diff] [blame] | 93 | # USE_LEVELDB |
| 94 | # enables use of LevelDB for storage |
| 95 | # |
| daquexian | 1fb8925 | 2018-10-03 06:03:02 -0700 | [diff] [blame] | 96 | # USE_LMDB |
| Orion Reblitz-Richardson | a175282 | 2018-09-10 17:11:16 -0700 | [diff] [blame] | 97 | # enables use of LMDB for storage |
| 98 | # |
| Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 99 | # BUILD_BINARY |
| 100 | # enables the additional binaries/ build |
| 101 | # |
| imaginary-person | 9e53c82 | 2021-07-22 08:49:55 -0700 | [diff] [blame] | 102 | # ATEN_AVX512_256=TRUE |
| 103 | # ATen AVX2 kernels can use 32 ymm registers, instead of the default 16. |
| 104 | # This option can be used if AVX512 doesn't perform well on a machine. |
| 105 | # The FBGEMM library also uses AVX512_256 kernels on Xeon D processors, |
| 106 | # but it also has some (optimized) assembly code. |
| 107 | # |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 108 | # PYTORCH_BUILD_VERSION |
| 109 | # PYTORCH_BUILD_NUMBER |
| 110 | # specify the version of PyTorch, rather than the hard-coded version |
| 111 | # in this file; used when we're building binaries for distribution |
| 112 | # |
| Richard Zou | 7355f5c | 2018-04-02 13:35:14 -0400 | [diff] [blame] | 113 | # TORCH_CUDA_ARCH_LIST |
| 114 | # specify which CUDA architectures to build for. |
| 115 | # ie `TORCH_CUDA_ARCH_LIST="6.0;7.0"` |
| Edward Yang | cd94163 | 2018-08-29 13:29:34 -0700 | [diff] [blame] | 116 | # These are not CUDA versions, instead, they specify what |
| 117 | # classes of NVIDIA hardware we should generate PTX for. |
| Richard Zou | 7355f5c | 2018-04-02 13:35:14 -0400 | [diff] [blame] | 118 | # |
| Jithun Nair | 8dfdc3d | 2021-12-13 15:38:06 -0800 | [diff] [blame] | 119 | # PYTORCH_ROCM_ARCH |
| 120 | # specify which AMD GPU targets to build for. |
| 121 | # ie `PYTORCH_ROCM_ARCH="gfx900;gfx906"` |
| 122 | # |
| Orion Reblitz-Richardson | edd4e2c | 2018-06-13 10:25:32 -0700 | [diff] [blame] | 123 | # ONNX_NAMESPACE |
| 124 | # specify a namespace for ONNX built here rather than the hard-coded |
| 125 | # one in this file; needed to build with other frameworks that share ONNX. |
| 126 | # |
| Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 127 | # BLAS |
| Robert Blackwell | cee4e8f | 2021-10-28 11:23:00 -0700 | [diff] [blame] | 128 | # BLAS to be used by Caffe2. Can be MKL, Eigen, ATLAS, FlexiBLAS, or OpenBLAS. If set |
| Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 129 | # then the build will fail if the requested BLAS is not found, otherwise |
| 130 | # the BLAS will be chosen based on what is found on your system. |
| 131 | # |
| Ilia Cherniavskii | 6350dbd | 2019-06-24 12:48:13 -0700 | [diff] [blame] | 132 | # MKL_THREADING |
| Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 133 | # MKL threading mode: SEQ, TBB or OMP (default) |
| Ilia Cherniavskii | 481b6d0 | 2019-05-06 19:25:55 -0700 | [diff] [blame] | 134 | # |
| Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 135 | # USE_REDIS |
| 136 | # Whether to use Redis for distributed workflows (Linux only) |
| 137 | # |
| 138 | # USE_ZSTD |
| 139 | # Enables use of ZSTD, if the libraries are found |
| 140 | # |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 141 | # Environment variables we respect (these environment variables are |
| 142 | # conventional and are often understood/set by other software.) |
| 143 | # |
| 144 | # CUDA_HOME (Linux/OS X) |
| 145 | # CUDA_PATH (Windows) |
| 146 | # specify where CUDA is installed; usually /usr/local/cuda or |
| 147 | # /usr/local/cuda-x.y |
| Sven-Hendrik Haase | 080266e | 2018-10-03 06:20:46 -0700 | [diff] [blame] | 148 | # CUDAHOSTCXX |
| 149 | # specify a different compiler than the system one to use as the CUDA |
| 150 | # host compiler for nvcc. |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 151 | # |
| Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 152 | # CUDA_NVCC_EXECUTABLE |
| 153 | # Specify a NVCC to use. This is used in our CI to point to a cached nvcc |
| 154 | # |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 155 | # CUDNN_LIB_DIR |
| 156 | # CUDNN_INCLUDE_DIR |
| 157 | # CUDNN_LIBRARY |
| 158 | # specify where cuDNN is installed |
| 159 | # |
| Johannes M Dieterich | a4c59a9 | 2018-08-23 15:20:02 -0700 | [diff] [blame] | 160 | # MIOPEN_LIB_DIR |
| 161 | # MIOPEN_INCLUDE_DIR |
| 162 | # MIOPEN_LIBRARY |
| 163 | # specify where MIOpen is installed |
| 164 | # |
| Hong Xu | 60c46dd | 2019-07-23 08:35:59 -0700 | [diff] [blame] | 165 | # NCCL_ROOT |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 166 | # NCCL_LIB_DIR |
| 167 | # NCCL_INCLUDE_DIR |
| 168 | # specify where nccl is installed |
| 169 | # |
| 170 | # NVTOOLSEXT_PATH (Windows only) |
| 171 | # specify where nvtoolsext is installed |
| 172 | # |
| Nathan John Sircombe | bf00d26 | 2021-05-20 07:42:48 -0700 | [diff] [blame] | 173 | # ACL_ROOT_DIR |
| 174 | # specify where Compute Library is installed |
| 175 | # |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 176 | # LIBRARY_PATH |
| 177 | # LD_LIBRARY_PATH |
| 178 | # we will search for libraries in these paths |
| Ilia Cherniavskii | c3d05e8 | 2019-05-24 01:59:00 -0700 | [diff] [blame] | 179 | # |
| Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 180 | # ATEN_THREADING |
| 181 | # ATen parallel backend to use for intra- and inter-op parallelism |
| Ilia Cherniavskii | c3d05e8 | 2019-05-24 01:59:00 -0700 | [diff] [blame] | 182 | # possible values: |
| Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 183 | # OMP - use OpenMP for intra-op and native backend for inter-op tasks |
| Ilia Cherniavskii | 82aecfa | 2019-05-28 01:37:40 -0700 | [diff] [blame] | 184 | # NATIVE - use native thread pool for both intra- and inter-op tasks |
| Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 185 | # TBB - using TBB for intra- and native thread pool for inter-op parallelism |
| Ilia Cherniavskii | 580eab6 | 2019-05-28 02:43:22 -0700 | [diff] [blame] | 186 | # |
| 187 | # USE_TBB |
| Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 188 | # enable TBB support |
| Ilia Cherniavskii | 580eab6 | 2019-05-28 02:43:22 -0700 | [diff] [blame] | 189 | # |
| Can Balioglu | 7565039 | 2021-08-02 07:37:57 -0700 | [diff] [blame] | 190 | # USE_SYSTEM_TBB |
| 191 | # Use system-provided Intel TBB. |
| 192 | # |
| Mo Zhou | ff21b15 | 2020-04-23 20:40:16 -0700 | [diff] [blame] | 193 | # USE_SYSTEM_LIBS (work in progress) |
| 194 | # Use system-provided libraries to satisfy the build dependencies. |
| 195 | # When turned on, the following cmake variables will be toggled as well: |
| 196 | # USE_SYSTEM_CPUINFO=ON USE_SYSTEM_SLEEF=ON BUILD_CUSTOM_PROTOBUF=OFF |
| Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 197 | |
| Nikita Shulga | a38eeef | 2020-10-14 16:30:39 -0700 | [diff] [blame] | 198 | # This future is needed to print Python2 EOL message |
| 199 | from __future__ import print_function |
| David Reiss | 3c85f44 | 2020-04-16 10:18:08 -0700 | [diff] [blame] | 200 | import sys |
| 201 | if sys.version_info < (3,): |
| Nikita Shulga | f00a37d | 2020-07-23 19:08:41 -0700 | [diff] [blame] | 202 | print("Python 2 has reached end-of-life and is no longer supported by PyTorch.") |
| 203 | sys.exit(-1) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 204 | if sys.platform == 'win32' and sys.maxsize.bit_length() == 31: |
| 205 | print("32-bit Windows Python runtime is not supported. Please switch to 64-bit Python.") |
| Nikita Shulga | f00a37d | 2020-07-23 19:08:41 -0700 | [diff] [blame] | 206 | sys.exit(-1) |
| David Reiss | 3c85f44 | 2020-04-16 10:18:08 -0700 | [diff] [blame] | 207 | |
| Hong Xu | 9063bce | 2020-08-28 09:03:02 -0700 | [diff] [blame] | 208 | import platform |
| Nikita Shulga | dc5cda0 | 2022-01-19 15:59:11 -0800 | [diff] [blame] | 209 | python_min_version = (3, 7, 0) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 210 | python_min_version_str = '.'.join(map(str, python_min_version)) |
| Nikita Shulga | 45de2ee | 2020-10-14 07:34:47 -0700 | [diff] [blame] | 211 | if sys.version_info < python_min_version: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 212 | print("You are using Python {}. Python >={} is required.".format(platform.python_version(), |
| 213 | python_min_version_str)) |
| Hong Xu | 9063bce | 2020-08-28 09:03:02 -0700 | [diff] [blame] | 214 | sys.exit(-1) |
| 215 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 216 | from setuptools import setup, Extension, find_packages |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 217 | from collections import defaultdict |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 218 | from setuptools.dist import Distribution |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 219 | import setuptools.command.build_ext |
| Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 220 | import setuptools.command.install |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 221 | import setuptools.command.sdist |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 222 | import filecmp |
| 223 | import shutil |
| 224 | import subprocess |
| 225 | import os |
| 226 | import json |
| 227 | import glob |
| 228 | import importlib |
| 229 | import time |
| 230 | import sysconfig |
| 231 | |
| Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 232 | from tools.build_pytorch_libs import build_caffe2 |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 233 | from tools.setup_helpers.env import (IS_WINDOWS, IS_DARWIN, IS_LINUX, |
| 234 | build_type) |
| Zsolt Dollenstein | b004307 | 2021-08-12 10:56:55 -0700 | [diff] [blame] | 235 | from tools.setup_helpers.cmake import CMake |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 236 | from tools.generate_torch_version import get_torch_version |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 237 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 238 | ################################################################################ |
| 239 | # Parameters parsed from environment |
| 240 | ################################################################################ |
| 241 | |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 242 | VERBOSE_SCRIPT = True |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 243 | RUN_BUILD_DEPS = True |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 244 | # see if the user passed a quiet flag to setup.py arguments and respect |
| 245 | # that in our parts of the build |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 246 | EMIT_BUILD_WARNING = False |
| Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 247 | RERUN_CMAKE = False |
| Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 248 | CMAKE_ONLY = False |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 249 | filtered_args = [] |
| 250 | for i, arg in enumerate(sys.argv): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 251 | if arg == '--cmake': |
| Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 252 | RERUN_CMAKE = True |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 253 | continue |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 254 | if arg == '--cmake-only': |
| Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 255 | # Stop once cmake terminates. Leave users a chance to adjust build |
| 256 | # options. |
| 257 | CMAKE_ONLY = True |
| 258 | continue |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 259 | if arg == 'rebuild' or arg == 'build': |
| 260 | arg = 'build' # rebuild is gone, make it build |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 261 | EMIT_BUILD_WARNING = True |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 262 | if arg == "--": |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 263 | filtered_args += sys.argv[i:] |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 264 | break |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 265 | if arg == '-q' or arg == '--quiet': |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 266 | VERBOSE_SCRIPT = False |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 267 | if arg in ['clean', 'egg_info', 'sdist']: |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 268 | RUN_BUILD_DEPS = False |
| 269 | filtered_args.append(arg) |
| 270 | sys.argv = filtered_args |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 271 | |
| 272 | if VERBOSE_SCRIPT: |
| 273 | def report(*args): |
| 274 | print(*args) |
| 275 | else: |
| 276 | def report(*args): |
| 277 | pass |
| 278 | |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 279 | # Make distutils respect --quiet too |
| 280 | setuptools.distutils.log.warn = report |
| 281 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 282 | # Constant known variables used throughout this file |
| 283 | cwd = os.path.dirname(os.path.abspath(__file__)) |
| 284 | lib_path = os.path.join(cwd, "torch", "lib") |
| 285 | third_party_path = os.path.join(cwd, "third_party") |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 286 | caffe2_build_dir = os.path.join(cwd, "build") |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 287 | |
| Philip Yang | b57fdf1 | 2018-10-12 08:06:43 -0700 | [diff] [blame] | 288 | # CMAKE: full path to python library |
| CircleCI | f1a2bc4 | 2018-11-12 14:35:39 -0800 | [diff] [blame] | 289 | if IS_WINDOWS: |
| 290 | cmake_python_library = "{}/libs/python{}.lib".format( |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 291 | sysconfig.get_config_var("prefix"), |
| 292 | sysconfig.get_config_var("VERSION")) |
| zrphercule | c564d79 | 2019-12-05 13:21:43 -0800 | [diff] [blame] | 293 | # Fix virtualenv builds |
| peter | d05da7d | 2019-11-06 09:00:52 -0800 | [diff] [blame] | 294 | # TODO: Fix for python < 3.3 |
| 295 | if not os.path.exists(cmake_python_library): |
| 296 | cmake_python_library = "{}/libs/python{}.lib".format( |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 297 | sys.base_prefix, |
| 298 | sysconfig.get_config_var("VERSION")) |
| CircleCI | f1a2bc4 | 2018-11-12 14:35:39 -0800 | [diff] [blame] | 299 | else: |
| 300 | cmake_python_library = "{}/{}".format( |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 301 | sysconfig.get_config_var("LIBDIR"), |
| 302 | sysconfig.get_config_var("INSTSONAME")) |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 303 | cmake_python_include_dir = sysconfig.get_path("include") |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 304 | |
| Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 305 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 306 | ################################################################################ |
| Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 307 | # Version, create_version_file, and package_name |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 308 | ################################################################################ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 309 | package_name = os.getenv('TORCH_PACKAGE_NAME', 'torch') |
| Michael Suo | 161490d4 | 2020-09-16 15:39:56 -0700 | [diff] [blame] | 310 | version = get_torch_version() |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 311 | report("Building wheel {}-{}".format(package_name, version)) |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 312 | |
| Hong Xu | 82545ec | 2019-07-25 07:16:01 -0700 | [diff] [blame] | 313 | cmake = CMake() |
| Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 314 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 315 | |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 316 | def get_submodule_folders(): |
| 317 | git_modules_path = os.path.join(cwd, ".gitmodules") |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 318 | default_modules_path = [os.path.join(third_party_path, name) for name in [ |
| 319 | "gloo", "cpuinfo", "tbb", "onnx", |
| 320 | "foxi", "QNNPACK", "fbgemm" |
| 321 | ]] |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 322 | if not os.path.exists(git_modules_path): |
| 323 | return default_modules_path |
| 324 | with open(git_modules_path) as f: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 325 | return [os.path.join(cwd, line.split("=", 1)[1].strip()) for line in |
| 326 | f.readlines() if line.strip().startswith("path")] |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 327 | |
| 328 | |
| Nikita Shulga | 272dfc7 | 2021-03-01 18:26:24 -0800 | [diff] [blame] | 329 | def check_submodules(): |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 330 | def check_for_files(folder, files): |
| 331 | if not any(os.path.exists(os.path.join(folder, f)) for f in files): |
| 332 | report("Could not find any of {} in {}".format(", ".join(files), folder)) |
| zhouzhuojie | 6107cf3 | 2021-07-07 15:37:32 -0700 | [diff] [blame] | 333 | report("Did you run 'git submodule update --init --recursive --jobs 0'?") |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 334 | sys.exit(1) |
| 335 | |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 336 | def not_exists_or_empty(folder): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 337 | return not os.path.exists(folder) or (os.path.isdir(folder) and len(os.listdir(folder)) == 0) |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 338 | |
| 339 | if bool(os.getenv("USE_SYSTEM_LIBS", False)): |
| 340 | return |
| 341 | folders = get_submodule_folders() |
| 342 | # If none of the submodule folders exists, try to initialize them |
| 343 | if all(not_exists_or_empty(folder) for folder in folders): |
| 344 | try: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 345 | print(' --- Trying to initialize submodules') |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 346 | start = time.time() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 347 | subprocess.check_call(["git", "submodule", "update", "--init", "--recursive"], cwd=cwd) |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 348 | end = time.time() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 349 | print(' --- Submodule initialization took {:.2f} sec'.format(end - start)) |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 350 | except Exception: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 351 | print(' --- Submodule initalization failed') |
| 352 | print('Please run:\n\tgit submodule update --init --recursive --jobs 0') |
| Nikita Shulga | 7e6a84d | 2021-03-09 09:09:32 -0800 | [diff] [blame] | 353 | sys.exit(1) |
| 354 | for folder in folders: |
| Nikita Shulga | 6e5d065b | 2021-08-17 15:28:45 -0700 | [diff] [blame] | 355 | check_for_files(folder, ["CMakeLists.txt", "Makefile", "setup.py", "LICENSE", "LICENSE.md", "LICENSE.txt"]) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 356 | check_for_files(os.path.join(third_party_path, 'fbgemm', 'third_party', |
| 357 | 'asmjit'), ['CMakeLists.txt']) |
| 358 | check_for_files(os.path.join(third_party_path, 'onnx', 'third_party', |
| 359 | 'benchmark'), ['CMakeLists.txt']) |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 360 | |
| Nikita Shulga | 272dfc7 | 2021-03-01 18:26:24 -0800 | [diff] [blame] | 361 | |
| 362 | # all the work we need to do _before_ setup runs |
| 363 | def build_deps(): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 364 | report('-- Building version ' + version) |
| Nikita Shulga | 272dfc7 | 2021-03-01 18:26:24 -0800 | [diff] [blame] | 365 | |
| 366 | check_submodules() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 367 | check_pydep('yaml', 'pyyaml') |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 368 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 369 | build_caffe2(version=version, |
| 370 | cmake_python_library=cmake_python_library, |
| 371 | build_python=True, |
| 372 | rerun_cmake=RERUN_CMAKE, |
| 373 | cmake_only=CMAKE_ONLY, |
| 374 | cmake=cmake) |
| Hong Xu | 081069e | 2019-10-04 07:48:19 -0700 | [diff] [blame] | 375 | |
| Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 376 | if CMAKE_ONLY: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 377 | report('Finished running cmake. Run "ccmake build" or ' |
| 378 | '"cmake-gui build" to adjust build options and ' |
| 379 | '"python setup.py install" to build.') |
| Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 380 | sys.exit() |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 381 | |
| 382 | # Use copies instead of symbolic files. |
| 383 | # Windows has very poor support for them. |
| Taylor Robie | 17ea112 | 2020-12-01 19:56:13 -0800 | [diff] [blame] | 384 | sym_files = [ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 385 | 'tools/shared/_utils_internal.py', |
| 386 | 'torch/utils/benchmark/utils/valgrind_wrapper/callgrind.h', |
| 387 | 'torch/utils/benchmark/utils/valgrind_wrapper/valgrind.h', |
| Taylor Robie | 17ea112 | 2020-12-01 19:56:13 -0800 | [diff] [blame] | 388 | ] |
| 389 | orig_files = [ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 390 | 'torch/_utils_internal.py', |
| 391 | 'third_party/valgrind-headers/callgrind.h', |
| 392 | 'third_party/valgrind-headers/valgrind.h', |
| Taylor Robie | 17ea112 | 2020-12-01 19:56:13 -0800 | [diff] [blame] | 393 | ] |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 394 | for sym_file, orig_file in zip(sym_files, orig_files): |
| 395 | same = False |
| 396 | if os.path.exists(sym_file): |
| 397 | if filecmp.cmp(sym_file, orig_file): |
| 398 | same = True |
| 399 | else: |
| 400 | os.remove(sym_file) |
| 401 | if not same: |
| 402 | shutil.copyfile(orig_file, sym_file) |
| 403 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 404 | ################################################################################ |
| 405 | # Building dependent libraries |
| Adam Paszke | 690d470 | 2016-05-03 15:11:32 +0200 | [diff] [blame] | 406 | ################################################################################ |
| Adam Paszke | 842e1b6 | 2016-05-05 20:58:13 +0200 | [diff] [blame] | 407 | |
| Soumith Chintala | 6313d5e | 2019-08-04 17:17:33 -0700 | [diff] [blame] | 408 | # the list of runtime dependencies required by this built package |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 409 | install_requires = [ |
| 410 | 'typing_extensions', |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 411 | ] |
| Soumith Chintala | 6313d5e | 2019-08-04 17:17:33 -0700 | [diff] [blame] | 412 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 413 | missing_pydep = ''' |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 414 | Missing build dependency: Unable to `import {importname}`. |
| 415 | Please install it via `conda install {module}` or `pip install {module}` |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 416 | '''.strip() |
| Sam Gross | 966fdbd | 2017-08-23 07:16:06 -0400 | [diff] [blame] | 417 | |
| Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 418 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 419 | def check_pydep(importname, module): |
| 420 | try: |
| 421 | importlib.import_module(importname) |
| 422 | except ImportError: |
| 423 | raise RuntimeError(missing_pydep.format(importname=importname, module=module)) |
| Zachary DeVito | 0e54c3a98 | 2017-11-29 16:10:51 -0500 | [diff] [blame] | 424 | |
| Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 425 | |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 426 | class build_ext(setuptools.command.build_ext.build_ext): |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 427 | |
| 428 | # Copy libiomp5.dylib inside the wheel package on OS X |
| 429 | def _embed_libiomp(self): |
| 430 | if not IS_DARWIN: |
| 431 | return |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 432 | lib_dir = os.path.join(self.build_lib, 'torch', 'lib') |
| 433 | libtorch_cpu_path = os.path.join(lib_dir, 'libtorch_cpu.dylib') |
| Nikita Shulga | 6f60251 | 2020-11-04 14:13:10 -0800 | [diff] [blame] | 434 | if not os.path.exists(libtorch_cpu_path): |
| 435 | return |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 436 | # Parse libtorch_cpu load commands |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 437 | otool_cmds = subprocess.check_output(['otool', '-l', libtorch_cpu_path]).decode('utf-8').split('\n') |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 438 | rpaths, libs = [], [] |
| 439 | for idx, line in enumerate(otool_cmds): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 440 | if line.strip() == 'cmd LC_LOAD_DYLIB': |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 441 | lib_name = otool_cmds[idx + 2].strip() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 442 | assert lib_name.startswith('name ') |
| 443 | libs.append(lib_name.split(' ', 1)[1].rsplit('(', 1)[0][:-1]) |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 444 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 445 | if line.strip() == 'cmd LC_RPATH': |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 446 | rpath = otool_cmds[idx + 2].strip() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 447 | assert rpath.startswith('path ') |
| 448 | rpaths.append(rpath.split(' ', 1)[1].rsplit('(', 1)[0][:-1]) |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 449 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 450 | omp_lib_name = 'libiomp5.dylib' |
| 451 | if os.path.join('@rpath', omp_lib_name) not in libs: |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 452 | return |
| 453 | |
| 454 | # Copy libiomp5 from rpath locations |
| 455 | for rpath in rpaths: |
| 456 | source_lib = os.path.join(rpath, omp_lib_name) |
| 457 | if not os.path.exists(source_lib): |
| 458 | continue |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 459 | target_lib = os.path.join(self.build_lib, 'torch', 'lib', omp_lib_name) |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 460 | self.copy_file(source_lib, target_lib) |
| 461 | break |
| 462 | |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 463 | def run(self): |
| Hong Xu | 0408697 | 2019-06-17 13:42:45 -0700 | [diff] [blame] | 464 | # Report build options. This is run after the build completes so # `CMakeCache.txt` exists and we can get an |
| 465 | # accurate report on what is used and what is not. |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 466 | cmake_cache_vars = defaultdict(lambda: False, cmake.get_cmake_cache_variables()) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 467 | if cmake_cache_vars['USE_NUMPY']: |
| 468 | report('-- Building with NumPy bindings') |
| Adam Paszke | 08d346d | 2016-12-15 00:04:28 +0100 | [diff] [blame] | 469 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 470 | report('-- NumPy not found') |
| 471 | if cmake_cache_vars['USE_CUDNN']: |
| 472 | report('-- Detected cuDNN at ' + |
| 473 | cmake_cache_vars['CUDNN_LIBRARY'] + ', ' + cmake_cache_vars['CUDNN_INCLUDE_DIR']) |
| Adam Paszke | 08d346d | 2016-12-15 00:04:28 +0100 | [diff] [blame] | 474 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 475 | report('-- Not using cuDNN') |
| 476 | if cmake_cache_vars['USE_CUDA']: |
| 477 | report('-- Detected CUDA at ' + cmake_cache_vars['CUDA_TOOLKIT_ROOT_DIR']) |
| Adam Paszke | 08d346d | 2016-12-15 00:04:28 +0100 | [diff] [blame] | 478 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 479 | report('-- Not using CUDA') |
| 480 | if cmake_cache_vars['USE_MKLDNN']: |
| 481 | report('-- Using MKLDNN') |
| 482 | if cmake_cache_vars['USE_MKLDNN_ACL']: |
| 483 | report('-- Using Compute Library for the Arm architecture with MKLDNN') |
| Nathan John Sircombe | bf00d26 | 2021-05-20 07:42:48 -0700 | [diff] [blame] | 484 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 485 | report('-- Not using Compute Library for the Arm architecture with MKLDNN') |
| 486 | if cmake_cache_vars['USE_MKLDNN_CBLAS']: |
| 487 | report('-- Using CBLAS in MKLDNN') |
| Hui Wu | 07ef85e | 2019-07-02 12:22:20 -0700 | [diff] [blame] | 488 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 489 | report('-- Not using CBLAS in MKLDNN') |
| Ma Mingfei | f8270c0 | 2018-03-30 06:25:07 +0800 | [diff] [blame] | 490 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 491 | report('-- Not using MKLDNN') |
| 492 | if cmake_cache_vars['USE_NCCL'] and cmake_cache_vars['USE_SYSTEM_NCCL']: |
| 493 | report('-- Using system provided NCCL library at {}, {}'.format(cmake_cache_vars['NCCL_LIBRARIES'], |
| 494 | cmake_cache_vars['NCCL_INCLUDE_DIRS'])) |
| 495 | elif cmake_cache_vars['USE_NCCL']: |
| 496 | report('-- Building NCCL library') |
| Sam Gross | b9379cf | 2017-03-16 16:10:17 -0400 | [diff] [blame] | 497 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 498 | report('-- Not using NCCL') |
| 499 | if cmake_cache_vars['USE_DISTRIBUTED']: |
| Pieter Noordhuis | 3556bea | 2019-09-05 07:08:12 -0700 | [diff] [blame] | 500 | if IS_WINDOWS: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 501 | report('-- Building without distributed package') |
| Teng Li | 020501b | 2018-09-04 17:18:29 -0700 | [diff] [blame] | 502 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 503 | report('-- Building with distributed package: ') |
| 504 | report(' -- USE_TENSORPIPE={}'.format(cmake_cache_vars['USE_TENSORPIPE'])) |
| 505 | report(' -- USE_GLOO={}'.format(cmake_cache_vars['USE_GLOO'])) |
| 506 | report(' -- USE_MPI={}'.format(cmake_cache_vars['USE_OPENMPI'])) |
| Adam Paszke | 714351f | 2017-06-07 06:36:20 -0400 | [diff] [blame] | 507 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 508 | report('-- Building without distributed package') |
| peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 509 | |
| Nikita Shulga | 2dff0b3 | 2020-11-24 10:55:00 -0800 | [diff] [blame] | 510 | # Do not use clang to compile extensions if `-fstack-clash-protection` is defined |
| Nikita Shulga | dd7cec6 | 2020-03-10 15:29:07 -0700 | [diff] [blame] | 511 | # in system CFLAGS |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 512 | c_flags = str(os.getenv('CFLAGS', '')) |
| 513 | if IS_LINUX and '-fstack-clash-protection' in c_flags and 'clang' in os.environ.get('CC', ''): |
| 514 | os.environ['CC'] = str(os.environ['CC']) |
| Nikita Shulga | dd7cec6 | 2020-03-10 15:29:07 -0700 | [diff] [blame] | 515 | |
| Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 516 | # It's an old-style class in Python 2.7... |
| 517 | setuptools.command.build_ext.build_ext.run(self) |
| 518 | |
| Nikita Shulga | 14194e4 | 2020-11-03 12:55:14 -0800 | [diff] [blame] | 519 | self._embed_libiomp() |
| 520 | |
| peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 521 | # Copy the essential export library to compile C++ extensions. |
| 522 | if IS_WINDOWS: |
| 523 | build_temp = self.build_temp |
| 524 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 525 | ext_filename = self.get_ext_filename('_C') |
| 526 | lib_filename = '.'.join(ext_filename.split('.')[:-1]) + '.lib' |
| peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 527 | |
| 528 | export_lib = os.path.join( |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 529 | build_temp, 'torch', 'csrc', lib_filename).replace('\\', '/') |
| peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 530 | |
| 531 | build_lib = self.build_lib |
| 532 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 533 | target_lib = os.path.join( |
| 534 | build_lib, 'torch', 'lib', '_C.lib').replace('\\', '/') |
| peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 535 | |
| Shuichi KITAGUCHI | ddbfdc9 | 2019-04-01 07:24:27 -0700 | [diff] [blame] | 536 | # Create "torch/lib" directory if not exists. |
| 537 | # (It is not created yet in "develop" mode.) |
| 538 | target_dir = os.path.dirname(target_lib) |
| 539 | if not os.path.exists(target_dir): |
| 540 | os.makedirs(target_dir) |
| 541 | |
| peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 542 | self.copy_file(export_lib, target_lib) |
| 543 | |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 544 | def build_extensions(self): |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 545 | self.create_compile_commands() |
| Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 546 | # The caffe2 extensions are created in |
| andersj | 8a5ba57 | 2019-01-08 15:54:20 -0800 | [diff] [blame] | 547 | # tmp_install/lib/pythonM.m/site-packages/caffe2/python/ |
| Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 548 | # and need to be copied to build/lib.linux.... , which will be a |
| 549 | # platform dependent build folder created by the "build" command of |
| 550 | # setuptools. Only the contents of this folder are installed in the |
| 551 | # "install" command by default. |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 552 | # We only make this copy for Caffe2's pybind extensions |
| 553 | caffe2_pybind_exts = [ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 554 | 'caffe2.python.caffe2_pybind11_state', |
| 555 | 'caffe2.python.caffe2_pybind11_state_gpu', |
| 556 | 'caffe2.python.caffe2_pybind11_state_hip', |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 557 | ] |
| 558 | i = 0 |
| 559 | while i < len(self.extensions): |
| 560 | ext = self.extensions[i] |
| 561 | if ext.name not in caffe2_pybind_exts: |
| 562 | i += 1 |
| 563 | continue |
| 564 | fullname = self.get_ext_fullname(ext.name) |
| 565 | filename = self.get_ext_filename(fullname) |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 566 | report("\nCopying extension {}".format(ext.name)) |
| Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 567 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 568 | relative_site_packages = sysconfig.get_path('purelib').replace(sysconfig.get_path('data'), '').lstrip(os.path.sep) |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 569 | src = os.path.join("torch", relative_site_packages, filename) |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 570 | if not os.path.exists(src): |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 571 | report("{} does not exist".format(src)) |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 572 | del self.extensions[i] |
| 573 | else: |
| 574 | dst = os.path.join(os.path.realpath(self.build_lib), filename) |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 575 | report("Copying {} from {} to {}".format(ext.name, src, dst)) |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 576 | dst_dir = os.path.dirname(dst) |
| 577 | if not os.path.exists(dst_dir): |
| 578 | os.makedirs(dst_dir) |
| 579 | self.copy_file(src, dst) |
| 580 | i += 1 |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 581 | setuptools.command.build_ext.build_ext.build_extensions(self) |
| 582 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 583 | |
| Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 584 | def get_outputs(self): |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 585 | outputs = setuptools.command.build_ext.build_ext.get_outputs(self) |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 586 | outputs.append(os.path.join(self.build_lib, "caffe2")) |
| Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 587 | report("setup.py::get_outputs returning {}".format(outputs)) |
| Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 588 | return outputs |
| 589 | |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 590 | def create_compile_commands(self): |
| 591 | def load(filename): |
| 592 | with open(filename) as f: |
| 593 | return json.load(f) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 594 | ninja_files = glob.glob('build/*compile_commands.json') |
| 595 | cmake_files = glob.glob('torch/lib/build/*/compile_commands.json') |
| 596 | all_commands = [entry |
| 597 | for f in ninja_files + cmake_files |
| 598 | for entry in load(f)] |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 599 | |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 600 | # cquery does not like c++ compiles that start with gcc. |
| 601 | # It forgets to include the c++ header directories. |
| 602 | # We can work around this by replacing the gcc calls that python |
| 603 | # setup.py generates with g++ calls instead |
| 604 | for command in all_commands: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 605 | if command['command'].startswith("gcc "): |
| 606 | command['command'] = "g++ " + command['command'][4:] |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 607 | |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 608 | new_contents = json.dumps(all_commands, indent=2) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 609 | contents = '' |
| 610 | if os.path.exists('compile_commands.json'): |
| 611 | with open('compile_commands.json', 'r') as f: |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 612 | contents = f.read() |
| 613 | if contents != new_contents: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 614 | with open('compile_commands.json', 'w') as f: |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 615 | f.write(new_contents) |
| Soumith Chintala | 4e8d9a4 | 2018-09-11 08:51:19 -0700 | [diff] [blame] | 616 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 617 | class concat_license_files(): |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 618 | """Merge LICENSE and LICENSES_BUNDLED.txt as a context manager |
| 619 | |
| 620 | LICENSE is the main PyTorch license, LICENSES_BUNDLED.txt is auto-generated |
| 621 | from all the licenses found in ./third_party/. We concatenate them so there |
| 622 | is a single license file in the sdist and wheels with all of the necessary |
| 623 | licensing info. |
| 624 | """ |
| 625 | def __init__(self): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 626 | self.f1 = 'LICENSE' |
| 627 | self.f2 = 'third_party/LICENSES_BUNDLED.txt' |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 628 | |
| 629 | def __enter__(self): |
| 630 | """Concatenate files""" |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 631 | with open(self.f1, 'r') as f1: |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 632 | self.bsd_text = f1.read() |
| 633 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 634 | with open(self.f1, 'a') as f1: |
| 635 | with open(self.f2, 'r') as f2: |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 636 | self.bundled_text = f2.read() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 637 | f1.write('\n\n') |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 638 | f1.write(self.bundled_text) |
| 639 | |
| 640 | def __exit__(self, exception_type, exception_value, traceback): |
| 641 | """Restore content of f1""" |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 642 | with open(self.f1, 'w') as f: |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 643 | f.write(self.bsd_text) |
| 644 | |
| 645 | |
| 646 | try: |
| 647 | from wheel.bdist_wheel import bdist_wheel |
| 648 | except ImportError: |
| 649 | # This is useful when wheel is not installed and bdist_wheel is not |
| 650 | # specified on the command line. If it _is_ specified, parsing the command |
| 651 | # line will fail before wheel_concatenate is needed |
| 652 | wheel_concatenate = None |
| 653 | else: |
| 654 | # Need to create the proper LICENSE.txt for the wheel |
| 655 | class wheel_concatenate(bdist_wheel): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 656 | """ check submodules on sdist to prevent incomplete tarballs """ |
| mattip | 9cbefad | 2021-02-08 08:23:56 -0800 | [diff] [blame] | 657 | def run(self): |
| 658 | with concat_license_files(): |
| 659 | super().run() |
| 660 | |
| Soumith Chintala | 4e8d9a4 | 2018-09-11 08:51:19 -0700 | [diff] [blame] | 661 | |
| Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 662 | class install(setuptools.command.install.install): |
| 663 | def run(self): |
| Nikita Shulga | 272dfc7 | 2021-03-01 18:26:24 -0800 | [diff] [blame] | 664 | super().run() |
| Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 665 | |
| 666 | |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 667 | class clean(setuptools.Command): |
| 668 | user_options = [] |
| 669 | |
| 670 | def initialize_options(self): |
| 671 | pass |
| 672 | |
| 673 | def finalize_options(self): |
| 674 | pass |
| 675 | |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 676 | def run(self): |
| Soumith Chintala | 140c65e | 2016-10-21 23:16:39 -0400 | [diff] [blame] | 677 | import glob |
| Shuichi KITAGUCHI | df23bdc | 2018-08-05 15:47:02 -0700 | [diff] [blame] | 678 | import re |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 679 | with open('.gitignore', 'r') as f: |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 680 | ignores = f.read() |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 681 | pat = re.compile(r'^#( BEGIN NOT-CLEAN-FILES )?') |
| 682 | for wildcard in filter(None, ignores.split('\n')): |
| Shuichi KITAGUCHI | df23bdc | 2018-08-05 15:47:02 -0700 | [diff] [blame] | 683 | match = pat.match(wildcard) |
| 684 | if match: |
| 685 | if match.group(1): |
| 686 | # Marker is found and stop reading .gitignore. |
| 687 | break |
| 688 | # Ignore lines which begin with '#'. |
| 689 | else: |
| 690 | for filename in glob.glob(wildcard): |
| 691 | try: |
| 692 | os.remove(filename) |
| 693 | except OSError: |
| 694 | shutil.rmtree(filename, ignore_errors=True) |
| Sam Gross | f2d7e94 | 2016-10-26 09:51:52 -0700 | [diff] [blame] | 695 | |
| Nikita Shulga | 272dfc7 | 2021-03-01 18:26:24 -0800 | [diff] [blame] | 696 | |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 697 | class sdist(setuptools.command.sdist.sdist): |
| Nikita Shulga | 272dfc7 | 2021-03-01 18:26:24 -0800 | [diff] [blame] | 698 | def run(self): |
| 699 | with concat_license_files(): |
| 700 | super().run() |
| 701 | |
| Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 702 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 703 | def configure_extension_build(): |
| 704 | r"""Configures extension build options according to system environment and user's choice. |
| Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 705 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 706 | Returns: |
| 707 | The input to parameters ext_modules, cmdclass, packages, and entry_points as required in setuptools.setup. |
| 708 | """ |
| Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 709 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 710 | try: |
| 711 | cmake_cache_vars = defaultdict(lambda: False, cmake.get_cmake_cache_variables()) |
| 712 | except FileNotFoundError: |
| 713 | # CMakeCache.txt does not exist. Probably running "python setup.py clean" over a clean directory. |
| 714 | cmake_cache_vars = defaultdict(lambda: False) |
| peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 715 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 716 | ################################################################################ |
| 717 | # Configure compile flags |
| 718 | ################################################################################ |
| Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 719 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 720 | library_dirs = [] |
| Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 721 | extra_install_requires = [] |
| Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 722 | |
| peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 723 | if IS_WINDOWS: |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 724 | # /NODEFAULTLIB makes sure we only link to DLL runtime |
| 725 | # and matches the flags set for protobuf and ONNX |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 726 | extra_link_args = ['/NODEFAULTLIB:LIBCMT.LIB'] |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 727 | # /MD links against DLL runtime |
| 728 | # and matches the flags set for protobuf and ONNX |
| peter | c5d6f59a | 2020-04-28 08:16:40 -0700 | [diff] [blame] | 729 | # /EHsc is about standard C++ exception handling |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 730 | # /DNOMINMAX removes builtin min/max functions |
| 731 | # /wdXXXX disables warning no. XXXX |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 732 | extra_compile_args = ['/MD', '/EHsc', '/DNOMINMAX', |
| 733 | '/wd4267', '/wd4251', '/wd4522', '/wd4522', '/wd4838', |
| 734 | '/wd4305', '/wd4244', '/wd4190', '/wd4101', '/wd4996', |
| 735 | '/wd4275'] |
| peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 736 | else: |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 737 | extra_link_args = [] |
| 738 | extra_compile_args = [ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 739 | '-Wall', |
| 740 | '-Wextra', |
| 741 | '-Wno-strict-overflow', |
| 742 | '-Wno-unused-parameter', |
| 743 | '-Wno-missing-field-initializers', |
| 744 | '-Wno-write-strings', |
| 745 | '-Wno-unknown-pragmas', |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 746 | # This is required for Python 2 declarations that are deprecated in 3. |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 747 | '-Wno-deprecated-declarations', |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 748 | # Python 2.6 requires -fno-strict-aliasing, see |
| 749 | # http://legacy.python.org/dev/peps/pep-3123/ |
| 750 | # We also depend on it in our code (even Python 3). |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 751 | '-fno-strict-aliasing', |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 752 | # Clang has an unfixed bug leading to spurious missing |
| 753 | # braces warnings, see |
| 754 | # https://bugs.llvm.org/show_bug.cgi?id=21629 |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 755 | '-Wno-missing-braces', |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 756 | ] |
| Johannes M Dieterich | a4c59a9 | 2018-08-23 15:20:02 -0700 | [diff] [blame] | 757 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 758 | library_dirs.append(lib_path) |
| Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 759 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 760 | main_compile_args = [] |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 761 | main_libraries = ['torch_python'] |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 762 | main_link_args = [] |
| Nikita Shulga | a864dbb | 2020-06-02 13:07:55 -0700 | [diff] [blame] | 763 | main_sources = ["torch/csrc/stub.c"] |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 764 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 765 | if cmake_cache_vars['USE_CUDA']: |
| 766 | library_dirs.append( |
| 767 | os.path.dirname(cmake_cache_vars['CUDA_CUDA_LIB'])) |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 768 | |
| Hong Xu | fd1d06e | 2019-07-24 08:02:43 -0700 | [diff] [blame] | 769 | if build_type.is_debug(): |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 770 | if IS_WINDOWS: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 771 | extra_compile_args.append('/Z7') |
| 772 | extra_link_args.append('/DEBUG:FULL') |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 773 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 774 | extra_compile_args += ['-O0', '-g'] |
| 775 | extra_link_args += ['-O0', '-g'] |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 776 | |
| Hong Xu | fd1d06e | 2019-07-24 08:02:43 -0700 | [diff] [blame] | 777 | if build_type.is_rel_with_deb_info(): |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 778 | if IS_WINDOWS: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 779 | extra_compile_args.append('/Z7') |
| 780 | extra_link_args.append('/DEBUG:FULL') |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 781 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 782 | extra_compile_args += ['-g'] |
| 783 | extra_link_args += ['-g'] |
| Zachary DeVito | 788d2e8 | 2018-11-21 06:36:26 -0800 | [diff] [blame] | 784 | |
| Nikita Shulga | e8e570e | 2021-03-16 00:21:55 -0700 | [diff] [blame] | 785 | # Cross-compile for M1 |
| 786 | if IS_DARWIN: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 787 | macos_target_arch = os.getenv('CMAKE_OSX_ARCHITECTURES', '') |
| 788 | if macos_target_arch in ['arm64', 'x86_64']: |
| 789 | macos_sysroot_path = os.getenv('CMAKE_OSX_SYSROOT') |
| Nikita Shulga | e8e570e | 2021-03-16 00:21:55 -0700 | [diff] [blame] | 790 | if macos_sysroot_path is None: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 791 | macos_sysroot_path = subprocess.check_output([ |
| 792 | 'xcrun', '--show-sdk-path', '--sdk', 'macosx' |
| 793 | ]).decode('utf-8').strip() |
| 794 | extra_compile_args += ['-arch', macos_target_arch, '-isysroot', macos_sysroot_path] |
| 795 | extra_link_args += ['-arch', macos_target_arch] |
| 796 | |
| Adam Paszke | 8d933cb | 2016-08-22 22:45:35 -0400 | [diff] [blame] | 797 | |
| peter | a08e8dd | 2020-11-09 11:36:56 -0800 | [diff] [blame] | 798 | def make_relative_rpath_args(path): |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 799 | if IS_DARWIN: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 800 | return ['-Wl,-rpath,@loader_path/' + path] |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 801 | elif IS_WINDOWS: |
| peter | a08e8dd | 2020-11-09 11:36:56 -0800 | [diff] [blame] | 802 | return [] |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 803 | else: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 804 | return ['-Wl,-rpath,$ORIGIN/' + path] |
| Adam Paszke | 8d933cb | 2016-08-22 22:45:35 -0400 | [diff] [blame] | 805 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 806 | ################################################################################ |
| 807 | # Declare extensions and package |
| 808 | ################################################################################ |
| Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 809 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 810 | extensions = [] |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 811 | packages = find_packages(exclude=('tools', 'tools.*')) |
| 812 | C = Extension("torch._C", |
| 813 | libraries=main_libraries, |
| 814 | sources=main_sources, |
| 815 | language='c', |
| 816 | extra_compile_args=main_compile_args + extra_compile_args, |
| 817 | include_dirs=[], |
| 818 | library_dirs=library_dirs, |
| 819 | extra_link_args=extra_link_args + main_link_args + make_relative_rpath_args('lib')) |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 820 | extensions.append(C) |
| Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 821 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 822 | if not IS_WINDOWS: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 823 | DL = Extension("torch._dl", |
| 824 | sources=["torch/csrc/dl.c"], |
| 825 | language='c') |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 826 | extensions.append(DL) |
| Soumith Chintala | 1cf87e8 | 2016-09-25 18:56:41 -0400 | [diff] [blame] | 827 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 828 | # These extensions are built by cmake and copied manually in build_extensions() |
| Nikita Shulga | a864dbb | 2020-06-02 13:07:55 -0700 | [diff] [blame] | 829 | # inside the build_ext implementation |
| Nikita Shulga | 77becca | 2021-10-21 20:31:01 -0700 | [diff] [blame] | 830 | if cmake_cache_vars['BUILD_CAFFE2']: |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 831 | extensions.append( |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 832 | Extension( |
| Nikita Shulga | 77becca | 2021-10-21 20:31:01 -0700 | [diff] [blame] | 833 | name=str('caffe2.python.caffe2_pybind11_state'), |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 834 | sources=[]), |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 835 | ) |
| Nikita Shulga | 77becca | 2021-10-21 20:31:01 -0700 | [diff] [blame] | 836 | if cmake_cache_vars['USE_CUDA']: |
| 837 | extensions.append( |
| 838 | Extension( |
| 839 | name=str('caffe2.python.caffe2_pybind11_state_gpu'), |
| 840 | sources=[]), |
| 841 | ) |
| 842 | if cmake_cache_vars['USE_ROCM']: |
| 843 | extensions.append( |
| 844 | Extension( |
| 845 | name=str('caffe2.python.caffe2_pybind11_state_hip'), |
| 846 | sources=[]), |
| 847 | ) |
| Adam Paszke | 1bdc281 | 2017-02-15 11:48:08 -0800 | [diff] [blame] | 848 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 849 | cmdclass = { |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 850 | 'bdist_wheel': wheel_concatenate, |
| 851 | 'build_ext': build_ext, |
| 852 | 'clean': clean, |
| 853 | 'install': install, |
| 854 | 'sdist': sdist, |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 855 | } |
| soumith | e4812b3 | 2017-01-17 14:13:44 -0800 | [diff] [blame] | 856 | |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 857 | entry_points = { |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 858 | 'console_scripts': [ |
| 859 | 'convert-caffe2-to-onnx = caffe2.python.onnx.bin.conversion:caffe2_to_onnx', |
| 860 | 'convert-onnx-to-caffe2 = caffe2.python.onnx.bin.conversion:onnx_to_caffe2', |
| Can Balioglu | 65e6194 | 2021-08-26 20:16:10 -0700 | [diff] [blame] | 861 | 'torchrun = torch.distributed.run:main', |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 862 | ] |
| 863 | } |
| 864 | |
| Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 865 | return extensions, cmdclass, packages, entry_points, extra_install_requires |
| Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 866 | |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 867 | # post run, warnings, printed at the end to make them more visible |
| 868 | build_update_message = """ |
| 869 | It is no longer necessary to use the 'build' or 'rebuild' targets |
| 870 | |
| 871 | To install: |
| 872 | $ python setup.py install |
| 873 | To develop locally: |
| 874 | $ python setup.py develop |
| Hong Xu | 646a7f9 | 2019-06-11 07:00:51 -0700 | [diff] [blame] | 875 | To force cmake to re-generate native build files (off by default): |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 876 | $ python setup.py develop --cmake |
| 877 | """ |
| 878 | |
| 879 | |
| 880 | def print_box(msg): |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 881 | lines = msg.split('\n') |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 882 | size = max(len(l) + 1 for l in lines) |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 883 | print('-' * (size + 2)) |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 884 | for l in lines: |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 885 | print('|{}{}|'.format(l, ' ' * (size - len(l)))) |
| 886 | print('-' * (size + 2)) |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 887 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 888 | if __name__ == '__main__': |
| Simeon Monov | bad4442 | 2019-02-12 00:12:03 -0800 | [diff] [blame] | 889 | # Parse the command line and check the arguments |
| 890 | # before we proceed with building deps and setup |
| 891 | dist = Distribution() |
| Simeon Monov | bad4442 | 2019-02-12 00:12:03 -0800 | [diff] [blame] | 892 | try: |
| davidriazati@fb.com | 4b96fc0 | 2021-04-29 12:09:02 -0700 | [diff] [blame] | 893 | dist.parse_command_line() |
| 894 | except setuptools.distutils.errors.DistutilsArgError as e: |
| 895 | print(e) |
| 896 | sys.exit(1) |
| Simeon Monov | bad4442 | 2019-02-12 00:12:03 -0800 | [diff] [blame] | 897 | |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 898 | if RUN_BUILD_DEPS: |
| 899 | build_deps() |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 900 | |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 901 | extensions, cmdclass, packages, entry_points, extra_install_requires = configure_extension_build() |
| Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 902 | |
| 903 | install_requires += extra_install_requires |
| Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 904 | |
| Eli Uriegas | b7b7433 | 2020-06-08 16:11:11 -0700 | [diff] [blame] | 905 | # Read in README.md for our long_description |
| 906 | with open(os.path.join(cwd, "README.md"), encoding="utf-8") as f: |
| 907 | long_description = f.read() |
| 908 | |
| Nikita Shulga | 14a2501 | 2021-03-26 12:39:40 -0700 | [diff] [blame] | 909 | version_range_max = max(sys.version_info[1], 9) + 1 |
| Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 910 | setup( |
| Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 911 | name=package_name, |
| Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 912 | version=version, |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 913 | description=("Tensors and Dynamic neural networks in " |
| 914 | "Python with strong GPU acceleration"), |
| Eli Uriegas | b7b7433 | 2020-06-08 16:11:11 -0700 | [diff] [blame] | 915 | long_description=long_description, |
| 916 | long_description_content_type="text/markdown", |
| Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 917 | ext_modules=extensions, |
| 918 | cmdclass=cmdclass, |
| 919 | packages=packages, |
| Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 920 | entry_points=entry_points, |
| Soumith Chintala | 6313d5e | 2019-08-04 17:17:33 -0700 | [diff] [blame] | 921 | install_requires=install_requires, |
| Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 922 | package_data={ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 923 | 'torch': [ |
| 924 | 'py.typed', |
| 925 | 'bin/*', |
| 926 | 'test/*', |
| 927 | '_C/*.pyi', |
| 928 | 'cuda/*.pyi', |
| 929 | 'optim/*.pyi', |
| 930 | 'autograd/*.pyi', |
| 931 | 'utils/data/*.pyi', |
| 932 | 'nn/*.pyi', |
| 933 | 'nn/modules/*.pyi', |
| 934 | 'nn/parallel/*.pyi', |
| 935 | 'lib/*.so*', |
| 936 | 'lib/*.dylib*', |
| 937 | 'lib/*.dll', |
| 938 | 'lib/*.lib', |
| 939 | 'lib/*.pdb', |
| 940 | 'lib/torch_shm_manager', |
| 941 | 'lib/*.h', |
| 942 | 'include/ATen/*.h', |
| 943 | 'include/ATen/cpu/*.h', |
| 944 | 'include/ATen/cpu/vec/vec256/*.h', |
| 945 | 'include/ATen/cpu/vec/vec512/*.h', |
| 946 | 'include/ATen/cpu/vec/*.h', |
| 947 | 'include/ATen/core/*.h', |
| 948 | 'include/ATen/cuda/*.cuh', |
| 949 | 'include/ATen/cuda/*.h', |
| 950 | 'include/ATen/cuda/detail/*.cuh', |
| 951 | 'include/ATen/cuda/detail/*.h', |
| 952 | 'include/ATen/cudnn/*.h', |
| Peter Bell | 4829dce | 2021-12-14 06:38:39 -0800 | [diff] [blame] | 953 | 'include/ATen/ops/*.h', |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 954 | 'include/ATen/hip/*.cuh', |
| 955 | 'include/ATen/hip/*.h', |
| 956 | 'include/ATen/hip/detail/*.cuh', |
| 957 | 'include/ATen/hip/detail/*.h', |
| 958 | 'include/ATen/hip/impl/*.h', |
| 959 | 'include/ATen/detail/*.h', |
| 960 | 'include/ATen/native/*.h', |
| 961 | 'include/ATen/native/cpu/*.h', |
| 962 | 'include/ATen/native/cuda/*.h', |
| 963 | 'include/ATen/native/cuda/*.cuh', |
| 964 | 'include/ATen/native/hip/*.h', |
| 965 | 'include/ATen/native/hip/*.cuh', |
| 966 | 'include/ATen/native/quantized/*.h', |
| 967 | 'include/ATen/native/quantized/cpu/*.h', |
| 968 | 'include/ATen/quantized/*.h', |
| 969 | 'include/caffe2/utils/*.h', |
| 970 | 'include/caffe2/utils/**/*.h', |
| 971 | 'include/c10/*.h', |
| 972 | 'include/c10/macros/*.h', |
| 973 | 'include/c10/core/*.h', |
| 974 | 'include/ATen/core/boxing/*.h', |
| 975 | 'include/ATen/core/boxing/impl/*.h', |
| 976 | 'include/ATen/core/dispatch/*.h', |
| 977 | 'include/ATen/core/op_registration/*.h', |
| 978 | 'include/c10/core/impl/*.h', |
| 979 | 'include/c10/util/*.h', |
| 980 | 'include/c10/cuda/*.h', |
| 981 | 'include/c10/cuda/impl/*.h', |
| 982 | 'include/c10/hip/*.h', |
| 983 | 'include/c10/hip/impl/*.h', |
| 984 | 'include/c10d/*.hpp', |
| 985 | 'include/caffe2/**/*.h', |
| 986 | 'include/torch/*.h', |
| 987 | 'include/torch/csrc/*.h', |
| 988 | 'include/torch/csrc/api/include/torch/*.h', |
| 989 | 'include/torch/csrc/api/include/torch/data/*.h', |
| 990 | 'include/torch/csrc/api/include/torch/data/dataloader/*.h', |
| 991 | 'include/torch/csrc/api/include/torch/data/datasets/*.h', |
| 992 | 'include/torch/csrc/api/include/torch/data/detail/*.h', |
| 993 | 'include/torch/csrc/api/include/torch/data/samplers/*.h', |
| 994 | 'include/torch/csrc/api/include/torch/data/transforms/*.h', |
| 995 | 'include/torch/csrc/api/include/torch/detail/*.h', |
| 996 | 'include/torch/csrc/api/include/torch/detail/ordered_dict.h', |
| 997 | 'include/torch/csrc/api/include/torch/nn/*.h', |
| 998 | 'include/torch/csrc/api/include/torch/nn/functional/*.h', |
| 999 | 'include/torch/csrc/api/include/torch/nn/options/*.h', |
| 1000 | 'include/torch/csrc/api/include/torch/nn/modules/*.h', |
| 1001 | 'include/torch/csrc/api/include/torch/nn/modules/container/*.h', |
| 1002 | 'include/torch/csrc/api/include/torch/nn/parallel/*.h', |
| 1003 | 'include/torch/csrc/api/include/torch/nn/utils/*.h', |
| 1004 | 'include/torch/csrc/api/include/torch/optim/*.h', |
| 1005 | 'include/torch/csrc/api/include/torch/optim/schedulers/*.h', |
| 1006 | 'include/torch/csrc/api/include/torch/serialize/*.h', |
| 1007 | 'include/torch/csrc/autograd/*.h', |
| 1008 | 'include/torch/csrc/autograd/functions/*.h', |
| 1009 | 'include/torch/csrc/autograd/generated/*.h', |
| 1010 | 'include/torch/csrc/autograd/utils/*.h', |
| 1011 | 'include/torch/csrc/cuda/*.h', |
| Michael Suo | ad18247 | 2021-12-01 21:53:29 -0800 | [diff] [blame] | 1012 | 'include/torch/csrc/deploy/*.h', |
| 1013 | 'include/torch/csrc/deploy/interpreter/interpreter_impl.h', |
| Can Balioglu | 6e640a0 | 2021-11-16 20:47:57 -0800 | [diff] [blame] | 1014 | 'include/torch/csrc/distributed/c10d/exception.h', |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1015 | 'include/torch/csrc/jit/*.h', |
| 1016 | 'include/torch/csrc/jit/backends/*.h', |
| 1017 | 'include/torch/csrc/jit/generated/*.h', |
| 1018 | 'include/torch/csrc/jit/passes/*.h', |
| 1019 | 'include/torch/csrc/jit/passes/quantization/*.h', |
| 1020 | 'include/torch/csrc/jit/passes/utils/*.h', |
| 1021 | 'include/torch/csrc/jit/runtime/*.h', |
| 1022 | 'include/torch/csrc/jit/ir/*.h', |
| 1023 | 'include/torch/csrc/jit/frontend/*.h', |
| 1024 | 'include/torch/csrc/jit/api/*.h', |
| 1025 | 'include/torch/csrc/jit/serialization/*.h', |
| 1026 | 'include/torch/csrc/jit/python/*.h', |
| 1027 | 'include/torch/csrc/jit/testing/*.h', |
| 1028 | 'include/torch/csrc/jit/tensorexpr/*.h', |
| 1029 | 'include/torch/csrc/jit/tensorexpr/operators/*.h', |
| 1030 | 'include/torch/csrc/onnx/*.h', |
| Taylor Robie | ebc66bf | 2021-12-16 10:32:13 -0800 | [diff] [blame] | 1031 | 'include/torch/csrc/profiler/*.h', |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1032 | 'include/torch/csrc/utils/*.h', |
| 1033 | 'include/torch/csrc/tensor/*.h', |
| Eli Uriegas | f398320 | 2021-11-29 08:26:00 -0800 | [diff] [blame] | 1034 | 'include/torch/csrc/lazy/core/*.h', |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1035 | 'include/pybind11/*.h', |
| 1036 | 'include/pybind11/detail/*.h', |
| 1037 | 'include/TH/*.h*', |
| 1038 | 'include/TH/generic/*.h*', |
| 1039 | 'include/THC/*.cuh', |
| 1040 | 'include/THC/*.h*', |
| 1041 | 'include/THC/generic/*.h', |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1042 | 'include/THH/*.cuh', |
| 1043 | 'include/THH/*.h*', |
| 1044 | 'include/THH/generic/*.h', |
| 1045 | 'share/cmake/ATen/*.cmake', |
| 1046 | 'share/cmake/Caffe2/*.cmake', |
| 1047 | 'share/cmake/Caffe2/public/*.cmake', |
| 1048 | 'share/cmake/Caffe2/Modules_CUDA_fix/*.cmake', |
| 1049 | 'share/cmake/Caffe2/Modules_CUDA_fix/upstream/*.cmake', |
| 1050 | 'share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/*.cmake', |
| 1051 | 'share/cmake/Gloo/*.cmake', |
| 1052 | 'share/cmake/Tensorpipe/*.cmake', |
| 1053 | 'share/cmake/Torch/*.cmake', |
| 1054 | 'utils/benchmark/utils/*.cpp', |
| 1055 | 'utils/benchmark/utils/valgrind_wrapper/*.cpp', |
| 1056 | 'utils/benchmark/utils/valgrind_wrapper/*.h', |
| 1057 | 'utils/model_dump/skeleton.html', |
| 1058 | 'utils/model_dump/code.js', |
| 1059 | 'utils/model_dump/*.mjs', |
| Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 1060 | ], |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1061 | 'caffe2': [ |
| 1062 | 'python/serialized_test/data/operator_test/*.zip', |
| Pritam Damania | f050b16 | 2020-01-22 21:05:28 -0800 | [diff] [blame] | 1063 | ], |
| Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 1064 | }, |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1065 | url='https://pytorch.org/', |
| 1066 | download_url='https://github.com/pytorch/pytorch/tags', |
| 1067 | author='PyTorch Team', |
| 1068 | author_email='packages@pytorch.org', |
| 1069 | python_requires='>={}'.format(python_min_version_str), |
| Soumith Chintala | dded794 | 2019-08-01 11:54:40 -0700 | [diff] [blame] | 1070 | # PyPI package information. |
| 1071 | classifiers=[ |
| Shen Li | 1022443 | 2021-08-12 11:39:31 -0700 | [diff] [blame] | 1072 | 'Development Status :: 5 - Production/Stable', |
| 1073 | 'Intended Audience :: Developers', |
| 1074 | 'Intended Audience :: Education', |
| 1075 | 'Intended Audience :: Science/Research', |
| 1076 | 'License :: OSI Approved :: BSD License', |
| 1077 | 'Topic :: Scientific/Engineering', |
| 1078 | 'Topic :: Scientific/Engineering :: Mathematics', |
| 1079 | 'Topic :: Scientific/Engineering :: Artificial Intelligence', |
| 1080 | 'Topic :: Software Development', |
| 1081 | 'Topic :: Software Development :: Libraries', |
| 1082 | 'Topic :: Software Development :: Libraries :: Python Modules', |
| 1083 | 'Programming Language :: C++', |
| 1084 | 'Programming Language :: Python :: 3', |
| 1085 | ] + ['Programming Language :: Python :: 3.{}'.format(i) for i in range(python_min_version[1], version_range_max)], |
| 1086 | license='BSD-3', |
| 1087 | keywords='pytorch machine learning', |
| Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 1088 | ) |
| Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 1089 | if EMIT_BUILD_WARNING: |
| 1090 | print_box(build_update_message) |