mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Parse the command line and check the arguments before build_deps() (#16914)
Summary: This is needed to check for wrong arguments or --help options before `build_deps()` is executed. Otherwise command line arguments are not parsed and checked until `setup()` is run. Fixes: #16707 Pull Request resolved: https://github.com/pytorch/pytorch/pull/16914 Differential Revision: D14041236 Pulled By: soumith fbshipit-source-id: 41f635772ccf47f05114775d5a19ae04c495ab3b
This commit is contained in:
committed by
Facebook Github Bot
parent
4d4c5273de
commit
bad4442a7c
16
setup.py
16
setup.py
@ -143,7 +143,9 @@
|
||||
|
||||
from __future__ import print_function
|
||||
from setuptools import setup, Extension, distutils, Command, find_packages
|
||||
from distutils import dir_util
|
||||
from distutils import core, dir_util
|
||||
from distutils.core import Distribution
|
||||
from distutils.errors import DistutilsArgError
|
||||
import setuptools.command.build_ext
|
||||
import setuptools.command.install
|
||||
import distutils.command.clean
|
||||
@ -716,6 +718,18 @@ def print_box(msg):
|
||||
print('-' * (size + 2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Parse the command line and check the arguments
|
||||
# before we proceed with building deps and setup
|
||||
dist = Distribution()
|
||||
dist.script_name = sys.argv[0]
|
||||
dist.script_args = sys.argv[1:]
|
||||
try:
|
||||
ok = dist.parse_command_line()
|
||||
except DistutilsArgError as msg:
|
||||
raise SystemExit(core.gen_usage(dist.script_name) + "\nerror: %s" % msg)
|
||||
if not ok:
|
||||
sys.exit()
|
||||
|
||||
if RUN_BUILD_DEPS:
|
||||
build_deps()
|
||||
setup(
|
||||
|
Reference in New Issue
Block a user