summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorpeter <peterghost86@gmail.com>2018-12-16 21:50:43 -0800
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2018-12-16 21:53:31 -0800
commitd71fac20ebf6b393e464d312b8a38ae1c45c3386 (patch)
tree29e4d58ffeebec4f8e97abaade4a540cc67fbd0b /setup.py
parent656b565a0f53d9f24547b060bd27aa67ebb89b88 (diff)
downloadpytorch-d71fac20ebf6b393e464d312b8a38ae1c45c3386.tar.gz
pytorch-d71fac20ebf6b393e464d312b8a38ae1c45c3386.tar.bz2
pytorch-d71fac20ebf6b393e464d312b8a38ae1c45c3386.zip
Refactor hotpatch_vars and apply it to libtorch (#14976)
Summary: Fixes #14801. Pull Request resolved: https://github.com/pytorch/pytorch/pull/14976 Differential Revision: D13485381 Pulled By: soumith fbshipit-source-id: 0af3c2e1b90988d56f6f85632328d1e4b788ffd2
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py28
1 files changed, 5 insertions, 23 deletions
diff --git a/setup.py b/setup.py
index 79ea3b7950..4d327ba28a 100644
--- a/setup.py
+++ b/setup.py
@@ -145,29 +145,11 @@ import json
import glob
import importlib
-from tools.setup_helpers.env import check_env_flag, check_negative_env_flag
-
-
-def hotpatch_var(var, prefix='USE_'):
- if check_env_flag('NO_' + var):
- os.environ[prefix + var] = '0'
- elif check_negative_env_flag('NO_' + var):
- os.environ[prefix + var] = '1'
- elif check_env_flag('WITH_' + var):
- os.environ[prefix + var] = '1'
- elif check_negative_env_flag('WITH_' + var):
- os.environ[prefix + var] = '0'
-
-# Before we run the setup_helpers, let's look for NO_* and WITH_*
-# variables and hotpatch environment with the USE_* equivalent
-use_env_vars = ['CUDA', 'CUDNN', 'FBGEMM', 'MIOPEN', 'MKLDNN', 'NNPACK', 'DISTRIBUTED',
- 'OPENCV', 'TENSORRT', 'QNNPACK', 'FFMPEG', 'SYSTEM_NCCL',
- 'GLOO_IBVERBS']
-list(map(hotpatch_var, use_env_vars))
-
-# Also hotpatch a few with BUILD_* equivalent
-build_env_vars = ['BINARY', 'TEST', 'CAFFE2_OPS']
-[hotpatch_var(v, 'BUILD_') for v in build_env_vars]
+from tools.setup_helpers.env import (check_env_flag, check_negative_env_flag,
+ hotpatch_build_env_vars)
+
+
+hotpatch_build_env_vars()
from tools.setup_helpers.cuda import USE_CUDA, CUDA_HOME, CUDA_VERSION
from tools.setup_helpers.build import (BUILD_BINARY, BUILD_TEST,