blob: 2d97ab2c6a2523a5c0ac0b6bbeba2d18eb99e4e5 [file] [log] [blame]
Edward Z. Yang031412a2018-02-20 16:55:57 -05001# Welcome to the PyTorch setup.py.
2#
srib53d26122018-04-16 14:29:45 -05003# Environment variables you are probably interested in:
Edward Z. Yang031412a2018-02-20 16:55:57 -05004#
5# DEBUG
6# build with -O0 and -g (debug symbols)
7#
Zachary DeVito788d2e82018-11-21 06:36:26 -08008# REL_WITH_DEB_INFO
9# build with optimizations and -g (debug symbols)
10#
Edward Z. Yang031412a2018-02-20 16:55:57 -050011# MAX_JOBS
12# maximum number of compile jobs we should use to compile your code
13#
Soumith Chintala3069c452019-02-21 09:53:24 -080014# USE_CUDA=0
Edward Z. Yang031412a2018-02-20 16:55:57 -050015# 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 Xu1a9334e2019-08-07 16:18:12 -070020# also applies to C++ files (unless CXXFLAGS is set), in contrast to the
21# default behavior of autogoo and cmake build systems.)
Edward Z. Yang031412a2018-02-20 16:55:57 -050022#
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 Chintala3069c452019-02-21 09:53:24 -080030# USE_CUDNN=0
Edward Z. Yang031412a2018-02-20 16:55:57 -050031# disables the cuDNN build
32#
Soumith Chintala3069c452019-02-21 09:53:24 -080033# USE_FBGEMM=0
Daya S Khudia18de3302018-11-06 15:37:30 -080034# disables the FBGEMM build
35#
Hong Xu240d62f2019-06-06 08:11:17 -070036# USE_NUMPY=0
37# disables the NumPy build
38#
Vishwak Srinivasan9e697032019-02-22 17:03:49 -080039# BUILD_TEST=0
Orion Reblitz-Richardson802d21c2018-09-07 15:06:30 -070040# disables the test build
41#
Soumith Chintala3069c452019-02-21 09:53:24 -080042# USE_MKLDNN=0
Gu, Jinghuid01cb702018-11-08 11:16:33 -080043# disables use of MKLDNN
44#
pinzhenxbd604cb2020-03-26 22:01:21 -070045# MKLDNN_CPU_RUNTIME
Ilia Cherniavskii74f80942019-07-26 13:05:54 -070046# MKL-DNN threading mode: TBB or OMP (default)
Ilia Cherniavskii481b6d02019-05-06 19:25:55 -070047#
Soumith Chintala3069c452019-02-21 09:53:24 -080048# USE_NNPACK=0
Edward Z. Yang031412a2018-02-20 16:55:57 -050049# disables NNPACK build
50#
Soumith Chintala3069c452019-02-21 09:53:24 -080051# USE_QNNPACK=0
Marat Dukhan5e73b822018-10-25 22:13:18 -070052# disables QNNPACK build (quantized 8-bit operators)
53#
Soumith Chintala3069c452019-02-21 09:53:24 -080054# USE_DISTRIBUTED=0
Orion Reblitz-Richardsondda84022018-09-06 08:40:57 -070055# disables distributed (c10d, gloo, mpi, etc.) build
Edward Z. Yang031412a2018-02-20 16:55:57 -050056#
Soumith Chintala3069c452019-02-21 09:53:24 -080057# USE_SYSTEM_NCCL=0
Edward Z. Yang031412a2018-02-20 16:55:57 -050058# disables use of system-wide nccl (we will use our submoduled
Edward Z. Yangeb18a2f2018-03-27 22:09:20 -040059# copy in third_party/nccl)
Edward Z. Yang031412a2018-02-20 16:55:57 -050060#
Vishwak Srinivasan9e697032019-02-22 17:03:49 -080061# BUILD_CAFFE2_OPS=0
Orion Reblitz-Richardsona1752822018-09-10 17:11:16 -070062# disable Caffe2 operators build
63#
Hong Xu8a026d42019-09-10 04:31:31 -070064# USE_IBVERBS
Edward Z. Yang031412a2018-02-20 16:55:57 -050065# toggle features related to distributed support
66#
Orion Reblitz-Richardson802d21c2018-09-07 15:06:30 -070067# USE_OPENCV
68# enables use of OpenCV for additional operators
69#
Ilia Cherniavskii481b6d02019-05-06 19:25:55 -070070# USE_OPENMP=0
71# disables use of OpenMP for parallelization
72#
Orion Reblitz-Richardson25bd7fe2018-10-10 18:07:58 -070073# USE_FFMPEG
74# enables use of ffmpeg for additional operators
75#
Orion Reblitz-Richardsona1752822018-09-10 17:11:16 -070076# USE_LEVELDB
77# enables use of LevelDB for storage
78#
daquexian1fb89252018-10-03 06:03:02 -070079# USE_LMDB
Orion Reblitz-Richardsona1752822018-09-10 17:11:16 -070080# enables use of LMDB for storage
81#
Orion Reblitz-Richardson802d21c2018-09-07 15:06:30 -070082# BUILD_BINARY
83# enables the additional binaries/ build
84#
Edward Z. Yang031412a2018-02-20 16:55:57 -050085# 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 Zou7355f5c2018-04-02 13:35:14 -040090# TORCH_CUDA_ARCH_LIST
91# specify which CUDA architectures to build for.
92# ie `TORCH_CUDA_ARCH_LIST="6.0;7.0"`
Edward Yangcd941632018-08-29 13:29:34 -070093# These are not CUDA versions, instead, they specify what
94# classes of NVIDIA hardware we should generate PTX for.
Richard Zou7355f5c2018-04-02 13:35:14 -040095#
Orion Reblitz-Richardsonedd4e2c2018-06-13 10:25:32 -070096# 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 Hellemn8964a2e62019-01-14 15:10:49 -0800100# 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 Cherniavskii6350dbd2019-06-24 12:48:13 -0700105# MKL_THREADING
Ilia Cherniavskii74f80942019-07-26 13:05:54 -0700106# MKL threading mode: SEQ, TBB or OMP (default)
Ilia Cherniavskii481b6d02019-05-06 19:25:55 -0700107#
Jesse Hellemn8964a2e62019-01-14 15:10:49 -0800108# 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. Yang031412a2018-02-20 16:55:57 -0500114# 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 Haase080266e2018-10-03 06:20:46 -0700121# CUDAHOSTCXX
122# specify a different compiler than the system one to use as the CUDA
123# host compiler for nvcc.
Edward Z. Yang031412a2018-02-20 16:55:57 -0500124#
Jesse Hellemn8964a2e62019-01-14 15:10:49 -0800125# CUDA_NVCC_EXECUTABLE
126# Specify a NVCC to use. This is used in our CI to point to a cached nvcc
127#
Edward Z. Yang031412a2018-02-20 16:55:57 -0500128# CUDNN_LIB_DIR
129# CUDNN_INCLUDE_DIR
130# CUDNN_LIBRARY
131# specify where cuDNN is installed
132#
Johannes M Dietericha4c59a92018-08-23 15:20:02 -0700133# MIOPEN_LIB_DIR
134# MIOPEN_INCLUDE_DIR
135# MIOPEN_LIBRARY
136# specify where MIOpen is installed
137#
Hong Xu60c46dd2019-07-23 08:35:59 -0700138# NCCL_ROOT
Edward Z. Yang031412a2018-02-20 16:55:57 -0500139# 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 Cherniavskiic3d05e82019-05-24 01:59:00 -0700149#
Ilia Cherniavskii74f80942019-07-26 13:05:54 -0700150# ATEN_THREADING
151# ATen parallel backend to use for intra- and inter-op parallelism
Ilia Cherniavskiic3d05e82019-05-24 01:59:00 -0700152# possible values:
Ilia Cherniavskii74f80942019-07-26 13:05:54 -0700153# OMP - use OpenMP for intra-op and native backend for inter-op tasks
Ilia Cherniavskii82aecfa2019-05-28 01:37:40 -0700154# NATIVE - use native thread pool for both intra- and inter-op tasks
Ilia Cherniavskii74f80942019-07-26 13:05:54 -0700155# TBB - using TBB for intra- and native thread pool for inter-op parallelism
Ilia Cherniavskii580eab62019-05-28 02:43:22 -0700156#
157# USE_TBB
Ilia Cherniavskii74f80942019-07-26 13:05:54 -0700158# enable TBB support
Ilia Cherniavskii580eab62019-05-28 02:43:22 -0700159#
Mo Zhouff21b152020-04-23 20:40:16 -0700160# 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. Yang031412a2018-02-20 16:55:57 -0500164
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800165from __future__ import print_function
David Reiss3c85f442020-04-16 10:18:08 -0700166
167import sys
168if sys.version_info < (3,):
169 raise Exception("Python 2 has reached end-of-life and is no longer supported by PyTorch.")
170
Edward Yang173f2242019-03-30 08:58:10 -0700171from setuptools import setup, Extension, distutils, find_packages
Hong Xub811b6d2019-06-14 08:10:18 -0700172from collections import defaultdict
Junjie Baib0c245d2019-11-12 14:48:37 -0800173from distutils import core
Simeon Monovbad44422019-02-12 00:12:03 -0800174from distutils.core import Distribution
175from distutils.errors import DistutilsArgError
Adam Paszke207d6ae2016-08-14 20:47:27 -0700176import setuptools.command.build_ext
Adam Paszkeb06c0002016-08-16 21:02:46 -0700177import setuptools.command.install
Adam Paszke207d6ae2016-08-14 20:47:27 -0700178import distutils.command.clean
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700179import distutils.sysconfig
Soumith Chintalaacb6f182018-09-13 12:26:58 -0700180import filecmp
Adam Paszke652a31b2016-08-04 10:42:19 -0700181import subprocess
Adam Paszke207d6ae2016-08-14 20:47:27 -0700182import shutil
Adam Paszkee9f9fd32016-08-10 09:19:13 -0700183import os
Zachary DeVito70ca8372017-11-30 10:11:43 -0500184import json
185import glob
Richard Zou03f2ad92018-03-09 23:49:18 -0500186import importlib
Adam Paszke731041c2016-05-02 23:06:53 +0200187
Zachary DeVito9477a5d2019-01-25 15:57:09 -0800188from tools.build_pytorch_libs import build_caffe2
Nikita Shulgadd7cec62020-03-10 15:29:07 -0700189from tools.setup_helpers.env import (IS_WINDOWS, IS_DARWIN, IS_LINUX,
Hong Xufd1d06e2019-07-24 08:02:43 -0700190 check_env_flag, build_type)
Hong Xub811b6d2019-06-14 08:10:18 -0700191from tools.setup_helpers.cmake import CMake
Hong Xub811b6d2019-06-14 08:10:18 -0700192
193try:
194 FileNotFoundError
195except NameError:
196 FileNotFoundError = IOError # Python 2.7 does not have FileNotFoundError
197
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700198################################################################################
199# Parameters parsed from environment
200################################################################################
201
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800202VERBOSE_SCRIPT = True
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800203RUN_BUILD_DEPS = True
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800204# see if the user passed a quiet flag to setup.py arguments and respect
205# that in our parts of the build
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800206EMIT_BUILD_WARNING = False
Zachary DeVito9477a5d2019-01-25 15:57:09 -0800207RERUN_CMAKE = False
Hong Xu9a989ec2019-05-28 17:04:10 -0700208CMAKE_ONLY = False
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800209filtered_args = []
210for i, arg in enumerate(sys.argv):
211 if arg == '--cmake':
Zachary DeVito9477a5d2019-01-25 15:57:09 -0800212 RERUN_CMAKE = True
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800213 continue
Hong Xu9a989ec2019-05-28 17:04:10 -0700214 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 DeVito0cd1ab82019-01-21 17:24:32 -0800219 if arg == 'rebuild' or arg == 'build':
220 arg = 'build' # rebuild is gone, make it build
221 EMIT_BUILD_WARNING = True
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800222 if arg == "--":
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800223 filtered_args += sys.argv[i:]
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800224 break
225 if arg == '-q' or arg == '--quiet':
226 VERBOSE_SCRIPT = False
peterb9260bd2020-04-08 08:55:08 -0700227 if arg == 'clean' or arg == 'egg_info':
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800228 RUN_BUILD_DEPS = False
229 filtered_args.append(arg)
230sys.argv = filtered_args
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800231
232if VERBOSE_SCRIPT:
233 def report(*args):
234 print(*args)
235else:
236 def report(*args):
237 pass
238
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700239# Constant known variables used throughout this file
240cwd = os.path.dirname(os.path.abspath(__file__))
241lib_path = os.path.join(cwd, "torch", "lib")
242third_party_path = os.path.join(cwd, "third_party")
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700243caffe2_build_dir = os.path.join(cwd, "build")
244# lib/pythonx.x/site-packages
Jesse Hellemn99ab0822018-07-09 18:04:25 -0700245rel_site_packages = distutils.sysconfig.get_python_lib(prefix='')
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700246# full absolute path to the dir above
Jesse Hellemn99ab0822018-07-09 18:04:25 -0700247full_site_packages = distutils.sysconfig.get_python_lib()
Philip Yangb57fdf12018-10-12 08:06:43 -0700248# CMAKE: full path to python library
CircleCIf1a2bc42018-11-12 14:35:39 -0800249if IS_WINDOWS:
250 cmake_python_library = "{}/libs/python{}.lib".format(
251 distutils.sysconfig.get_config_var("prefix"),
252 distutils.sysconfig.get_config_var("VERSION"))
zrpherculec564d792019-12-05 13:21:43 -0800253 # Fix virtualenv builds
peterd05da7d2019-11-06 09:00:52 -0800254 # 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"))
CircleCIf1a2bc42018-11-12 14:35:39 -0800259else:
260 cmake_python_library = "{}/{}".format(
261 distutils.sysconfig.get_config_var("LIBDIR"),
262 distutils.sysconfig.get_config_var("INSTSONAME"))
Philip Yangb57fdf12018-10-12 08:06:43 -0700263cmake_python_include_dir = distutils.sysconfig.get_python_inc()
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700264
Soumith Chintala5e372c72018-06-06 12:53:58 -0400265
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700266################################################################################
Jesse Hellemndef37152018-08-10 11:55:03 -0700267# Version, create_version_file, and package_name
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700268################################################################################
Jesse Hellemndef37152018-08-10 11:55:03 -0700269package_name = os.getenv('TORCH_PACKAGE_NAME', 'torch')
Pavel Belevich493c9002019-10-03 12:05:33 -0700270version = open('version.txt', 'r').read().strip()
Gao, Xianga40e0a72019-03-25 19:54:27 -0700271sha = 'Unknown'
272
273try:
274 sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()
275except Exception:
276 pass
277
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700278if 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, Xianga40e0a72019-03-25 19:54:27 -0700284elif sha != 'Unknown':
285 version += '+' + sha[:7]
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800286report("Building wheel {}-{}".format(package_name, version))
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700287
Hong Xu82545ec2019-07-25 07:16:01 -0700288cmake = CMake()
Soumith Chintala5e372c72018-06-06 12:53:58 -0400289
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800290# all the work we need to do _before_ setup runs
291def build_deps():
292 report('-- Building version ' + version)
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700293
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800294 def check_file(f):
Mo Zhou5b9f7f72020-04-27 09:34:52 -0700295 if bool(os.getenv("USE_SYSTEM_LIBS", False)):
296 return
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800297 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 Cherniavskii580eab62019-05-28 02:43:22 -0700305 check_file(os.path.join(third_party_path, 'tbb', 'Makefile'))
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800306 check_file(os.path.join(third_party_path, 'onnx', 'CMakeLists.txt'))
Lu Fang9e08c992019-02-25 14:25:18 -0800307 check_file(os.path.join(third_party_path, 'foxi', 'CMakeLists.txt'))
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800308 check_file(os.path.join(third_party_path, 'QNNPACK', 'CMakeLists.txt'))
309 check_file(os.path.join(third_party_path, 'fbgemm', 'CMakeLists.txt'))
Hong Xu1e8f1292019-05-26 18:37:42 -0700310 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 DeVito0cd1ab82019-01-21 17:24:32 -0800314
315 check_pydep('yaml', 'pyyaml')
316 check_pydep('typing', 'typing')
317
Zachary DeVito9477a5d2019-01-25 15:57:09 -0800318 build_caffe2(version=version,
319 cmake_python_library=cmake_python_library,
320 build_python=True,
321 rerun_cmake=RERUN_CMAKE,
Hong Xu9a989ec2019-05-28 17:04:10 -0700322 cmake_only=CMAKE_ONLY,
Hong Xub811b6d2019-06-14 08:10:18 -0700323 cmake=cmake)
Hong Xu081069e2019-10-04 07:48:19 -0700324
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 Viehmann7889e1e2019-11-15 12:01:21 -0800335 f.write("hip = {}\n".format(repr(cmake_cache_vars['HIP_VERSION'])))
Hong Xu081069e2019-10-04 07:48:19 -0700336
Hong Xu9a989ec2019-05-28 17:04:10 -0700337 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 DeVito0cd1ab82019-01-21 17:24:32 -0800342
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 Hellemn8e6f7a12018-06-06 08:31:31 -0700357################################################################################
358# Building dependent libraries
Adam Paszke690d4702016-05-03 15:11:32 +0200359################################################################################
Adam Paszke842e1b62016-05-05 20:58:13 +0200360
Soumith Chintala6313d5e2019-08-04 17:17:33 -0700361# the list of runtime dependencies required by this built package
Nikita Shulgad3f50452020-03-19 17:29:00 -0700362install_requires = ['future']
Soumith Chintala6313d5e2019-08-04 17:17:33 -0700363
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700364missing_pydep = '''
365Missing build dependency: Unable to `import {importname}`.
366Please install it via `conda install {module}` or `pip install {module}`
367'''.strip()
Sam Gross966fdbd2017-08-23 07:16:06 -0400368
Soumith Chintala5e372c72018-06-06 12:53:58 -0400369
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700370def 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 DeVito0e54c3a982017-11-29 16:10:51 -0500375
Soumith Chintala5e372c72018-06-06 12:53:58 -0400376
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800377class build_ext(setuptools.command.build_ext.build_ext):
Adam Paszke207d6ae2016-08-14 20:47:27 -0700378 def run(self):
Hong Xu04086972019-06-17 13:42:45 -0700379 # 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 Xub811b6d2019-06-14 08:10:18 -0700381 cmake_cache_vars = defaultdict(lambda: False, cmake.get_cmake_cache_variables())
382 if cmake_cache_vars['USE_NUMPY']:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800383 report('-- Building with NumPy bindings')
Adam Paszke08d346d2016-12-15 00:04:28 +0100384 else:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800385 report('-- NumPy not found')
Hong Xub811b6d2019-06-14 08:10:18 -0700386 if cmake_cache_vars['USE_CUDNN']:
Hong Xu5e5cbce2019-09-24 07:42:52 -0700387 report('-- Detected cuDNN at ' +
388 cmake_cache_vars['CUDNN_LIBRARY'] + ', ' + cmake_cache_vars['CUDNN_INCLUDE_DIR'])
Adam Paszke08d346d2016-12-15 00:04:28 +0100389 else:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800390 report('-- Not using cuDNN')
Hong Xub811b6d2019-06-14 08:10:18 -0700391 if cmake_cache_vars['USE_CUDA']:
Hong Xua5354ad2019-10-22 13:59:14 -0700392 report('-- Detected CUDA at ' + cmake_cache_vars['CUDA_TOOLKIT_ROOT_DIR'])
Adam Paszke08d346d2016-12-15 00:04:28 +0100393 else:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800394 report('-- Not using CUDA')
Hong Xub811b6d2019-06-14 08:10:18 -0700395 if cmake_cache_vars['USE_MKLDNN']:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800396 report('-- Using MKLDNN')
Hui Wu07ef85e2019-07-02 12:22:20 -0700397 if cmake_cache_vars['USE_MKLDNN_CBLAS']:
398 report('-- Using CBLAS in MKLDNN')
399 else:
400 report('-- Not using CBLAS in MKLDNN')
Ma Mingfeif8270c02018-03-30 06:25:07 +0800401 else:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800402 report('-- Not using MKLDNN')
Hong Xub811b6d2019-06-14 08:10:18 -0700403 if cmake_cache_vars['USE_NCCL'] and cmake_cache_vars['USE_SYSTEM_NCCL']:
Hong Xu60c46dd2019-07-23 08:35:59 -0700404 report('-- Using system provided NCCL library at {}, {}'.format(cmake_cache_vars['NCCL_LIBRARIES'],
405 cmake_cache_vars['NCCL_INCLUDE_DIRS']))
Hong Xub811b6d2019-06-14 08:10:18 -0700406 elif cmake_cache_vars['USE_NCCL']:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800407 report('-- Building NCCL library')
Sam Grossb9379cf2017-03-16 16:10:17 -0400408 else:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800409 report('-- Not using NCCL')
Hong Xub811b6d2019-06-14 08:10:18 -0700410 if cmake_cache_vars['USE_DISTRIBUTED']:
Pieter Noordhuis3556bea2019-09-05 07:08:12 -0700411 if IS_WINDOWS:
412 report('-- Building without distributed package')
Teng Li020501b2018-09-04 17:18:29 -0700413 else:
Pieter Noordhuis3556bea2019-09-05 07:08:12 -0700414 report('-- Building with distributed package ')
Adam Paszke714351f2017-06-07 06:36:20 -0400415 else:
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800416 report('-- Building without distributed package')
peterjc123aa911932017-11-09 02:51:35 +0800417
Nikita Shulgadd7cec62020-03-10 15:29:07 -0700418 # 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 Paszkeb06c0002016-08-16 21:02:46 -0700424 # It's an old-style class in Python 2.7...
425 setuptools.command.build_ext.build_ext.run(self)
426
peterjc12363af8982018-04-03 01:53:25 +0800427 # 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 KITAGUCHIddbfdc92019-04-01 07:24:27 -0700442 # 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
peterjc12363af8982018-04-03 01:53:25 +0800448 self.copy_file(export_lib, target_lib)
449
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700450 def build_extensions(self):
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800451 self.create_compile_commands()
Jesse Hellemn99ab0822018-07-09 18:04:25 -0700452 # The caffe2 extensions are created in
andersj8a5ba572019-01-08 15:54:20 -0800453 # tmp_install/lib/pythonM.m/site-packages/caffe2/python/
Jesse Hellemn99ab0822018-07-09 18:04:25 -0700454 # 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 Hellemnc0efe6f2018-09-05 16:45:48 -0700458 # 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 DeVitoe747acb2018-12-09 22:45:18 -0800472 report("\nCopying extension {}".format(ext.name))
Paul Jesse Hellemn8e6f7a12018-06-06 08:31:31 -0700473
Zachary DeVito21193bf2019-01-29 16:36:08 -0800474 src = os.path.join("torch", rel_site_packages, filename)
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700475 if not os.path.exists(src):
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800476 report("{} does not exist".format(src))
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700477 del self.extensions[i]
478 else:
479 dst = os.path.join(os.path.realpath(self.build_lib), filename)
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800480 report("Copying {} from {} to {}".format(ext.name, src, dst))
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700481 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 Hellemn8e6f7a12018-06-06 08:31:31 -0700486 distutils.command.build_ext.build_ext.build_extensions(self)
487
Jesse Hellemn99ab0822018-07-09 18:04:25 -0700488 def get_outputs(self):
489 outputs = distutils.command.build_ext.build_ext.get_outputs(self)
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700490 outputs.append(os.path.join(self.build_lib, "caffe2"))
Zachary DeVitoe747acb2018-12-09 22:45:18 -0800491 report("setup.py::get_outputs returning {}".format(outputs))
Jesse Hellemn99ab0822018-07-09 18:04:25 -0700492 return outputs
493
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800494 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 Paszke207d6ae2016-08-14 20:47:27 -0700503
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800504 # 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 Paszke207d6ae2016-08-14 20:47:27 -0700511
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800512 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 Chintala4e8d9a42018-09-11 08:51:19 -0700520
521
Adam Paszkeb06c0002016-08-16 21:02:46 -0700522class install(setuptools.command.install.install):
523 def run(self):
Adam Paszkeb06c0002016-08-16 21:02:46 -0700524 setuptools.command.install.install.run(self)
525
526
Adam Paszke207d6ae2016-08-14 20:47:27 -0700527class clean(distutils.command.clean.clean):
528 def run(self):
Soumith Chintala140c65e2016-10-21 23:16:39 -0400529 import glob
Shuichi KITAGUCHIdf23bdc2018-08-05 15:47:02 -0700530 import re
Adam Paszke207d6ae2016-08-14 20:47:27 -0700531 with open('.gitignore', 'r') as f:
532 ignores = f.read()
Shuichi KITAGUCHIdf23bdc2018-08-05 15:47:02 -0700533 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 Grossf2d7e942016-10-26 09:51:52 -0700547
Adam Paszkeb06c0002016-08-16 21:02:46 -0700548 # It's an old-style class in Python 2.7...
549 distutils.command.clean.clean.run(self)
550
Hong Xub811b6d2019-06-14 08:10:18 -0700551def configure_extension_build():
552 r"""Configures extension build options according to system environment and user's choice.
Adam Paszke207d6ae2016-08-14 20:47:27 -0700553
Hong Xub811b6d2019-06-14 08:10:18 -0700554 Returns:
555 The input to parameters ext_modules, cmdclass, packages, and entry_points as required in setuptools.setup.
556 """
Adam Paszkee9f9fd32016-08-10 09:19:13 -0700557
Hong Xub811b6d2019-06-14 08:10:18 -0700558 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)
peterjc123aa911932017-11-09 02:51:35 +0800563
Hong Xub811b6d2019-06-14 08:10:18 -0700564 ################################################################################
565 # Configure compile flags
566 ################################################################################
Adam Paszkee9f9fd32016-08-10 09:19:13 -0700567
Hong Xub811b6d2019-06-14 08:10:18 -0700568 library_dirs = []
Eli Uriegas275f5c82020-03-17 13:24:14 -0700569 extra_install_requires = []
Adam Paszkee9f9fd32016-08-10 09:19:13 -0700570
peterjc123aa911932017-11-09 02:51:35 +0800571 if IS_WINDOWS:
Hong Xub811b6d2019-06-14 08:10:18 -0700572 # /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
peterc5d6f592020-04-28 08:16:40 -0700578 # /EHsc is about standard C++ exception handling
Hong Xub811b6d2019-06-14 08:10:18 -0700579 # /DNOMINMAX removes builtin min/max functions
580 # /wdXXXX disables warning no. XXXX
581 extra_compile_args = ['/MD', '/Z7',
peterc5d6f592020-04-28 08:16:40 -0700582 '/EHsc', '/DNOMINMAX',
Hong Xub811b6d2019-06-14 08:10:18 -0700583 '/wd4267', '/wd4251', '/wd4522', '/wd4522', '/wd4838',
584 '/wd4305', '/wd4244', '/wd4190', '/wd4101', '/wd4996',
585 '/wd4275']
peterjc123aa911932017-11-09 02:51:35 +0800586 else:
Hong Xub811b6d2019-06-14 08:10:18 -0700587 extra_link_args = []
588 extra_compile_args = [
Sebastian Messmerbc2e6d12019-12-03 14:29:00 -0800589 '-std=c++14',
Hong Xub811b6d2019-06-14 08:10:18 -0700590 '-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 Dietericha4c59a92018-08-23 15:20:02 -0700610
Hong Xub811b6d2019-06-14 08:10:18 -0700611 library_dirs.append(lib_path)
Adam Paszkee9f9fd32016-08-10 09:19:13 -0700612
Hong Xub811b6d2019-06-14 08:10:18 -0700613 main_compile_args = []
614 main_libraries = ['shm', 'torch_python']
615 main_link_args = []
616 main_sources = ["torch/csrc/stub.cpp"]
617
Hong Xub811b6d2019-06-14 08:10:18 -0700618 if cmake_cache_vars['USE_CUDA']:
Hong Xua5354ad2019-10-22 13:59:14 -0700619 library_dirs.append(
620 os.path.dirname(cmake_cache_vars['CUDA_CUDA_LIB']))
Hong Xub811b6d2019-06-14 08:10:18 -0700621
Eli Uriegas275f5c82020-03-17 13:24:14 -0700622 if cmake_cache_vars['USE_NUMPY']:
623 extra_install_requires += ['numpy']
624
Hong Xufd1d06e2019-07-24 08:02:43 -0700625 if build_type.is_debug():
Hong Xub811b6d2019-06-14 08:10:18 -0700626 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 Xufd1d06e2019-07-24 08:02:43 -0700632 if build_type.is_rel_with_deb_info():
Hong Xub811b6d2019-06-14 08:10:18 -0700633 if IS_WINDOWS:
634 extra_link_args.append('/DEBUG:FULL')
635 else:
636 extra_compile_args += ['-g']
637 extra_link_args += ['-g']
Zachary DeVito788d2e82018-11-21 06:36:26 -0800638
Adam Paszke8d933cb2016-08-22 22:45:35 -0400639
Hong Xub811b6d2019-06-14 08:10:18 -0700640 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 Paszke8d933cb2016-08-22 22:45:35 -0400647
Hong Xub811b6d2019-06-14 08:10:18 -0700648 ################################################################################
649 # Declare extensions and package
650 ################################################################################
Adam Paszkee9f9fd32016-08-10 09:19:13 -0700651
Hong Xub811b6d2019-06-14 08:10:18 -0700652 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 Paszkee9f9fd32016-08-10 09:19:13 -0700663
Hong Xub811b6d2019-06-14 08:10:18 -0700664 if not IS_WINDOWS:
665 DL = Extension("torch._dl",
666 sources=["torch/csrc/dl.c"],
667 language='c')
668 extensions.append(DL)
Soumith Chintala1cf87e82016-09-25 18:56:41 -0400669
Hong Xub811b6d2019-06-14 08:10:18 -0700670 # These extensions are built by cmake and copied manually in build_extensions()
671 # inside the build_ext implementaiton
Orion Reblitz-Richardson802d21c2018-09-07 15:06:30 -0700672 extensions.append(
HB_alon5e307bd2018-12-05 22:16:44 -0800673 Extension(
Hong Xub811b6d2019-06-14 08:10:18 -0700674 name=str('caffe2.python.caffe2_pybind11_state'),
Orion Reblitz-Richardson802d21c2018-09-07 15:06:30 -0700675 sources=[]),
676 )
Hong Xub811b6d2019-06-14 08:10:18 -0700677 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 Paszke1bdc2812017-02-15 11:48:08 -0800689
Hong Xub811b6d2019-06-14 08:10:18 -0700690 cmdclass = {
691 'build_ext': build_ext,
692 'clean': clean,
693 'install': install,
694 }
soumithe4812b32017-01-17 14:13:44 -0800695
Hong Xub811b6d2019-06-14 08:10:18 -0700696 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 Uriegas275f5c82020-03-17 13:24:14 -0700703 return extensions, cmdclass, packages, entry_points, extra_install_requires
Jesse Hellemndef37152018-08-10 11:55:03 -0700704
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800705# post run, warnings, printed at the end to make them more visible
706build_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 Xu646a7f92019-06-11 07:00:51 -0700713 To force cmake to re-generate native build files (off by default):
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800714 $ python setup.py develop --cmake
715"""
716
717
718def 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 Crall94f439c2018-01-11 07:24:17 -0500726if __name__ == '__main__':
Simeon Monovbad44422019-02-12 00:12:03 -0800727 # 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 DeVito0cd1ab82019-01-21 17:24:32 -0800739 if RUN_BUILD_DEPS:
740 build_deps()
Hong Xub811b6d2019-06-14 08:10:18 -0700741
Eli Uriegas275f5c82020-03-17 13:24:14 -0700742 extensions, cmdclass, packages, entry_points, extra_install_requires = configure_extension_build()
743
744 install_requires += extra_install_requires
Hong Xub811b6d2019-06-14 08:10:18 -0700745
Peter Goldsborough1262fba2018-01-22 16:49:11 -0800746 setup(
Jesse Hellemndef37152018-08-10 11:55:03 -0700747 name=package_name,
Peter Goldsborough1262fba2018-01-22 16:49:11 -0800748 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 Hellemndef37152018-08-10 11:55:03 -0700754 entry_points=entry_points,
Soumith Chintala6313d5e2019-08-04 17:17:33 -0700755 install_requires=install_requires,
Peter Goldsborough1262fba2018-01-22 16:49:11 -0800756 package_data={
757 'torch': [
Jon Malmaud1b25fdb2019-04-01 15:56:21 -0700758 'py.typed',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800759 'bin/*',
760 'test/*',
Thomas Viehmann6a6983e2019-01-29 11:19:51 -0800761 '__init__.pyi',
Jon Malmaud1b25fdb2019-04-01 15:56:21 -0700762 'cuda/*.pyi',
763 'optim/*.pyi',
764 'autograd/*.pyi',
Jon Malmaud05651412019-04-08 09:45:49 -0700765 'utils/data/*.pyi',
Jon Malmaudbfeff1e2019-07-01 09:41:50 -0700766 'nn/*.pyi',
767 'nn/modules/*.pyi',
768 'nn/parallel/*.pyi',
Peter Goldsborough1262fba2018-01-22 16:49:11 -0800769 'lib/*.so*',
770 'lib/*.dylib*',
771 'lib/*.dll',
772 'lib/*.lib',
peterf7733522019-01-16 23:31:57 -0800773 'lib/*.pdb',
Peter Goldsborough1262fba2018-01-22 16:49:11 -0800774 'lib/torch_shm_manager',
775 'lib/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800776 'include/ATen/*.h',
777 'include/ATen/cpu/*.h',
Tri Dao37890612019-02-21 07:34:27 -0800778 'include/ATen/cpu/vec256/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800779 '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',
ashish9a4219e2020-01-13 08:31:43 -0800785 '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 DeVito21193bf2019-01-29 16:36:08 -0800790 'include/ATen/detail/*.h',
zrpherculec564d792019-12-05 13:21:43 -0800791 'include/ATen/native/*.h',
Pavel Belevichb1c85dd2020-01-29 11:27:32 -0800792 'include/ATen/native/cpu/*.h',
zrpherculeeae4a692019-11-08 14:29:31 -0800793 'include/ATen/native/quantized/*.h',
794 'include/ATen/native/quantized/cpu/*.h',
Pavel Belevich11a40412020-03-22 10:54:06 -0700795 'include/ATen/quantized/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800796 'include/caffe2/utils/*.h',
qzhong060550fd20b2019-10-30 10:47:09 -0700797 'include/caffe2/utils/**/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800798 'include/c10/*.h',
799 'include/c10/macros/*.h',
800 'include/c10/core/*.h',
Sebastian Messmered207b52019-09-20 18:42:22 -0700801 'include/ATen/core/boxing/*.h',
Sebastian Messmer7ee88d62020-04-04 14:11:13 -0700802 'include/ATen/core/boxing/impl/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800803 'include/ATen/core/dispatch/*.h',
Sebastian Messmerdaa77c62019-03-21 14:51:38 -0700804 'include/ATen/core/op_registration/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800805 'include/c10/core/impl/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800806 '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 Tian762270c2020-04-02 15:44:40 -0700811 'include/c10d/*.hpp',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800812 '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 Feng57a4b7c2019-09-17 10:05:11 -0700825 'include/torch/csrc/api/include/torch/nn/functional/*.h',
826 'include/torch/csrc/api/include/torch/nn/options/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800827 'include/torch/csrc/api/include/torch/nn/modules/*.h',
Will Feng57a4b7c2019-09-17 10:05:11 -0700828 'include/torch/csrc/api/include/torch/nn/modules/container/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800829 'include/torch/csrc/api/include/torch/nn/parallel/*.h',
Rohan Varmabadb08d2019-10-04 13:47:49 -0700830 'include/torch/csrc/api/include/torch/nn/utils/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800831 'include/torch/csrc/api/include/torch/optim/*.h',
832 'include/torch/csrc/api/include/torch/serialize/*.h',
833 'include/torch/csrc/autograd/*.h',
Dmytro Dzhulgakov5a265792019-02-13 22:53:56 -0800834 'include/torch/csrc/autograd/functions/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800835 'include/torch/csrc/autograd/generated/*.h',
Dmytro Dzhulgakov5a265792019-02-13 22:53:56 -0800836 'include/torch/csrc/autograd/utils/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800837 '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 Wasti035966d2019-05-06 14:55:02 -0700841 'include/torch/csrc/jit/passes/utils/*.h',
Michael Suodbe850a2020-02-27 12:18:24 -0800842 '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 Ellison89df22e2019-02-19 12:25:30 -0800848 'include/torch/csrc/jit/testing/*.h',
Dmytro Dzhulgakov5a265792019-02-13 22:53:56 -0800849 'include/torch/csrc/onnx/*.h',
Zachary DeVito21193bf2019-01-29 16:36:08 -0800850 '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',
ashish9a4219e2020-01-13 08:31:43 -0800860 'include/THH/*.cuh',
861 'include/THH/*.h*',
862 'include/THH/generic/*.h',
Peter Goldsborougha0d41062018-09-10 15:24:47 -0700863 'share/cmake/ATen/*.cmake',
864 'share/cmake/Caffe2/*.cmake',
865 'share/cmake/Caffe2/public/*.cmake',
Yangqing Jia52beb332018-10-24 10:14:18 -0700866 '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 Goldsborougha0d41062018-09-10 15:24:47 -0700869 'share/cmake/Gloo/*.cmake',
870 'share/cmake/Torch/*.cmake',
Jesse Hellemnc0efe6f2018-09-05 16:45:48 -0700871 ],
872 'caffe2': [
Jesse Hellemn406b9c42019-01-15 10:12:18 -0800873 'python/serialized_test/data/operator_test/*.zip',
Pritam Damaniaf050b162020-01-22 21:05:28 -0800874 ],
Jesse Hellemndef37152018-08-10 11:55:03 -0700875 },
Soumith Chintaladded7942019-08-01 11:54:40 -0700876 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-Richardsonf1019492020-03-27 14:25:57 -0700880 python_requires='>=3.6.1',
Soumith Chintaladded7942019-08-01 11:54:40 -0700881 # 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 Chintaladded7942019-08-01 11:54:40 -0700889 'Programming Language :: Python :: 3',
Soumith Chintaladded7942019-08-01 11:54:40 -0700890 'Programming Language :: Python :: 3.6',
891 'Programming Language :: Python :: 3.7',
Orion Reblitz-Richardsonf1019492020-03-27 14:25:57 -0700892 'Programming Language :: Python :: 3.8',
Soumith Chintaladded7942019-08-01 11:54:40 -0700893 '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 Hellemndef37152018-08-10 11:55:03 -0700902 )
Zachary DeVito0cd1ab82019-01-21 17:24:32 -0800903 if EMIT_BUILD_WARNING:
904 print_box(build_update_message)