Properly creating arguments to pass to setup.py (#3744)

This commit is contained in:
David Brownell 2020-04-29 09:47:51 -07:00 committed by GitHub
parent ea0e2d1dde
commit 7296e06dd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 25 deletions

View file

@ -19,6 +19,26 @@ featurizers_build = False
package_name = 'onnxruntime'
wheel_name_suffix = None
# Any combination of the following arguments can be applied
if '--use_featurizers' in sys.argv:
featurizers_build = True
sys.argv.remove('--use_featurizers')
if '--nightly_build' in sys.argv:
package_name = 'ort-nightly'
nightly_build = True
sys.argv.remove('--nightly_build')
for arg in sys.argv[1:]:
if arg.startswith("--wheel_name_suffix="):
wheel_name_suffix = arg[len("--wheel_name_suffix="):]
nightly_build = True
sys.argv.remove(arg)
break
# The following arguments are mutually exclusive
if '--use_tensorrt' in sys.argv:
package_name = 'onnxruntime-gpu-tensorrt'
sys.argv.remove('--use_tensorrt')
@ -36,34 +56,17 @@ elif '--use_cuda' in sys.argv:
elif '--use_ngraph' in sys.argv:
package_name = 'onnxruntime-ngraph'
sys.argv.remove('--use_ngraph')
elif '--use_openvino' in sys.argv:
package_name = 'onnxruntime-openvino'
sys.argv.remove('--use_openvino')
elif '--use_dnnl' in sys.argv:
package_name = 'onnxruntime-dnnl'
sys.argv.remove('--use_dnnl')
elif '--use_nuphar' in sys.argv:
package_name = 'onnxruntime-nuphar'
sys.argv.remove('--use_nuphar')
elif '--use_openvino' in sys.argv:
package_name = 'onnxruntime-openvino'
sys.argv.remove('--use_openvino')
# --use_acl is specified in build.py, but not parsed here
elif '--use_featurizers' in sys.argv:
featurizers_build = True
sys.argv.remove('--use_featurizers')
if '--nightly_build' in sys.argv:
package_name = 'ort-nightly'
nightly_build = True
sys.argv.remove('--nightly_build')
for arg in sys.argv[1:]:
if arg.startswith("--wheel_name_suffix="):
wheel_name_suffix = arg[len("--wheel_name_suffix="):]
nightly_build = True
sys.argv.remove(arg)
break
is_manylinux1 = False
if environ.get('AUDITWHEEL_PLAT', None) == 'manylinux1_x86_64' or environ.get('AUDITWHEEL_PLAT', None) == 'manylinux2010_x86_64' :

View file

@ -1345,10 +1345,19 @@ def build_python_wheel(
cwd = get_config_build_dir(build_dir, config)
if is_windows():
cwd = os.path.join(cwd, config)
args = [sys.executable, os.path.join(source_dir, 'setup.py'),
'bdist_wheel']
# Any combination of the following arguments can be applied
if nightly_build:
args.append('--nightly_build')
if featurizers_build:
args.append("--use_featurizers")
if wheel_name_suffix:
args.append('--wheel_name_suffix={}'.format(wheel_name_suffix))
# The following arguments are mutually exclusive
if use_tensorrt:
args.append('--use_tensorrt')
elif use_cuda:
@ -1361,12 +1370,8 @@ def build_python_wheel(
args.append('--use_dnnl')
elif use_nuphar:
args.append('--use_nuphar')
if wheel_name_suffix:
args.append('--wheel_name_suffix={}'.format(wheel_name_suffix))
elif use_acl:
args.append('--use_acl')
elif featurizers_build:
args.append("--use_featurizers")
run_subprocess(args, cwd=cwd)