diff options
author | Richard Zou <zou3519@users.noreply.github.com> | 2018-03-09 23:49:18 -0500 |
---|---|---|
committer | Soumith Chintala <soumith@gmail.com> | 2018-03-09 23:49:18 -0500 |
commit | 03f2ad9029165d20585d00b11f45fe50de6b687f (patch) | |
tree | c3f2e2433c6abd9a830339eb75d9e9c46f31bd62 /setup.py | |
parent | 74043b69c23113e399917ef047c255f31cb82bda (diff) | |
download | pytorch-03f2ad9029165d20585d00b11f45fe50de6b687f.tar.gz pytorch-03f2ad9029165d20585d00b11f45fe50de6b687f.tar.bz2 pytorch-03f2ad9029165d20585d00b11f45fe50de6b687f.zip |
Add check for python build deps to setup.py (#5618)
* Add check for python build deps to setup.py
* Address comments
* Remove install_requires line
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -91,6 +91,7 @@ import sys import os import json import glob +import importlib from tools.setup_helpers.env import check_env_flag from tools.setup_helpers.cuda import WITH_CUDA, CUDA_HOME, CUDA_VERSION @@ -220,6 +221,18 @@ def build_libs(libs): if subprocess.call(build_libs_cmd + libs, env=my_env) != 0: sys.exit(1) +missing_pydep = ''' +Missing build dependency: Unable to `import {importname}`. +Please install it via `conda install {module}` or `pip install {module}` +'''.strip() + + +def check_pydep(importname, module): + try: + importlib.import_module(importname) + except ImportError: + raise RuntimeError(missing_pydep.format(importname=importname, module=module)) + class build_deps(Command): user_options = [] @@ -241,6 +254,9 @@ class build_deps(Command): check_file(os.path.join(lib_path, "nanopb", "CMakeLists.txt")) check_file(os.path.join(lib_path, "pybind11", "CMakeLists.txt")) + check_pydep('yaml', 'pyyaml') + check_pydep('typing', 'typing') + libs = [] if WITH_NCCL and not WITH_SYSTEM_NCCL: libs += ['nccl'] @@ -810,5 +826,4 @@ if __name__ == '__main__': 'lib/include/torch/csrc/utils/*.h', 'lib/include/torch/torch.h', ] - }, - install_requires=['pyyaml', 'numpy'], ) + }) |