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 |
| 24 | # the C/C++ compiler to use (NB: the CXX flag has no effect for distutils |
| 25 | # compiles, because distutils always uses CC to compile, even for C++ |
| 26 | # files. |
| 27 | # |
| 28 | # Environment variables for feature toggles: |
| 29 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 30 | # USE_CUDNN=0 |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 31 | # disables the cuDNN build |
| 32 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 33 | # USE_FBGEMM=0 |
Daya S Khudia | 18de330 | 2018-11-06 15:37:30 -0800 | [diff] [blame] | 34 | # disables the FBGEMM build |
| 35 | # |
Hong Xu | 240d62f | 2019-06-06 08:11:17 -0700 | [diff] [blame] | 36 | # USE_NUMPY=0 |
| 37 | # disables the NumPy build |
| 38 | # |
Vishwak Srinivasan | 9e69703 | 2019-02-22 17:03:49 -0800 | [diff] [blame] | 39 | # BUILD_TEST=0 |
Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 40 | # disables the test build |
| 41 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 42 | # USE_MKLDNN=0 |
Gu, Jinghui | d01cb70 | 2018-11-08 11:16:33 -0800 | [diff] [blame] | 43 | # disables use of MKLDNN |
| 44 | # |
pinzhenx | bd604cb | 2020-03-26 22:01:21 -0700 | [diff] [blame] | 45 | # MKLDNN_CPU_RUNTIME |
Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 46 | # MKL-DNN threading mode: TBB or OMP (default) |
Ilia Cherniavskii | 481b6d0 | 2019-05-06 19:25:55 -0700 | [diff] [blame] | 47 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 48 | # USE_NNPACK=0 |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 49 | # disables NNPACK build |
| 50 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 51 | # USE_QNNPACK=0 |
Marat Dukhan | 5e73b82 | 2018-10-25 22:13:18 -0700 | [diff] [blame] | 52 | # disables QNNPACK build (quantized 8-bit operators) |
| 53 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 54 | # USE_DISTRIBUTED=0 |
Orion Reblitz-Richardson | dda8402 | 2018-09-06 08:40:57 -0700 | [diff] [blame] | 55 | # disables distributed (c10d, gloo, mpi, etc.) build |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 56 | # |
Soumith Chintala | 3069c45 | 2019-02-21 09:53:24 -0800 | [diff] [blame] | 57 | # USE_SYSTEM_NCCL=0 |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 58 | # disables use of system-wide nccl (we will use our submoduled |
Edward Z. Yang | eb18a2f | 2018-03-27 22:09:20 -0400 | [diff] [blame] | 59 | # copy in third_party/nccl) |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 60 | # |
Vishwak Srinivasan | 9e69703 | 2019-02-22 17:03:49 -0800 | [diff] [blame] | 61 | # BUILD_CAFFE2_OPS=0 |
Orion Reblitz-Richardson | a175282 | 2018-09-10 17:11:16 -0700 | [diff] [blame] | 62 | # disable Caffe2 operators build |
| 63 | # |
Hong Xu | 8a026d4 | 2019-09-10 04:31:31 -0700 | [diff] [blame] | 64 | # USE_IBVERBS |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 65 | # toggle features related to distributed support |
| 66 | # |
Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 67 | # USE_OPENCV |
| 68 | # enables use of OpenCV for additional operators |
| 69 | # |
Ilia Cherniavskii | 481b6d0 | 2019-05-06 19:25:55 -0700 | [diff] [blame] | 70 | # USE_OPENMP=0 |
| 71 | # disables use of OpenMP for parallelization |
| 72 | # |
Orion Reblitz-Richardson | 25bd7fe | 2018-10-10 18:07:58 -0700 | [diff] [blame] | 73 | # USE_FFMPEG |
| 74 | # enables use of ffmpeg for additional operators |
| 75 | # |
Orion Reblitz-Richardson | a175282 | 2018-09-10 17:11:16 -0700 | [diff] [blame] | 76 | # USE_LEVELDB |
| 77 | # enables use of LevelDB for storage |
| 78 | # |
daquexian | 1fb8925 | 2018-10-03 06:03:02 -0700 | [diff] [blame] | 79 | # USE_LMDB |
Orion Reblitz-Richardson | a175282 | 2018-09-10 17:11:16 -0700 | [diff] [blame] | 80 | # enables use of LMDB for storage |
| 81 | # |
Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 82 | # BUILD_BINARY |
| 83 | # enables the additional binaries/ build |
| 84 | # |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 85 | # PYTORCH_BUILD_VERSION |
| 86 | # PYTORCH_BUILD_NUMBER |
| 87 | # specify the version of PyTorch, rather than the hard-coded version |
| 88 | # in this file; used when we're building binaries for distribution |
| 89 | # |
Richard Zou | 7355f5c | 2018-04-02 13:35:14 -0400 | [diff] [blame] | 90 | # TORCH_CUDA_ARCH_LIST |
| 91 | # specify which CUDA architectures to build for. |
| 92 | # ie `TORCH_CUDA_ARCH_LIST="6.0;7.0"` |
Edward Yang | cd94163 | 2018-08-29 13:29:34 -0700 | [diff] [blame] | 93 | # These are not CUDA versions, instead, they specify what |
| 94 | # classes of NVIDIA hardware we should generate PTX for. |
Richard Zou | 7355f5c | 2018-04-02 13:35:14 -0400 | [diff] [blame] | 95 | # |
Orion Reblitz-Richardson | edd4e2c | 2018-06-13 10:25:32 -0700 | [diff] [blame] | 96 | # ONNX_NAMESPACE |
| 97 | # specify a namespace for ONNX built here rather than the hard-coded |
| 98 | # one in this file; needed to build with other frameworks that share ONNX. |
| 99 | # |
Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 100 | # BLAS |
| 101 | # BLAS to be used by Caffe2. Can be MKL, Eigen, ATLAS, or OpenBLAS. If set |
| 102 | # then the build will fail if the requested BLAS is not found, otherwise |
| 103 | # the BLAS will be chosen based on what is found on your system. |
| 104 | # |
Ilia Cherniavskii | 6350dbd | 2019-06-24 12:48:13 -0700 | [diff] [blame] | 105 | # MKL_THREADING |
Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 106 | # MKL threading mode: SEQ, TBB or OMP (default) |
Ilia Cherniavskii | 481b6d0 | 2019-05-06 19:25:55 -0700 | [diff] [blame] | 107 | # |
Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 108 | # USE_REDIS |
| 109 | # Whether to use Redis for distributed workflows (Linux only) |
| 110 | # |
| 111 | # USE_ZSTD |
| 112 | # Enables use of ZSTD, if the libraries are found |
| 113 | # |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 114 | # Environment variables we respect (these environment variables are |
| 115 | # conventional and are often understood/set by other software.) |
| 116 | # |
| 117 | # CUDA_HOME (Linux/OS X) |
| 118 | # CUDA_PATH (Windows) |
| 119 | # specify where CUDA is installed; usually /usr/local/cuda or |
| 120 | # /usr/local/cuda-x.y |
Sven-Hendrik Haase | 080266e | 2018-10-03 06:20:46 -0700 | [diff] [blame] | 121 | # CUDAHOSTCXX |
| 122 | # specify a different compiler than the system one to use as the CUDA |
| 123 | # host compiler for nvcc. |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 124 | # |
Jesse Hellemn | 8964a2e6 | 2019-01-14 15:10:49 -0800 | [diff] [blame] | 125 | # CUDA_NVCC_EXECUTABLE |
| 126 | # Specify a NVCC to use. This is used in our CI to point to a cached nvcc |
| 127 | # |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 128 | # CUDNN_LIB_DIR |
| 129 | # CUDNN_INCLUDE_DIR |
| 130 | # CUDNN_LIBRARY |
| 131 | # specify where cuDNN is installed |
| 132 | # |
Johannes M Dieterich | a4c59a9 | 2018-08-23 15:20:02 -0700 | [diff] [blame] | 133 | # MIOPEN_LIB_DIR |
| 134 | # MIOPEN_INCLUDE_DIR |
| 135 | # MIOPEN_LIBRARY |
| 136 | # specify where MIOpen is installed |
| 137 | # |
Hong Xu | 60c46dd | 2019-07-23 08:35:59 -0700 | [diff] [blame] | 138 | # NCCL_ROOT |
Edward Z. Yang | 031412a | 2018-02-20 16:55:57 -0500 | [diff] [blame] | 139 | # NCCL_LIB_DIR |
| 140 | # NCCL_INCLUDE_DIR |
| 141 | # specify where nccl is installed |
| 142 | # |
| 143 | # NVTOOLSEXT_PATH (Windows only) |
| 144 | # specify where nvtoolsext is installed |
| 145 | # |
| 146 | # LIBRARY_PATH |
| 147 | # LD_LIBRARY_PATH |
| 148 | # we will search for libraries in these paths |
Ilia Cherniavskii | c3d05e8 | 2019-05-24 01:59:00 -0700 | [diff] [blame] | 149 | # |
Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 150 | # ATEN_THREADING |
| 151 | # ATen parallel backend to use for intra- and inter-op parallelism |
Ilia Cherniavskii | c3d05e8 | 2019-05-24 01:59:00 -0700 | [diff] [blame] | 152 | # possible values: |
Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 153 | # 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] | 154 | # NATIVE - use native thread pool for both intra- and inter-op tasks |
Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 155 | # 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] | 156 | # |
| 157 | # USE_TBB |
Ilia Cherniavskii | 74f8094 | 2019-07-26 13:05:54 -0700 | [diff] [blame] | 158 | # enable TBB support |
Ilia Cherniavskii | 580eab6 | 2019-05-28 02:43:22 -0700 | [diff] [blame] | 159 | # |
Mo Zhou | ff21b15 | 2020-04-23 20:40:16 -0700 | [diff] [blame] | 160 | # USE_SYSTEM_LIBS (work in progress) |
| 161 | # Use system-provided libraries to satisfy the build dependencies. |
| 162 | # When turned on, the following cmake variables will be toggled as well: |
| 163 | # 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] | 164 | |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 165 | from __future__ import print_function |
David Reiss | 3c85f44 | 2020-04-16 10:18:08 -0700 | [diff] [blame] | 166 | |
| 167 | import sys |
| 168 | if sys.version_info < (3,): |
| 169 | raise Exception("Python 2 has reached end-of-life and is no longer supported by PyTorch.") |
| 170 | |
Edward Yang | 173f224 | 2019-03-30 08:58:10 -0700 | [diff] [blame] | 171 | from setuptools import setup, Extension, distutils, find_packages |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 172 | from collections import defaultdict |
Junjie Bai | b0c245d | 2019-11-12 14:48:37 -0800 | [diff] [blame] | 173 | from distutils import core |
Simeon Monov | bad4442 | 2019-02-12 00:12:03 -0800 | [diff] [blame] | 174 | from distutils.core import Distribution |
| 175 | from distutils.errors import DistutilsArgError |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 176 | import setuptools.command.build_ext |
Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 177 | import setuptools.command.install |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 178 | import distutils.command.clean |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 179 | import distutils.sysconfig |
Soumith Chintala | acb6f18 | 2018-09-13 12:26:58 -0700 | [diff] [blame] | 180 | import filecmp |
Adam Paszke | 652a31b | 2016-08-04 10:42:19 -0700 | [diff] [blame] | 181 | import subprocess |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 182 | import shutil |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 183 | import os |
Zachary DeVito | 70ca837 | 2017-11-30 10:11:43 -0500 | [diff] [blame] | 184 | import json |
| 185 | import glob |
Richard Zou | 03f2ad9 | 2018-03-09 23:49:18 -0500 | [diff] [blame] | 186 | import importlib |
Adam Paszke | 731041c | 2016-05-02 23:06:53 +0200 | [diff] [blame] | 187 | |
Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 188 | from tools.build_pytorch_libs import build_caffe2 |
Nikita Shulga | dd7cec6 | 2020-03-10 15:29:07 -0700 | [diff] [blame] | 189 | from tools.setup_helpers.env import (IS_WINDOWS, IS_DARWIN, IS_LINUX, |
Hong Xu | fd1d06e | 2019-07-24 08:02:43 -0700 | [diff] [blame] | 190 | check_env_flag, build_type) |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 191 | from tools.setup_helpers.cmake import CMake |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 192 | |
| 193 | try: |
| 194 | FileNotFoundError |
| 195 | except NameError: |
| 196 | FileNotFoundError = IOError # Python 2.7 does not have FileNotFoundError |
| 197 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 198 | ################################################################################ |
| 199 | # Parameters parsed from environment |
| 200 | ################################################################################ |
| 201 | |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 202 | VERBOSE_SCRIPT = True |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 203 | RUN_BUILD_DEPS = True |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 204 | # see if the user passed a quiet flag to setup.py arguments and respect |
| 205 | # that in our parts of the build |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 206 | EMIT_BUILD_WARNING = False |
Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 207 | RERUN_CMAKE = False |
Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 208 | CMAKE_ONLY = False |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 209 | filtered_args = [] |
| 210 | for i, arg in enumerate(sys.argv): |
| 211 | if arg == '--cmake': |
Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 212 | RERUN_CMAKE = True |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 213 | continue |
Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 214 | if arg == '--cmake-only': |
| 215 | # Stop once cmake terminates. Leave users a chance to adjust build |
| 216 | # options. |
| 217 | CMAKE_ONLY = True |
| 218 | continue |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 219 | if arg == 'rebuild' or arg == 'build': |
| 220 | arg = 'build' # rebuild is gone, make it build |
| 221 | EMIT_BUILD_WARNING = True |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 222 | if arg == "--": |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 223 | filtered_args += sys.argv[i:] |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 224 | break |
| 225 | if arg == '-q' or arg == '--quiet': |
| 226 | VERBOSE_SCRIPT = False |
peter | b9260bd | 2020-04-08 08:55:08 -0700 | [diff] [blame] | 227 | if arg == 'clean' or arg == 'egg_info': |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 228 | RUN_BUILD_DEPS = False |
| 229 | filtered_args.append(arg) |
| 230 | sys.argv = filtered_args |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 231 | |
| 232 | if VERBOSE_SCRIPT: |
| 233 | def report(*args): |
| 234 | print(*args) |
| 235 | else: |
| 236 | def report(*args): |
| 237 | pass |
| 238 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 239 | # Constant known variables used throughout this file |
| 240 | cwd = os.path.dirname(os.path.abspath(__file__)) |
| 241 | lib_path = os.path.join(cwd, "torch", "lib") |
| 242 | third_party_path = os.path.join(cwd, "third_party") |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 243 | caffe2_build_dir = os.path.join(cwd, "build") |
| 244 | # lib/pythonx.x/site-packages |
Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 245 | rel_site_packages = distutils.sysconfig.get_python_lib(prefix='') |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 246 | # full absolute path to the dir above |
Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 247 | full_site_packages = distutils.sysconfig.get_python_lib() |
Philip Yang | b57fdf1 | 2018-10-12 08:06:43 -0700 | [diff] [blame] | 248 | # CMAKE: full path to python library |
CircleCI | f1a2bc4 | 2018-11-12 14:35:39 -0800 | [diff] [blame] | 249 | if IS_WINDOWS: |
| 250 | cmake_python_library = "{}/libs/python{}.lib".format( |
| 251 | distutils.sysconfig.get_config_var("prefix"), |
| 252 | distutils.sysconfig.get_config_var("VERSION")) |
zrphercule | c564d79 | 2019-12-05 13:21:43 -0800 | [diff] [blame] | 253 | # Fix virtualenv builds |
peter | d05da7d | 2019-11-06 09:00:52 -0800 | [diff] [blame] | 254 | # TODO: Fix for python < 3.3 |
| 255 | if not os.path.exists(cmake_python_library): |
| 256 | cmake_python_library = "{}/libs/python{}.lib".format( |
| 257 | sys.base_prefix, |
| 258 | distutils.sysconfig.get_config_var("VERSION")) |
CircleCI | f1a2bc4 | 2018-11-12 14:35:39 -0800 | [diff] [blame] | 259 | else: |
| 260 | cmake_python_library = "{}/{}".format( |
| 261 | distutils.sysconfig.get_config_var("LIBDIR"), |
| 262 | distutils.sysconfig.get_config_var("INSTSONAME")) |
Philip Yang | b57fdf1 | 2018-10-12 08:06:43 -0700 | [diff] [blame] | 263 | cmake_python_include_dir = distutils.sysconfig.get_python_inc() |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 264 | |
Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 265 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 266 | ################################################################################ |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 267 | # Version, create_version_file, and package_name |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 268 | ################################################################################ |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 269 | package_name = os.getenv('TORCH_PACKAGE_NAME', 'torch') |
Pavel Belevich | 493c900 | 2019-10-03 12:05:33 -0700 | [diff] [blame] | 270 | version = open('version.txt', 'r').read().strip() |
Gao, Xiang | a40e0a7 | 2019-03-25 19:54:27 -0700 | [diff] [blame] | 271 | sha = 'Unknown' |
| 272 | |
| 273 | try: |
| 274 | sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip() |
| 275 | except Exception: |
| 276 | pass |
| 277 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 278 | if os.getenv('PYTORCH_BUILD_VERSION'): |
| 279 | assert os.getenv('PYTORCH_BUILD_NUMBER') is not None |
| 280 | build_number = int(os.getenv('PYTORCH_BUILD_NUMBER')) |
| 281 | version = os.getenv('PYTORCH_BUILD_VERSION') |
| 282 | if build_number > 1: |
| 283 | version += '.post' + str(build_number) |
Gao, Xiang | a40e0a7 | 2019-03-25 19:54:27 -0700 | [diff] [blame] | 284 | elif sha != 'Unknown': |
| 285 | version += '+' + sha[:7] |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 286 | report("Building wheel {}-{}".format(package_name, version)) |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 287 | |
Hong Xu | 82545ec | 2019-07-25 07:16:01 -0700 | [diff] [blame] | 288 | cmake = CMake() |
Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 289 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 290 | # all the work we need to do _before_ setup runs |
| 291 | def build_deps(): |
| 292 | report('-- Building version ' + version) |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 293 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 294 | def check_file(f): |
Mo Zhou | 5b9f7f7 | 2020-04-27 09:34:52 -0700 | [diff] [blame] | 295 | if bool(os.getenv("USE_SYSTEM_LIBS", False)): |
| 296 | return |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 297 | if not os.path.exists(f): |
| 298 | report("Could not find {}".format(f)) |
| 299 | report("Did you run 'git submodule update --init --recursive'?") |
| 300 | sys.exit(1) |
| 301 | |
| 302 | check_file(os.path.join(third_party_path, "gloo", "CMakeLists.txt")) |
| 303 | check_file(os.path.join(third_party_path, "pybind11", "CMakeLists.txt")) |
| 304 | check_file(os.path.join(third_party_path, 'cpuinfo', 'CMakeLists.txt')) |
Ilia Cherniavskii | 580eab6 | 2019-05-28 02:43:22 -0700 | [diff] [blame] | 305 | check_file(os.path.join(third_party_path, 'tbb', 'Makefile')) |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 306 | check_file(os.path.join(third_party_path, 'onnx', 'CMakeLists.txt')) |
Lu Fang | 9e08c99 | 2019-02-25 14:25:18 -0800 | [diff] [blame] | 307 | check_file(os.path.join(third_party_path, 'foxi', 'CMakeLists.txt')) |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 308 | check_file(os.path.join(third_party_path, 'QNNPACK', 'CMakeLists.txt')) |
| 309 | check_file(os.path.join(third_party_path, 'fbgemm', 'CMakeLists.txt')) |
Hong Xu | 1e8f129 | 2019-05-26 18:37:42 -0700 | [diff] [blame] | 310 | check_file(os.path.join(third_party_path, 'fbgemm', 'third_party', |
| 311 | 'asmjit', 'CMakeLists.txt')) |
| 312 | check_file(os.path.join(third_party_path, 'onnx', 'third_party', |
| 313 | 'benchmark', 'CMakeLists.txt')) |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 314 | |
| 315 | check_pydep('yaml', 'pyyaml') |
| 316 | check_pydep('typing', 'typing') |
| 317 | |
Zachary DeVito | 9477a5d | 2019-01-25 15:57:09 -0800 | [diff] [blame] | 318 | build_caffe2(version=version, |
| 319 | cmake_python_library=cmake_python_library, |
| 320 | build_python=True, |
| 321 | rerun_cmake=RERUN_CMAKE, |
Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 322 | cmake_only=CMAKE_ONLY, |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 323 | cmake=cmake) |
Hong Xu | 081069e | 2019-10-04 07:48:19 -0700 | [diff] [blame] | 324 | |
| 325 | version_path = os.path.join(cwd, 'torch', 'version.py') |
| 326 | with open(version_path, 'w') as f: |
| 327 | f.write("__version__ = '{}'\n".format(version)) |
| 328 | # NB: This is not 100% accurate, because you could have built the |
| 329 | # library code with DEBUG, but csrc without DEBUG (in which case |
| 330 | # this would claim to be a release build when it's not.) |
| 331 | f.write("debug = {}\n".format(repr(build_type.is_debug()))) |
| 332 | cmake_cache_vars = defaultdict(lambda: None, cmake.get_cmake_cache_variables()) |
| 333 | f.write("cuda = {}\n".format(repr(cmake_cache_vars['CUDA_VERSION']))) |
| 334 | f.write("git_version = {}\n".format(repr(sha))) |
Thomas Viehmann | 7889e1e | 2019-11-15 12:01:21 -0800 | [diff] [blame] | 335 | f.write("hip = {}\n".format(repr(cmake_cache_vars['HIP_VERSION']))) |
Hong Xu | 081069e | 2019-10-04 07:48:19 -0700 | [diff] [blame] | 336 | |
Hong Xu | 9a989ec | 2019-05-28 17:04:10 -0700 | [diff] [blame] | 337 | if CMAKE_ONLY: |
| 338 | report('Finished running cmake. Run "ccmake build" or ' |
| 339 | '"cmake-gui build" to adjust build options and ' |
| 340 | '"python setup.py install" to build.') |
| 341 | sys.exit() |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 342 | |
| 343 | # Use copies instead of symbolic files. |
| 344 | # Windows has very poor support for them. |
| 345 | sym_files = ['tools/shared/cwrap_common.py', 'tools/shared/_utils_internal.py'] |
| 346 | orig_files = ['aten/src/ATen/common_with_cwrap.py', 'torch/_utils_internal.py'] |
| 347 | for sym_file, orig_file in zip(sym_files, orig_files): |
| 348 | same = False |
| 349 | if os.path.exists(sym_file): |
| 350 | if filecmp.cmp(sym_file, orig_file): |
| 351 | same = True |
| 352 | else: |
| 353 | os.remove(sym_file) |
| 354 | if not same: |
| 355 | shutil.copyfile(orig_file, sym_file) |
| 356 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 357 | ################################################################################ |
| 358 | # Building dependent libraries |
Adam Paszke | 690d470 | 2016-05-03 15:11:32 +0200 | [diff] [blame] | 359 | ################################################################################ |
Adam Paszke | 842e1b6 | 2016-05-05 20:58:13 +0200 | [diff] [blame] | 360 | |
Soumith Chintala | 6313d5e | 2019-08-04 17:17:33 -0700 | [diff] [blame] | 361 | # the list of runtime dependencies required by this built package |
Nikita Shulga | d3f5045 | 2020-03-19 17:29:00 -0700 | [diff] [blame] | 362 | install_requires = ['future'] |
Soumith Chintala | 6313d5e | 2019-08-04 17:17:33 -0700 | [diff] [blame] | 363 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 364 | missing_pydep = ''' |
| 365 | Missing build dependency: Unable to `import {importname}`. |
| 366 | Please install it via `conda install {module}` or `pip install {module}` |
| 367 | '''.strip() |
Sam Gross | 966fdbd | 2017-08-23 07:16:06 -0400 | [diff] [blame] | 368 | |
Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 369 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 370 | def check_pydep(importname, module): |
| 371 | try: |
| 372 | importlib.import_module(importname) |
| 373 | except ImportError: |
| 374 | raise RuntimeError(missing_pydep.format(importname=importname, module=module)) |
Zachary DeVito | 0e54c3a98 | 2017-11-29 16:10:51 -0500 | [diff] [blame] | 375 | |
Soumith Chintala | 5e372c7 | 2018-06-06 12:53:58 -0400 | [diff] [blame] | 376 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 377 | class build_ext(setuptools.command.build_ext.build_ext): |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 378 | def run(self): |
Hong Xu | 0408697 | 2019-06-17 13:42:45 -0700 | [diff] [blame] | 379 | # Report build options. This is run after the build completes so # `CMakeCache.txt` exists and we can get an |
| 380 | # accurate report on what is used and what is not. |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 381 | cmake_cache_vars = defaultdict(lambda: False, cmake.get_cmake_cache_variables()) |
| 382 | if cmake_cache_vars['USE_NUMPY']: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 383 | report('-- Building with NumPy bindings') |
Adam Paszke | 08d346d | 2016-12-15 00:04:28 +0100 | [diff] [blame] | 384 | else: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 385 | report('-- NumPy not found') |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 386 | if cmake_cache_vars['USE_CUDNN']: |
Hong Xu | 5e5cbce | 2019-09-24 07:42:52 -0700 | [diff] [blame] | 387 | report('-- Detected cuDNN at ' + |
| 388 | cmake_cache_vars['CUDNN_LIBRARY'] + ', ' + cmake_cache_vars['CUDNN_INCLUDE_DIR']) |
Adam Paszke | 08d346d | 2016-12-15 00:04:28 +0100 | [diff] [blame] | 389 | else: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 390 | report('-- Not using cuDNN') |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 391 | if cmake_cache_vars['USE_CUDA']: |
Hong Xu | a5354ad | 2019-10-22 13:59:14 -0700 | [diff] [blame] | 392 | report('-- Detected CUDA at ' + cmake_cache_vars['CUDA_TOOLKIT_ROOT_DIR']) |
Adam Paszke | 08d346d | 2016-12-15 00:04:28 +0100 | [diff] [blame] | 393 | else: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 394 | report('-- Not using CUDA') |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 395 | if cmake_cache_vars['USE_MKLDNN']: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 396 | report('-- Using MKLDNN') |
Hui Wu | 07ef85e | 2019-07-02 12:22:20 -0700 | [diff] [blame] | 397 | if cmake_cache_vars['USE_MKLDNN_CBLAS']: |
| 398 | report('-- Using CBLAS in MKLDNN') |
| 399 | else: |
| 400 | report('-- Not using CBLAS in MKLDNN') |
Ma Mingfei | f8270c0 | 2018-03-30 06:25:07 +0800 | [diff] [blame] | 401 | else: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 402 | report('-- Not using MKLDNN') |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 403 | if cmake_cache_vars['USE_NCCL'] and cmake_cache_vars['USE_SYSTEM_NCCL']: |
Hong Xu | 60c46dd | 2019-07-23 08:35:59 -0700 | [diff] [blame] | 404 | report('-- Using system provided NCCL library at {}, {}'.format(cmake_cache_vars['NCCL_LIBRARIES'], |
| 405 | cmake_cache_vars['NCCL_INCLUDE_DIRS'])) |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 406 | elif cmake_cache_vars['USE_NCCL']: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 407 | report('-- Building NCCL library') |
Sam Gross | b9379cf | 2017-03-16 16:10:17 -0400 | [diff] [blame] | 408 | else: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 409 | report('-- Not using NCCL') |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 410 | if cmake_cache_vars['USE_DISTRIBUTED']: |
Pieter Noordhuis | 3556bea | 2019-09-05 07:08:12 -0700 | [diff] [blame] | 411 | if IS_WINDOWS: |
| 412 | report('-- Building without distributed package') |
Teng Li | 020501b | 2018-09-04 17:18:29 -0700 | [diff] [blame] | 413 | else: |
Pieter Noordhuis | 3556bea | 2019-09-05 07:08:12 -0700 | [diff] [blame] | 414 | report('-- Building with distributed package ') |
Adam Paszke | 714351f | 2017-06-07 06:36:20 -0400 | [diff] [blame] | 415 | else: |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 416 | report('-- Building without distributed package') |
peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 417 | |
Nikita Shulga | dd7cec6 | 2020-03-10 15:29:07 -0700 | [diff] [blame] | 418 | # Do not use clang to compile exensions if `-fstack-clash-protection` is defined |
| 419 | # in system CFLAGS |
| 420 | system_c_flags = distutils.sysconfig.get_config_var('CFLAGS') |
| 421 | if IS_LINUX and '-fstack-clash-protection' in system_c_flags and 'clang' in os.environ.get('CC', ''): |
| 422 | os.environ['CC'] = distutils.sysconfig.get_config_var('CC') |
| 423 | |
Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 424 | # It's an old-style class in Python 2.7... |
| 425 | setuptools.command.build_ext.build_ext.run(self) |
| 426 | |
peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 427 | # Copy the essential export library to compile C++ extensions. |
| 428 | if IS_WINDOWS: |
| 429 | build_temp = self.build_temp |
| 430 | |
| 431 | ext_filename = self.get_ext_filename('_C') |
| 432 | lib_filename = '.'.join(ext_filename.split('.')[:-1]) + '.lib' |
| 433 | |
| 434 | export_lib = os.path.join( |
| 435 | build_temp, 'torch', 'csrc', lib_filename).replace('\\', '/') |
| 436 | |
| 437 | build_lib = self.build_lib |
| 438 | |
| 439 | target_lib = os.path.join( |
| 440 | build_lib, 'torch', 'lib', '_C.lib').replace('\\', '/') |
| 441 | |
Shuichi KITAGUCHI | ddbfdc9 | 2019-04-01 07:24:27 -0700 | [diff] [blame] | 442 | # Create "torch/lib" directory if not exists. |
| 443 | # (It is not created yet in "develop" mode.) |
| 444 | target_dir = os.path.dirname(target_lib) |
| 445 | if not os.path.exists(target_dir): |
| 446 | os.makedirs(target_dir) |
| 447 | |
peterjc123 | 63af898 | 2018-04-03 01:53:25 +0800 | [diff] [blame] | 448 | self.copy_file(export_lib, target_lib) |
| 449 | |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 450 | def build_extensions(self): |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 451 | self.create_compile_commands() |
Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 452 | # The caffe2 extensions are created in |
andersj | 8a5ba57 | 2019-01-08 15:54:20 -0800 | [diff] [blame] | 453 | # tmp_install/lib/pythonM.m/site-packages/caffe2/python/ |
Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 454 | # and need to be copied to build/lib.linux.... , which will be a |
| 455 | # platform dependent build folder created by the "build" command of |
| 456 | # setuptools. Only the contents of this folder are installed in the |
| 457 | # "install" command by default. |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 458 | # We only make this copy for Caffe2's pybind extensions |
| 459 | caffe2_pybind_exts = [ |
| 460 | 'caffe2.python.caffe2_pybind11_state', |
| 461 | 'caffe2.python.caffe2_pybind11_state_gpu', |
| 462 | 'caffe2.python.caffe2_pybind11_state_hip', |
| 463 | ] |
| 464 | i = 0 |
| 465 | while i < len(self.extensions): |
| 466 | ext = self.extensions[i] |
| 467 | if ext.name not in caffe2_pybind_exts: |
| 468 | i += 1 |
| 469 | continue |
| 470 | fullname = self.get_ext_fullname(ext.name) |
| 471 | filename = self.get_ext_filename(fullname) |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 472 | report("\nCopying extension {}".format(ext.name)) |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 473 | |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 474 | src = os.path.join("torch", rel_site_packages, filename) |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 475 | if not os.path.exists(src): |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 476 | report("{} does not exist".format(src)) |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 477 | del self.extensions[i] |
| 478 | else: |
| 479 | dst = os.path.join(os.path.realpath(self.build_lib), filename) |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 480 | report("Copying {} from {} to {}".format(ext.name, src, dst)) |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 481 | dst_dir = os.path.dirname(dst) |
| 482 | if not os.path.exists(dst_dir): |
| 483 | os.makedirs(dst_dir) |
| 484 | self.copy_file(src, dst) |
| 485 | i += 1 |
Paul Jesse Hellemn | 8e6f7a1 | 2018-06-06 08:31:31 -0700 | [diff] [blame] | 486 | distutils.command.build_ext.build_ext.build_extensions(self) |
| 487 | |
Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 488 | def get_outputs(self): |
| 489 | outputs = distutils.command.build_ext.build_ext.get_outputs(self) |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 490 | outputs.append(os.path.join(self.build_lib, "caffe2")) |
Zachary DeVito | e747acb | 2018-12-09 22:45:18 -0800 | [diff] [blame] | 491 | report("setup.py::get_outputs returning {}".format(outputs)) |
Jesse Hellemn | 99ab082 | 2018-07-09 18:04:25 -0700 | [diff] [blame] | 492 | return outputs |
| 493 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 494 | def create_compile_commands(self): |
| 495 | def load(filename): |
| 496 | with open(filename) as f: |
| 497 | return json.load(f) |
| 498 | ninja_files = glob.glob('build/*compile_commands.json') |
| 499 | cmake_files = glob.glob('torch/lib/build/*/compile_commands.json') |
| 500 | all_commands = [entry |
| 501 | for f in ninja_files + cmake_files |
| 502 | for entry in load(f)] |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 503 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 504 | # cquery does not like c++ compiles that start with gcc. |
| 505 | # It forgets to include the c++ header directories. |
| 506 | # We can work around this by replacing the gcc calls that python |
| 507 | # setup.py generates with g++ calls instead |
| 508 | for command in all_commands: |
| 509 | if command['command'].startswith("gcc "): |
| 510 | command['command'] = "g++ " + command['command'][4:] |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 511 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 512 | new_contents = json.dumps(all_commands, indent=2) |
| 513 | contents = '' |
| 514 | if os.path.exists('compile_commands.json'): |
| 515 | with open('compile_commands.json', 'r') as f: |
| 516 | contents = f.read() |
| 517 | if contents != new_contents: |
| 518 | with open('compile_commands.json', 'w') as f: |
| 519 | f.write(new_contents) |
Soumith Chintala | 4e8d9a4 | 2018-09-11 08:51:19 -0700 | [diff] [blame] | 520 | |
| 521 | |
Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 522 | class install(setuptools.command.install.install): |
| 523 | def run(self): |
Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 524 | setuptools.command.install.install.run(self) |
| 525 | |
| 526 | |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 527 | class clean(distutils.command.clean.clean): |
| 528 | def run(self): |
Soumith Chintala | 140c65e | 2016-10-21 23:16:39 -0400 | [diff] [blame] | 529 | import glob |
Shuichi KITAGUCHI | df23bdc | 2018-08-05 15:47:02 -0700 | [diff] [blame] | 530 | import re |
Adam Paszke | 207d6ae | 2016-08-14 20:47:27 -0700 | [diff] [blame] | 531 | with open('.gitignore', 'r') as f: |
| 532 | ignores = f.read() |
Shuichi KITAGUCHI | df23bdc | 2018-08-05 15:47:02 -0700 | [diff] [blame] | 533 | pat = re.compile(r'^#( BEGIN NOT-CLEAN-FILES )?') |
| 534 | for wildcard in filter(None, ignores.split('\n')): |
| 535 | match = pat.match(wildcard) |
| 536 | if match: |
| 537 | if match.group(1): |
| 538 | # Marker is found and stop reading .gitignore. |
| 539 | break |
| 540 | # Ignore lines which begin with '#'. |
| 541 | else: |
| 542 | for filename in glob.glob(wildcard): |
| 543 | try: |
| 544 | os.remove(filename) |
| 545 | except OSError: |
| 546 | shutil.rmtree(filename, ignore_errors=True) |
Sam Gross | f2d7e94 | 2016-10-26 09:51:52 -0700 | [diff] [blame] | 547 | |
Adam Paszke | b06c000 | 2016-08-16 21:02:46 -0700 | [diff] [blame] | 548 | # It's an old-style class in Python 2.7... |
| 549 | distutils.command.clean.clean.run(self) |
| 550 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 551 | def configure_extension_build(): |
| 552 | 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] | 553 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 554 | Returns: |
| 555 | The input to parameters ext_modules, cmdclass, packages, and entry_points as required in setuptools.setup. |
| 556 | """ |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 557 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 558 | try: |
| 559 | cmake_cache_vars = defaultdict(lambda: False, cmake.get_cmake_cache_variables()) |
| 560 | except FileNotFoundError: |
| 561 | # CMakeCache.txt does not exist. Probably running "python setup.py clean" over a clean directory. |
| 562 | cmake_cache_vars = defaultdict(lambda: False) |
peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 563 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 564 | ################################################################################ |
| 565 | # Configure compile flags |
| 566 | ################################################################################ |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 567 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 568 | library_dirs = [] |
Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 569 | extra_install_requires = [] |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 570 | |
peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 571 | if IS_WINDOWS: |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 572 | # /NODEFAULTLIB makes sure we only link to DLL runtime |
| 573 | # and matches the flags set for protobuf and ONNX |
| 574 | extra_link_args = ['/NODEFAULTLIB:LIBCMT.LIB'] |
| 575 | # /MD links against DLL runtime |
| 576 | # and matches the flags set for protobuf and ONNX |
| 577 | # /Z7 turns on symbolic debugging information in .obj files |
peter | c5d6f59 | 2020-04-28 08:16:40 -0700 | [diff] [blame] | 578 | # /EHsc is about standard C++ exception handling |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 579 | # /DNOMINMAX removes builtin min/max functions |
| 580 | # /wdXXXX disables warning no. XXXX |
| 581 | extra_compile_args = ['/MD', '/Z7', |
peter | c5d6f59 | 2020-04-28 08:16:40 -0700 | [diff] [blame] | 582 | '/EHsc', '/DNOMINMAX', |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 583 | '/wd4267', '/wd4251', '/wd4522', '/wd4522', '/wd4838', |
| 584 | '/wd4305', '/wd4244', '/wd4190', '/wd4101', '/wd4996', |
| 585 | '/wd4275'] |
peterjc123 | aa91193 | 2017-11-09 02:51:35 +0800 | [diff] [blame] | 586 | else: |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 587 | extra_link_args = [] |
| 588 | extra_compile_args = [ |
Sebastian Messmer | bc2e6d1 | 2019-12-03 14:29:00 -0800 | [diff] [blame] | 589 | '-std=c++14', |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 590 | '-Wall', |
| 591 | '-Wextra', |
| 592 | '-Wno-strict-overflow', |
| 593 | '-Wno-unused-parameter', |
| 594 | '-Wno-missing-field-initializers', |
| 595 | '-Wno-write-strings', |
| 596 | '-Wno-unknown-pragmas', |
| 597 | # This is required for Python 2 declarations that are deprecated in 3. |
| 598 | '-Wno-deprecated-declarations', |
| 599 | # Python 2.6 requires -fno-strict-aliasing, see |
| 600 | # http://legacy.python.org/dev/peps/pep-3123/ |
| 601 | # We also depend on it in our code (even Python 3). |
| 602 | '-fno-strict-aliasing', |
| 603 | # Clang has an unfixed bug leading to spurious missing |
| 604 | # braces warnings, see |
| 605 | # https://bugs.llvm.org/show_bug.cgi?id=21629 |
| 606 | '-Wno-missing-braces', |
| 607 | ] |
| 608 | if check_env_flag('WERROR'): |
| 609 | extra_compile_args.append('-Werror') |
Johannes M Dieterich | a4c59a9 | 2018-08-23 15:20:02 -0700 | [diff] [blame] | 610 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 611 | library_dirs.append(lib_path) |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 612 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 613 | main_compile_args = [] |
| 614 | main_libraries = ['shm', 'torch_python'] |
| 615 | main_link_args = [] |
| 616 | main_sources = ["torch/csrc/stub.cpp"] |
| 617 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 618 | if cmake_cache_vars['USE_CUDA']: |
Hong Xu | a5354ad | 2019-10-22 13:59:14 -0700 | [diff] [blame] | 619 | library_dirs.append( |
| 620 | os.path.dirname(cmake_cache_vars['CUDA_CUDA_LIB'])) |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 621 | |
Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 622 | if cmake_cache_vars['USE_NUMPY']: |
| 623 | extra_install_requires += ['numpy'] |
| 624 | |
Hong Xu | fd1d06e | 2019-07-24 08:02:43 -0700 | [diff] [blame] | 625 | if build_type.is_debug(): |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 626 | if IS_WINDOWS: |
| 627 | extra_link_args.append('/DEBUG:FULL') |
| 628 | else: |
| 629 | extra_compile_args += ['-O0', '-g'] |
| 630 | extra_link_args += ['-O0', '-g'] |
| 631 | |
Hong Xu | fd1d06e | 2019-07-24 08:02:43 -0700 | [diff] [blame] | 632 | if build_type.is_rel_with_deb_info(): |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 633 | if IS_WINDOWS: |
| 634 | extra_link_args.append('/DEBUG:FULL') |
| 635 | else: |
| 636 | extra_compile_args += ['-g'] |
| 637 | extra_link_args += ['-g'] |
Zachary DeVito | 788d2e8 | 2018-11-21 06:36:26 -0800 | [diff] [blame] | 638 | |
Adam Paszke | 8d933cb | 2016-08-22 22:45:35 -0400 | [diff] [blame] | 639 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 640 | def make_relative_rpath(path): |
| 641 | if IS_DARWIN: |
| 642 | return '-Wl,-rpath,@loader_path/' + path |
| 643 | elif IS_WINDOWS: |
| 644 | return '' |
| 645 | else: |
| 646 | return '-Wl,-rpath,$ORIGIN/' + path |
Adam Paszke | 8d933cb | 2016-08-22 22:45:35 -0400 | [diff] [blame] | 647 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 648 | ################################################################################ |
| 649 | # Declare extensions and package |
| 650 | ################################################################################ |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 651 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 652 | extensions = [] |
| 653 | packages = find_packages(exclude=('tools', 'tools.*')) |
| 654 | C = Extension("torch._C", |
| 655 | libraries=main_libraries, |
| 656 | sources=main_sources, |
| 657 | language='c++', |
| 658 | extra_compile_args=main_compile_args + extra_compile_args, |
| 659 | include_dirs=[], |
| 660 | library_dirs=library_dirs, |
| 661 | extra_link_args=extra_link_args + main_link_args + [make_relative_rpath('lib')]) |
| 662 | extensions.append(C) |
Adam Paszke | e9f9fd3 | 2016-08-10 09:19:13 -0700 | [diff] [blame] | 663 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 664 | if not IS_WINDOWS: |
| 665 | DL = Extension("torch._dl", |
| 666 | sources=["torch/csrc/dl.c"], |
| 667 | language='c') |
| 668 | extensions.append(DL) |
Soumith Chintala | 1cf87e8 | 2016-09-25 18:56:41 -0400 | [diff] [blame] | 669 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 670 | # These extensions are built by cmake and copied manually in build_extensions() |
| 671 | # inside the build_ext implementaiton |
Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 672 | extensions.append( |
HB_alon | 5e307bd | 2018-12-05 22:16:44 -0800 | [diff] [blame] | 673 | Extension( |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 674 | name=str('caffe2.python.caffe2_pybind11_state'), |
Orion Reblitz-Richardson | 802d21c | 2018-09-07 15:06:30 -0700 | [diff] [blame] | 675 | sources=[]), |
| 676 | ) |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 677 | if cmake_cache_vars['USE_CUDA']: |
| 678 | extensions.append( |
| 679 | Extension( |
| 680 | name=str('caffe2.python.caffe2_pybind11_state_gpu'), |
| 681 | sources=[]), |
| 682 | ) |
| 683 | if cmake_cache_vars['USE_ROCM']: |
| 684 | extensions.append( |
| 685 | Extension( |
| 686 | name=str('caffe2.python.caffe2_pybind11_state_hip'), |
| 687 | sources=[]), |
| 688 | ) |
Adam Paszke | 1bdc281 | 2017-02-15 11:48:08 -0800 | [diff] [blame] | 689 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 690 | cmdclass = { |
| 691 | 'build_ext': build_ext, |
| 692 | 'clean': clean, |
| 693 | 'install': install, |
| 694 | } |
soumith | e4812b3 | 2017-01-17 14:13:44 -0800 | [diff] [blame] | 695 | |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 696 | entry_points = { |
| 697 | 'console_scripts': [ |
| 698 | 'convert-caffe2-to-onnx = caffe2.python.onnx.bin.conversion:caffe2_to_onnx', |
| 699 | 'convert-onnx-to-caffe2 = caffe2.python.onnx.bin.conversion:onnx_to_caffe2', |
| 700 | ] |
| 701 | } |
| 702 | |
Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 703 | return extensions, cmdclass, packages, entry_points, extra_install_requires |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 704 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 705 | # post run, warnings, printed at the end to make them more visible |
| 706 | build_update_message = """ |
| 707 | It is no longer necessary to use the 'build' or 'rebuild' targets |
| 708 | |
| 709 | To install: |
| 710 | $ python setup.py install |
| 711 | To develop locally: |
| 712 | $ python setup.py develop |
Hong Xu | 646a7f9 | 2019-06-11 07:00:51 -0700 | [diff] [blame] | 713 | To force cmake to re-generate native build files (off by default): |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 714 | $ python setup.py develop --cmake |
| 715 | """ |
| 716 | |
| 717 | |
| 718 | def print_box(msg): |
| 719 | lines = msg.split('\n') |
| 720 | size = max(len(l) + 1 for l in lines) |
| 721 | print('-' * (size + 2)) |
| 722 | for l in lines: |
| 723 | print('|{}{}|'.format(l, ' ' * (size - len(l)))) |
| 724 | print('-' * (size + 2)) |
| 725 | |
Jon Crall | 94f439c | 2018-01-11 07:24:17 -0500 | [diff] [blame] | 726 | if __name__ == '__main__': |
Simeon Monov | bad4442 | 2019-02-12 00:12:03 -0800 | [diff] [blame] | 727 | # Parse the command line and check the arguments |
| 728 | # before we proceed with building deps and setup |
| 729 | dist = Distribution() |
| 730 | dist.script_name = sys.argv[0] |
| 731 | dist.script_args = sys.argv[1:] |
| 732 | try: |
| 733 | ok = dist.parse_command_line() |
| 734 | except DistutilsArgError as msg: |
| 735 | raise SystemExit(core.gen_usage(dist.script_name) + "\nerror: %s" % msg) |
| 736 | if not ok: |
| 737 | sys.exit() |
| 738 | |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 739 | if RUN_BUILD_DEPS: |
| 740 | build_deps() |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 741 | |
Eli Uriegas | 275f5c8 | 2020-03-17 13:24:14 -0700 | [diff] [blame] | 742 | extensions, cmdclass, packages, entry_points, extra_install_requires = configure_extension_build() |
| 743 | |
| 744 | install_requires += extra_install_requires |
Hong Xu | b811b6d | 2019-06-14 08:10:18 -0700 | [diff] [blame] | 745 | |
Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 746 | setup( |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 747 | name=package_name, |
Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 748 | version=version, |
| 749 | description=("Tensors and Dynamic neural networks in " |
| 750 | "Python with strong GPU acceleration"), |
| 751 | ext_modules=extensions, |
| 752 | cmdclass=cmdclass, |
| 753 | packages=packages, |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 754 | entry_points=entry_points, |
Soumith Chintala | 6313d5e | 2019-08-04 17:17:33 -0700 | [diff] [blame] | 755 | install_requires=install_requires, |
Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 756 | package_data={ |
| 757 | 'torch': [ |
Jon Malmaud | 1b25fdb | 2019-04-01 15:56:21 -0700 | [diff] [blame] | 758 | 'py.typed', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 759 | 'bin/*', |
| 760 | 'test/*', |
Thomas Viehmann | 6a6983e | 2019-01-29 11:19:51 -0800 | [diff] [blame] | 761 | '__init__.pyi', |
Jon Malmaud | 1b25fdb | 2019-04-01 15:56:21 -0700 | [diff] [blame] | 762 | 'cuda/*.pyi', |
| 763 | 'optim/*.pyi', |
| 764 | 'autograd/*.pyi', |
Jon Malmaud | 0565141 | 2019-04-08 09:45:49 -0700 | [diff] [blame] | 765 | 'utils/data/*.pyi', |
Jon Malmaud | bfeff1e | 2019-07-01 09:41:50 -0700 | [diff] [blame] | 766 | 'nn/*.pyi', |
| 767 | 'nn/modules/*.pyi', |
| 768 | 'nn/parallel/*.pyi', |
Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 769 | 'lib/*.so*', |
| 770 | 'lib/*.dylib*', |
| 771 | 'lib/*.dll', |
| 772 | 'lib/*.lib', |
peter | f773352 | 2019-01-16 23:31:57 -0800 | [diff] [blame] | 773 | 'lib/*.pdb', |
Peter Goldsborough | 1262fba | 2018-01-22 16:49:11 -0800 | [diff] [blame] | 774 | 'lib/torch_shm_manager', |
| 775 | 'lib/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 776 | 'include/ATen/*.h', |
| 777 | 'include/ATen/cpu/*.h', |
Tri Dao | 3789061 | 2019-02-21 07:34:27 -0800 | [diff] [blame] | 778 | 'include/ATen/cpu/vec256/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 779 | 'include/ATen/core/*.h', |
| 780 | 'include/ATen/cuda/*.cuh', |
| 781 | 'include/ATen/cuda/*.h', |
| 782 | 'include/ATen/cuda/detail/*.cuh', |
| 783 | 'include/ATen/cuda/detail/*.h', |
| 784 | 'include/ATen/cudnn/*.h', |
ashish | 9a4219e | 2020-01-13 08:31:43 -0800 | [diff] [blame] | 785 | 'include/ATen/hip/*.cuh', |
| 786 | 'include/ATen/hip/*.h', |
| 787 | 'include/ATen/hip/detail/*.cuh', |
| 788 | 'include/ATen/hip/detail/*.h', |
| 789 | 'include/ATen/hip/impl/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 790 | 'include/ATen/detail/*.h', |
zrphercule | c564d79 | 2019-12-05 13:21:43 -0800 | [diff] [blame] | 791 | 'include/ATen/native/*.h', |
Pavel Belevich | b1c85dd | 2020-01-29 11:27:32 -0800 | [diff] [blame] | 792 | 'include/ATen/native/cpu/*.h', |
zrphercule | eae4a69 | 2019-11-08 14:29:31 -0800 | [diff] [blame] | 793 | 'include/ATen/native/quantized/*.h', |
| 794 | 'include/ATen/native/quantized/cpu/*.h', |
Pavel Belevich | 11a4041 | 2020-03-22 10:54:06 -0700 | [diff] [blame] | 795 | 'include/ATen/quantized/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 796 | 'include/caffe2/utils/*.h', |
qzhong0605 | 50fd20b | 2019-10-30 10:47:09 -0700 | [diff] [blame] | 797 | 'include/caffe2/utils/**/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 798 | 'include/c10/*.h', |
| 799 | 'include/c10/macros/*.h', |
| 800 | 'include/c10/core/*.h', |
Sebastian Messmer | ed207b5 | 2019-09-20 18:42:22 -0700 | [diff] [blame] | 801 | 'include/ATen/core/boxing/*.h', |
Sebastian Messmer | 7ee88d6 | 2020-04-04 14:11:13 -0700 | [diff] [blame] | 802 | 'include/ATen/core/boxing/impl/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 803 | 'include/ATen/core/dispatch/*.h', |
Sebastian Messmer | daa77c6 | 2019-03-21 14:51:38 -0700 | [diff] [blame] | 804 | 'include/ATen/core/op_registration/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 805 | 'include/c10/core/impl/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 806 | 'include/c10/util/*.h', |
| 807 | 'include/c10/cuda/*.h', |
| 808 | 'include/c10/cuda/impl/*.h', |
| 809 | 'include/c10/hip/*.h', |
| 810 | 'include/c10/hip/impl/*.h', |
Feng Tian | 762270c | 2020-04-02 15:44:40 -0700 | [diff] [blame] | 811 | 'include/c10d/*.hpp', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 812 | 'include/caffe2/**/*.h', |
| 813 | 'include/torch/*.h', |
| 814 | 'include/torch/csrc/*.h', |
| 815 | 'include/torch/csrc/api/include/torch/*.h', |
| 816 | 'include/torch/csrc/api/include/torch/data/*.h', |
| 817 | 'include/torch/csrc/api/include/torch/data/dataloader/*.h', |
| 818 | 'include/torch/csrc/api/include/torch/data/datasets/*.h', |
| 819 | 'include/torch/csrc/api/include/torch/data/detail/*.h', |
| 820 | 'include/torch/csrc/api/include/torch/data/samplers/*.h', |
| 821 | 'include/torch/csrc/api/include/torch/data/transforms/*.h', |
| 822 | 'include/torch/csrc/api/include/torch/detail/*.h', |
| 823 | 'include/torch/csrc/api/include/torch/detail/ordered_dict.h', |
| 824 | 'include/torch/csrc/api/include/torch/nn/*.h', |
Will Feng | 57a4b7c | 2019-09-17 10:05:11 -0700 | [diff] [blame] | 825 | 'include/torch/csrc/api/include/torch/nn/functional/*.h', |
| 826 | 'include/torch/csrc/api/include/torch/nn/options/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 827 | 'include/torch/csrc/api/include/torch/nn/modules/*.h', |
Will Feng | 57a4b7c | 2019-09-17 10:05:11 -0700 | [diff] [blame] | 828 | 'include/torch/csrc/api/include/torch/nn/modules/container/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 829 | 'include/torch/csrc/api/include/torch/nn/parallel/*.h', |
Rohan Varma | badb08d | 2019-10-04 13:47:49 -0700 | [diff] [blame] | 830 | 'include/torch/csrc/api/include/torch/nn/utils/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 831 | 'include/torch/csrc/api/include/torch/optim/*.h', |
| 832 | 'include/torch/csrc/api/include/torch/serialize/*.h', |
| 833 | 'include/torch/csrc/autograd/*.h', |
Dmytro Dzhulgakov | 5a26579 | 2019-02-13 22:53:56 -0800 | [diff] [blame] | 834 | 'include/torch/csrc/autograd/functions/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 835 | 'include/torch/csrc/autograd/generated/*.h', |
Dmytro Dzhulgakov | 5a26579 | 2019-02-13 22:53:56 -0800 | [diff] [blame] | 836 | 'include/torch/csrc/autograd/utils/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 837 | 'include/torch/csrc/cuda/*.h', |
| 838 | 'include/torch/csrc/jit/*.h', |
| 839 | 'include/torch/csrc/jit/generated/*.h', |
| 840 | 'include/torch/csrc/jit/passes/*.h', |
Bram Wasti | 035966d | 2019-05-06 14:55:02 -0700 | [diff] [blame] | 841 | 'include/torch/csrc/jit/passes/utils/*.h', |
Michael Suo | dbe850a | 2020-02-27 12:18:24 -0800 | [diff] [blame] | 842 | 'include/torch/csrc/jit/runtime/*.h', |
| 843 | 'include/torch/csrc/jit/ir/*.h', |
| 844 | 'include/torch/csrc/jit/frontend/*.h', |
| 845 | 'include/torch/csrc/jit/api/*.h', |
| 846 | 'include/torch/csrc/jit/serialization/*.h', |
| 847 | 'include/torch/csrc/jit/python/*.h', |
Elias Ellison | 89df22e | 2019-02-19 12:25:30 -0800 | [diff] [blame] | 848 | 'include/torch/csrc/jit/testing/*.h', |
Dmytro Dzhulgakov | 5a26579 | 2019-02-13 22:53:56 -0800 | [diff] [blame] | 849 | 'include/torch/csrc/onnx/*.h', |
Zachary DeVito | 21193bf | 2019-01-29 16:36:08 -0800 | [diff] [blame] | 850 | 'include/torch/csrc/utils/*.h', |
| 851 | 'include/pybind11/*.h', |
| 852 | 'include/pybind11/detail/*.h', |
| 853 | 'include/TH/*.h*', |
| 854 | 'include/TH/generic/*.h*', |
| 855 | 'include/THC/*.cuh', |
| 856 | 'include/THC/*.h*', |
| 857 | 'include/THC/generic/*.h', |
| 858 | 'include/THCUNN/*.cuh', |
| 859 | 'include/THCUNN/generic/*.h', |
ashish | 9a4219e | 2020-01-13 08:31:43 -0800 | [diff] [blame] | 860 | 'include/THH/*.cuh', |
| 861 | 'include/THH/*.h*', |
| 862 | 'include/THH/generic/*.h', |
Peter Goldsborough | a0d4106 | 2018-09-10 15:24:47 -0700 | [diff] [blame] | 863 | 'share/cmake/ATen/*.cmake', |
| 864 | 'share/cmake/Caffe2/*.cmake', |
| 865 | 'share/cmake/Caffe2/public/*.cmake', |
Yangqing Jia | 52beb33 | 2018-10-24 10:14:18 -0700 | [diff] [blame] | 866 | 'share/cmake/Caffe2/Modules_CUDA_fix/*.cmake', |
| 867 | 'share/cmake/Caffe2/Modules_CUDA_fix/upstream/*.cmake', |
| 868 | 'share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/*.cmake', |
Peter Goldsborough | a0d4106 | 2018-09-10 15:24:47 -0700 | [diff] [blame] | 869 | 'share/cmake/Gloo/*.cmake', |
| 870 | 'share/cmake/Torch/*.cmake', |
Jesse Hellemn | c0efe6f | 2018-09-05 16:45:48 -0700 | [diff] [blame] | 871 | ], |
| 872 | 'caffe2': [ |
Jesse Hellemn | 406b9c4 | 2019-01-15 10:12:18 -0800 | [diff] [blame] | 873 | 'python/serialized_test/data/operator_test/*.zip', |
Pritam Damania | f050b16 | 2020-01-22 21:05:28 -0800 | [diff] [blame] | 874 | ], |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 875 | }, |
Soumith Chintala | dded794 | 2019-08-01 11:54:40 -0700 | [diff] [blame] | 876 | url='https://pytorch.org/', |
| 877 | download_url='https://github.com/pytorch/pytorch/tags', |
| 878 | author='PyTorch Team', |
| 879 | author_email='packages@pytorch.org', |
Orion Reblitz-Richardson | f101949 | 2020-03-27 14:25:57 -0700 | [diff] [blame] | 880 | python_requires='>=3.6.1', |
Soumith Chintala | dded794 | 2019-08-01 11:54:40 -0700 | [diff] [blame] | 881 | # PyPI package information. |
| 882 | classifiers=[ |
| 883 | 'Development Status :: 5 - Production/Stable', |
| 884 | 'Intended Audience :: Developers', |
| 885 | 'Intended Audience :: Education', |
| 886 | 'Intended Audience :: Science/Research', |
| 887 | 'License :: OSI Approved :: BSD License', |
| 888 | 'Programming Language :: C++', |
Soumith Chintala | dded794 | 2019-08-01 11:54:40 -0700 | [diff] [blame] | 889 | 'Programming Language :: Python :: 3', |
Soumith Chintala | dded794 | 2019-08-01 11:54:40 -0700 | [diff] [blame] | 890 | 'Programming Language :: Python :: 3.6', |
| 891 | 'Programming Language :: Python :: 3.7', |
Orion Reblitz-Richardson | f101949 | 2020-03-27 14:25:57 -0700 | [diff] [blame] | 892 | 'Programming Language :: Python :: 3.8', |
Soumith Chintala | dded794 | 2019-08-01 11:54:40 -0700 | [diff] [blame] | 893 | 'Topic :: Scientific/Engineering', |
| 894 | 'Topic :: Scientific/Engineering :: Mathematics', |
| 895 | 'Topic :: Scientific/Engineering :: Artificial Intelligence', |
| 896 | 'Topic :: Software Development', |
| 897 | 'Topic :: Software Development :: Libraries', |
| 898 | 'Topic :: Software Development :: Libraries :: Python Modules', |
| 899 | ], |
| 900 | license='BSD-3', |
| 901 | keywords='pytorch machine learning', |
Jesse Hellemn | def3715 | 2018-08-10 11:55:03 -0700 | [diff] [blame] | 902 | ) |
Zachary DeVito | 0cd1ab8 | 2019-01-21 17:24:32 -0800 | [diff] [blame] | 903 | if EMIT_BUILD_WARNING: |
| 904 | print_box(build_update_message) |