2018-11-20 00:48:22 +00:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
#--------------------------------------------------------------------------
|
|
|
|
|
|
2019-06-27 22:45:06 +00:00
|
|
|
from setuptools import setup, find_packages, Extension
|
|
|
|
|
from distutils import log as logger
|
|
|
|
|
from distutils.command.build_ext import build_ext as _build_ext
|
|
|
|
|
from glob import glob
|
2020-04-23 20:27:22 +00:00
|
|
|
from os import path, getcwd, environ, remove, walk, makedirs, listdir
|
|
|
|
|
from shutil import copyfile, copytree, rmtree
|
2018-11-20 00:48:22 +00:00
|
|
|
import platform
|
2019-06-27 22:45:06 +00:00
|
|
|
import subprocess
|
2018-11-20 00:48:22 +00:00
|
|
|
import sys
|
2019-04-12 05:06:18 +00:00
|
|
|
import datetime
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2019-04-12 05:06:18 +00:00
|
|
|
nightly_build = False
|
2020-04-23 20:27:22 +00:00
|
|
|
featurizers_build = False
|
2018-11-20 00:48:22 +00:00
|
|
|
package_name = 'onnxruntime'
|
2020-04-14 16:00:13 +00:00
|
|
|
wheel_name_suffix = None
|
2019-06-18 15:58:53 +00:00
|
|
|
|
2020-04-29 16:47:51 +00:00
|
|
|
# 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="):]
|
|
|
|
|
|
|
|
|
|
sys.argv.remove(arg)
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
# The following arguments are mutually exclusive
|
2019-03-15 05:25:16 +00:00
|
|
|
if '--use_tensorrt' in sys.argv:
|
2020-06-01 16:30:56 +00:00
|
|
|
package_name = 'onnxruntime-gpu-tensorrt' if not nightly_build else 'ort-trt-nightly'
|
2019-03-15 05:25:16 +00:00
|
|
|
sys.argv.remove('--use_tensorrt')
|
|
|
|
|
elif '--use_cuda' in sys.argv:
|
2020-06-01 16:30:56 +00:00
|
|
|
package_name = 'onnxruntime-gpu' if not nightly_build else 'ort-gpu-nightly'
|
2018-11-20 00:48:22 +00:00
|
|
|
sys.argv.remove('--use_cuda')
|
2019-04-21 00:02:35 +00:00
|
|
|
elif '--use_ngraph' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-ngraph'
|
|
|
|
|
sys.argv.remove('--use_ngraph')
|
2020-04-29 16:47:51 +00:00
|
|
|
elif '--use_openvino' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-openvino'
|
|
|
|
|
sys.argv.remove('--use_openvino')
|
2020-01-13 22:37:11 +00:00
|
|
|
elif '--use_dnnl' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-dnnl'
|
|
|
|
|
sys.argv.remove('--use_dnnl')
|
2019-09-05 15:50:48 +00:00
|
|
|
elif '--use_nuphar' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-nuphar'
|
|
|
|
|
sys.argv.remove('--use_nuphar')
|
2020-05-19 12:32:32 +00:00
|
|
|
elif '--use_vitisai' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-vitisai'
|
|
|
|
|
sys.argv.remove('--use_vitisai')
|
2020-06-18 14:54:14 +00:00
|
|
|
elif '--use_acl' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-acl'
|
|
|
|
|
sys.argv.remove('--use_acl')
|
|
|
|
|
elif '--use_armnn' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-armnn'
|
|
|
|
|
sys.argv.remove('--use_armnn')
|
2020-09-08 21:34:09 +00:00
|
|
|
elif '--use_dml' in sys.argv:
|
|
|
|
|
package_name = 'onnxruntime-dml'
|
|
|
|
|
sys.argv.remove('--use_dml')
|
2020-04-14 16:00:13 +00:00
|
|
|
|
2020-05-11 17:26:16 +00:00
|
|
|
# PEP 513 defined manylinux1_x86_64 and manylinux1_i686
|
|
|
|
|
# PEP 571 defined manylinux2010_x86_64 and manylinux2010_i686
|
|
|
|
|
# PEP 599 defines the following platform tags:
|
|
|
|
|
# manylinux2014_x86_64
|
|
|
|
|
# manylinux2014_i686
|
|
|
|
|
# manylinux2014_aarch64
|
|
|
|
|
# manylinux2014_armv7l
|
|
|
|
|
# manylinux2014_ppc64
|
|
|
|
|
# manylinux2014_ppc64le
|
|
|
|
|
# manylinux2014_s390x
|
|
|
|
|
manylinux_tags = [
|
|
|
|
|
'manylinux1_x86_64',
|
|
|
|
|
'manylinux1_i686',
|
|
|
|
|
'manylinux2010_x86_64',
|
|
|
|
|
'manylinux2010_i686',
|
|
|
|
|
'manylinux2014_x86_64',
|
|
|
|
|
'manylinux2014_i686',
|
|
|
|
|
'manylinux2014_aarch64',
|
|
|
|
|
'manylinux2014_armv7l',
|
|
|
|
|
'manylinux2014_ppc64',
|
|
|
|
|
'manylinux2014_ppc64le',
|
|
|
|
|
'manylinux2014_s390x',
|
|
|
|
|
]
|
2020-05-18 16:41:00 +00:00
|
|
|
is_manylinux = environ.get('AUDITWHEEL_PLAT', None) in manylinux_tags
|
2019-06-27 22:45:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class build_ext(_build_ext):
|
|
|
|
|
def build_extension(self, ext):
|
|
|
|
|
dest_file = self.get_ext_fullpath(ext.name)
|
|
|
|
|
logger.info('copying %s -> %s', ext.sources[0], dest_file)
|
|
|
|
|
copyfile(ext.sources[0], dest_file)
|
|
|
|
|
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
try:
|
|
|
|
|
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
|
|
|
|
|
class bdist_wheel(_bdist_wheel):
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
_bdist_wheel.finalize_options(self)
|
2020-05-18 16:41:00 +00:00
|
|
|
if not is_manylinux:
|
2019-06-27 22:45:06 +00:00
|
|
|
self.root_is_pure = False
|
|
|
|
|
|
|
|
|
|
def _rewrite_ld_preload(self, to_preload):
|
|
|
|
|
with open('onnxruntime/capi/_ld_preload.py', 'rt') as f:
|
|
|
|
|
ld_preload = f.read().splitlines()
|
|
|
|
|
with open('onnxruntime/capi/_ld_preload.py', 'wt') as f:
|
|
|
|
|
for line in ld_preload:
|
|
|
|
|
f.write(line)
|
|
|
|
|
f.write('\n')
|
|
|
|
|
if 'LD_PRELOAD_BEGIN_MARK' in line:
|
|
|
|
|
break
|
|
|
|
|
if len(to_preload) > 0:
|
|
|
|
|
f.write('from ctypes import CDLL, RTLD_GLOBAL\n')
|
|
|
|
|
for library in to_preload:
|
|
|
|
|
f.write('_{} = CDLL("{}", mode=RTLD_GLOBAL)\n'.format(library.split('.')[0], library))
|
|
|
|
|
|
|
|
|
|
def run(self):
|
2020-05-18 16:41:00 +00:00
|
|
|
if is_manylinux:
|
2019-06-27 22:45:06 +00:00
|
|
|
source = 'onnxruntime/capi/onnxruntime_pybind11_state.so'
|
2019-10-09 16:23:00 +00:00
|
|
|
dest = 'onnxruntime/capi/onnxruntime_pybind11_state_manylinux1.so'
|
2019-06-27 22:45:06 +00:00
|
|
|
logger.info('copying %s -> %s', source, dest)
|
|
|
|
|
copyfile(source, dest)
|
|
|
|
|
result = subprocess.run(['patchelf', '--print-needed', dest], check=True, stdout=subprocess.PIPE, universal_newlines=True)
|
2020-05-25 05:55:24 +00:00
|
|
|
cuda_dependencies = ['libcublas.so', 'libcudnn.so', 'libcudart.so', 'libcurand.so', 'libcufft.so', 'libnvToolsExt.so']
|
2019-06-27 22:45:06 +00:00
|
|
|
to_preload = []
|
|
|
|
|
args = ['patchelf', '--debug']
|
|
|
|
|
for line in result.stdout.split('\n'):
|
|
|
|
|
for dependency in cuda_dependencies:
|
|
|
|
|
if dependency in line:
|
|
|
|
|
to_preload.append(line)
|
|
|
|
|
args.extend(['--remove-needed', line])
|
|
|
|
|
args.append(dest)
|
|
|
|
|
if len(to_preload) > 0:
|
|
|
|
|
subprocess.run(args, check=True, stdout=subprocess.PIPE)
|
|
|
|
|
self._rewrite_ld_preload(to_preload)
|
|
|
|
|
_bdist_wheel.run(self)
|
2020-05-18 16:41:00 +00:00
|
|
|
if is_manylinux:
|
2019-06-27 22:45:06 +00:00
|
|
|
file = glob(path.join(self.dist_dir, '*linux*.whl'))[0]
|
2019-10-09 16:23:00 +00:00
|
|
|
logger.info('repairing %s for manylinux1', file)
|
2019-06-27 22:45:06 +00:00
|
|
|
try:
|
2019-10-11 01:31:24 +00:00
|
|
|
subprocess.run(['auditwheel', 'repair', '-w', self.dist_dir, file], check=True, stdout=subprocess.PIPE)
|
2019-06-27 22:45:06 +00:00
|
|
|
finally:
|
|
|
|
|
logger.info('removing %s', file)
|
|
|
|
|
remove(file)
|
|
|
|
|
|
2019-11-27 21:03:23 +00:00
|
|
|
except ImportError as error:
|
|
|
|
|
print("Error importing dependencies:")
|
|
|
|
|
print(error)
|
2018-11-20 00:48:22 +00:00
|
|
|
bdist_wheel = None
|
|
|
|
|
|
|
|
|
|
# Additional binaries
|
2018-11-29 04:01:21 +00:00
|
|
|
if platform.system() == 'Linux':
|
2020-08-17 16:40:31 +00:00
|
|
|
libs = ['onnxruntime_pybind11_state.so', 'libdnnl.so.1', 'libmklml_intel.so', 'libmklml_gnu.so', 'libiomp5.so', 'mimalloc.so']
|
2020-08-11 04:17:16 +00:00
|
|
|
# DNNL & TensorRT EPs are built as shared libs
|
|
|
|
|
libs.extend(['libonnxruntime_providers_shared.so'])
|
2020-05-09 00:11:29 +00:00
|
|
|
libs.extend(['libonnxruntime_providers_dnnl.so'])
|
2020-08-11 04:17:16 +00:00
|
|
|
libs.extend(['libonnxruntime_providers_tensorrt.so'])
|
2019-04-21 00:02:35 +00:00
|
|
|
# nGraph Libs
|
2019-12-27 13:40:01 +00:00
|
|
|
libs.extend(['libngraph.so', 'libcodegen.so', 'libcpu_backend.so', 'libmkldnn.so', 'libtbb_debug.so', 'libtbb_debug.so.2', 'libtbb.so', 'libtbb.so.2'])
|
2020-04-24 11:06:02 +00:00
|
|
|
# OpenVINO Libs
|
|
|
|
|
if package_name == 'onnxruntime-openvino':
|
|
|
|
|
if platform.system() == 'Linux':
|
|
|
|
|
libs.extend(['libovep_ngraph.so'])
|
2019-09-05 15:50:48 +00:00
|
|
|
# Nuphar Libs
|
2019-09-30 17:39:02 +00:00
|
|
|
libs.extend(['libtvm.so.0.5.1'])
|
2019-10-08 19:02:45 +00:00
|
|
|
if nightly_build:
|
|
|
|
|
libs.extend(['libonnxruntime_pywrapper.so'])
|
2018-11-29 04:01:21 +00:00
|
|
|
elif platform.system() == "Darwin":
|
2019-12-03 15:34:23 +00:00
|
|
|
libs = ['onnxruntime_pybind11_state.so', 'libdnnl.1.dylib', 'mimalloc.so'] # TODO add libmklml and libiomp5 later.
|
2020-08-11 04:17:16 +00:00
|
|
|
# DNNL & TensorRT EPs are built as shared libs
|
|
|
|
|
libs.extend(['libonnxruntime_providers_shared.dylib'])
|
2020-05-09 00:11:29 +00:00
|
|
|
libs.extend(['libonnxruntime_providers_dnnl.dylib'])
|
2020-08-11 04:17:16 +00:00
|
|
|
libs.extend(['libonnxruntime_providers_tensorrt.dylib'])
|
2019-10-08 19:02:45 +00:00
|
|
|
if nightly_build:
|
|
|
|
|
libs.extend(['libonnxruntime_pywrapper.dylib'])
|
2018-11-20 00:48:22 +00:00
|
|
|
else:
|
2019-12-03 15:34:23 +00:00
|
|
|
libs = ['onnxruntime_pybind11_state.pyd', 'dnnl.dll', 'mklml.dll', 'libiomp5md.dll']
|
2020-08-11 04:17:16 +00:00
|
|
|
# DNNL & TensorRT EPs are built as shared libs
|
2020-08-13 22:24:44 +00:00
|
|
|
libs.extend(['onnxruntime_providers_shared.dll'])
|
2020-05-09 00:11:29 +00:00
|
|
|
libs.extend(['onnxruntime_providers_dnnl.dll'])
|
2020-08-11 04:17:16 +00:00
|
|
|
libs.extend(['onnxruntime_providers_tensorrt.dll'])
|
|
|
|
|
# nGraph Libs
|
2019-09-14 00:12:48 +00:00
|
|
|
libs.extend(['ngraph.dll', 'cpu_backend.dll', 'tbb.dll', 'mimalloc-override.dll', 'mimalloc-redirect.dll', 'mimalloc-redirect32.dll'])
|
2020-09-08 21:34:09 +00:00
|
|
|
# DirectML Libs
|
|
|
|
|
libs.extend(['directml.dll'])
|
2019-09-05 15:50:48 +00:00
|
|
|
# Nuphar Libs
|
|
|
|
|
libs.extend(['tvm.dll'])
|
2019-10-08 19:02:45 +00:00
|
|
|
if nightly_build:
|
|
|
|
|
libs.extend(['onnxruntime_pywrapper.dll'])
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2020-05-18 16:41:00 +00:00
|
|
|
if is_manylinux:
|
2019-10-08 19:02:45 +00:00
|
|
|
data = ['capi/libonnxruntime_pywrapper.so'] if nightly_build else []
|
2019-06-27 22:45:06 +00:00
|
|
|
ext_modules = [
|
|
|
|
|
Extension(
|
|
|
|
|
'onnxruntime.capi.onnxruntime_pybind11_state',
|
2019-10-09 16:23:00 +00:00
|
|
|
['onnxruntime/capi/onnxruntime_pybind11_state_manylinux1.so'],
|
2019-06-27 22:45:06 +00:00
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
else:
|
|
|
|
|
data = [path.join('capi', x) for x in libs if path.isfile(path.join('onnxruntime', 'capi', x))]
|
|
|
|
|
ext_modules = []
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
# Additional examples
|
2019-07-04 03:10:29 +00:00
|
|
|
examples_names = ["mul_1.onnx", "logreg_iris.onnx", "sigmoid.onnx"]
|
2018-11-20 00:48:22 +00:00
|
|
|
examples = [path.join('datasets', x) for x in examples_names]
|
|
|
|
|
|
|
|
|
|
# Extra files such as EULA and ThirdPartyNotices
|
2019-10-20 14:58:36 +00:00
|
|
|
extra = ["LICENSE", "ThirdPartyNotices.txt", "Privacy.md"]
|
2018-11-20 00:48:22 +00:00
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
README = path.join(getcwd(), "docs/python/README.rst")
|
|
|
|
|
if not path.exists(README):
|
|
|
|
|
this = path.dirname(__file__)
|
|
|
|
|
README = path.join(this, "docs/python/README.rst")
|
|
|
|
|
if not path.exists(README):
|
|
|
|
|
raise FileNotFoundError("Unable to find 'README.rst'")
|
|
|
|
|
with open(README) as f:
|
|
|
|
|
long_description = f.read()
|
|
|
|
|
|
2020-04-23 20:27:22 +00:00
|
|
|
packages = [
|
|
|
|
|
'onnxruntime',
|
|
|
|
|
'onnxruntime.backend',
|
|
|
|
|
'onnxruntime.capi',
|
2020-04-23 20:50:33 +00:00
|
|
|
'onnxruntime.capi.training',
|
2020-04-23 20:27:22 +00:00
|
|
|
'onnxruntime.datasets',
|
|
|
|
|
'onnxruntime.tools',
|
2020-07-09 04:42:53 +00:00
|
|
|
'onnxruntime.quantization',
|
2020-09-01 16:07:46 +00:00
|
|
|
'onnxruntime.quantization.operators',
|
2020-04-23 20:27:22 +00:00
|
|
|
]
|
|
|
|
|
|
Add new PytTrch front-end (#4815)
* Add ORTTrainerOptions class for the new pytorch frontend (#4382)
Add ORTTrainerOptions class and some placeholders
* Add _ORTTrainerModelDesc to perform validation for model description (#4416)
* Add Loss Scaler classes to the new frontend (#4306)
* Add TrainStepInfo used on the new frontend API (#4256)
* Add Optimizer classes to the new frontend (#4280)
* Add LRScheduler implementation (#4357)
* Add basic ORTTrainer API (#4435)
This PR presents the public API for ORTTrainer for the short term
development.
It also validates and saves input parameters, which will be used in the
next stages, such as building ONNX model, post processing the model and
configuring the training session
* Add opset_version into ORTTrainerOptions and change type of ORTTrainer.loss_fn (#4592)
* Update ModelDescription and minor fix on ORTTrainer ctor (#4605)
* Update ModelDescription and minor fix on ORTTrainer/ORTTrainerOptions
This PR keeps the public API intact, but changes how model description is stored on the backend
Currently, users creates a dict with two lists of tuples.
One list called 'inputs' and each tuple has the following format tuple(name, shape).
The second list is called 'outputs' and each tuple can be either tuple(name, shape) or tuple(name, shape, is_loss).
With this PR, when this dict is passed in to ORTTrainer, it is fully validated as usual.
However, tuples are internally replaced by namedtuples and all output tuples will have
tuple(name, shape, is_loss) format instead of is_loss being optionally present.
Additionally to that normalization in the internal representation (which eases coding),
two internal methods were created to replace a namedtuple(name, shape) to namedtuple(name, shape, dtype)
or namedtuple(name, shape, is_loss, dtype) dependeing whether the tuple is an input or output.
This is necessary as ORTTRainer finds out data types of each input/output during model export to onnx.
Finally, a minor fix was done on ORTTrainer. It could initialize ORTTrainerOptions incorrectly when options=None
* Rename input name for test
* Add ONNX Model Export to New Frontend (#4612)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
* Create training session + minor improvements (#4668)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
* Save ONNX model in file (#4671)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
* Add eval step (#4674)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
* Add train_step (#4677)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
* Add LR Scheduler (#4694)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
* Add deterministic compute tests (#4716)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
* Add legacy vs experimental ORTTrainer accuracy comparison (#4727)
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
* Add Mixed precision/LossScaler + several fixes (#4739)
Additionally to the mixed precision/loss scaler code, this PR includes:
* Fix CUDA training
* Add optimization_step into TrainStepInfo class
* Refactor LRSCheduler to use optimization_step instead of step
* Updated several default values at ORTTrainerOptions
* Add initial Gradient Accumulation supported. Untested
* Fix ONNX model post processing
* Refactor unit tests
* Add ONNX BERT example + minor fixes (#4757)
* Fix training issue when passing ONNX file into ORTTrainer
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
* Add Dynamic Shape support (#4758)
* Update DeepSpeed Zero Stage option to a separate option group (#4772)
* Add support to fetches (#4777)
* Add Gradient Accumulation Steps support (#4793)
* Fix Dynamic Axes feature and add unit test (#4795)
* Add frozen weights test (#4807)
* Move new pytorch front-end to 'experimental' namespace (#4814)
* Fix build
Co-authored-by: Rayan-Krishnan <rayankrishnan@live.com>
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
2020-08-17 16:45:25 +00:00
|
|
|
# TODO: thiagofc: Temporary 'experimental' namespace for new PyTorch front-end
|
|
|
|
|
if '--enable_training' in sys.argv:
|
|
|
|
|
packages.extend(['onnxruntime.experimental',
|
|
|
|
|
'onnxruntime.experimental.amp',
|
|
|
|
|
'onnxruntime.experimental.optim'])
|
|
|
|
|
sys.argv.remove('--enable_training')
|
|
|
|
|
|
2020-04-23 20:27:22 +00:00
|
|
|
package_data = {}
|
|
|
|
|
data_files = []
|
|
|
|
|
|
|
|
|
|
if package_name == 'onnxruntime-nuphar':
|
|
|
|
|
packages += ["onnxruntime.nuphar"]
|
|
|
|
|
extra += [path.join('nuphar', 'NUPHAR_CACHE_VERSION')]
|
|
|
|
|
|
|
|
|
|
if featurizers_build:
|
|
|
|
|
# Copy the featurizer data from its current directory into the onnx runtime directory so that the
|
|
|
|
|
# content can be included as module data.
|
2020-04-24 22:19:15 +00:00
|
|
|
|
|
|
|
|
# Apparently, the root_dir is different based on how the script is invoked
|
|
|
|
|
source_root_dir = None
|
|
|
|
|
dest_root_dir = None
|
|
|
|
|
|
|
|
|
|
for potential_source_prefix, potential_dest_prefix in [
|
|
|
|
|
(getcwd(), getcwd()),
|
|
|
|
|
(path.dirname(__file__), path.dirname(__file__)),
|
|
|
|
|
(path.join(getcwd(), ".."), getcwd()),
|
|
|
|
|
]:
|
|
|
|
|
potential_dir = path.join(potential_source_prefix, "external", "FeaturizersLibrary", "Data")
|
|
|
|
|
if path.isdir(potential_dir):
|
|
|
|
|
source_root_dir = potential_source_prefix
|
|
|
|
|
dest_root_dir = potential_dest_prefix
|
|
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if source_root_dir is None:
|
|
|
|
|
raise Exception("Unable to find the build root dir")
|
|
|
|
|
|
|
|
|
|
assert dest_root_dir is not None
|
|
|
|
|
|
|
|
|
|
featurizer_source_dir = path.join(source_root_dir, "external", "FeaturizersLibrary", "Data")
|
2020-04-23 20:27:22 +00:00
|
|
|
assert path.isdir(featurizer_source_dir), featurizer_source_dir
|
|
|
|
|
|
2020-04-24 22:19:15 +00:00
|
|
|
featurizer_dest_dir = path.join(dest_root_dir, "onnxruntime", "FeaturizersLibrary", "Data")
|
2020-04-23 20:27:22 +00:00
|
|
|
if path.isdir(featurizer_dest_dir):
|
|
|
|
|
rmtree(featurizer_dest_dir)
|
|
|
|
|
|
|
|
|
|
for item in listdir(featurizer_source_dir):
|
|
|
|
|
this_featurizer_source_fullpath = path.join(featurizer_source_dir)
|
|
|
|
|
assert path.isdir(this_featurizer_source_fullpath), this_featurizer_source_fullpath
|
|
|
|
|
|
|
|
|
|
copytree(this_featurizer_source_fullpath, featurizer_dest_dir)
|
|
|
|
|
|
2020-04-24 22:19:15 +00:00
|
|
|
packages.append("onnxruntime.FeaturizersLibrary.Data.{}".format(item))
|
2020-04-23 20:27:22 +00:00
|
|
|
package_data[packages[-1]] = listdir(path.join(featurizer_dest_dir, item))
|
|
|
|
|
|
|
|
|
|
package_data["onnxruntime"] = data + examples + extra
|
2019-04-12 05:06:18 +00:00
|
|
|
|
2019-03-21 20:44:13 +00:00
|
|
|
version_number = ''
|
|
|
|
|
with open('VERSION_NUMBER') as f:
|
|
|
|
|
version_number = f.readline().strip()
|
2019-04-12 05:06:18 +00:00
|
|
|
if nightly_build:
|
2020-01-02 23:43:40 +00:00
|
|
|
#https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables
|
2020-04-14 16:00:13 +00:00
|
|
|
build_suffix = environ.get('BUILD_BUILDNUMBER')
|
|
|
|
|
if build_suffix is None:
|
2020-01-02 23:43:40 +00:00
|
|
|
#The following line is only for local testing
|
2020-04-14 16:00:13 +00:00
|
|
|
build_suffix = str(datetime.datetime.now().date().strftime("%Y%m%d"))
|
2020-01-02 23:43:40 +00:00
|
|
|
else:
|
2020-04-14 16:00:13 +00:00
|
|
|
build_suffix = build_suffix.replace('.','')
|
|
|
|
|
|
|
|
|
|
version_number = version_number + ".dev" + build_suffix
|
|
|
|
|
|
|
|
|
|
if wheel_name_suffix:
|
|
|
|
|
package_name = "{}_{}".format(package_name, wheel_name_suffix)
|
2018-11-20 00:48:22 +00:00
|
|
|
|
2019-11-27 21:03:23 +00:00
|
|
|
cmd_classes = {}
|
|
|
|
|
if bdist_wheel is not None :
|
|
|
|
|
cmd_classes['bdist_wheel'] = bdist_wheel
|
|
|
|
|
cmd_classes['build_ext'] = build_ext
|
|
|
|
|
|
2020-04-13 22:45:27 +00:00
|
|
|
requirements_path = path.join(getcwd(), "requirements.txt")
|
|
|
|
|
if not path.exists(requirements_path):
|
|
|
|
|
this = path.dirname(__file__)
|
|
|
|
|
requirements_path = path.join(this, "requirements.txt")
|
|
|
|
|
if not path.exists(requirements_path):
|
|
|
|
|
raise FileNotFoundError("Unable to find 'requirements.txt'")
|
|
|
|
|
with open(requirements_path) as f:
|
2020-04-13 01:44:21 +00:00
|
|
|
install_requires = f.read().splitlines()
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
# Setup
|
|
|
|
|
setup(
|
|
|
|
|
name=package_name,
|
2019-03-21 20:44:13 +00:00
|
|
|
version=version_number,
|
2018-12-03 20:55:29 +00:00
|
|
|
description='ONNX Runtime Python bindings',
|
2018-11-20 00:48:22 +00:00
|
|
|
long_description=long_description,
|
|
|
|
|
author='Microsoft Corporation',
|
|
|
|
|
author_email='onnx@microsoft.com',
|
2019-11-27 21:03:23 +00:00
|
|
|
cmdclass=cmd_classes,
|
2018-11-20 00:48:22 +00:00
|
|
|
license="MIT License",
|
2020-04-23 20:27:22 +00:00
|
|
|
packages=packages,
|
2019-06-27 22:45:06 +00:00
|
|
|
ext_modules=ext_modules,
|
2020-04-23 20:27:22 +00:00
|
|
|
package_data=package_data,
|
|
|
|
|
data_files=data_files,
|
2020-04-13 01:44:21 +00:00
|
|
|
install_requires=install_requires,
|
2018-11-20 00:48:22 +00:00
|
|
|
entry_points= {
|
|
|
|
|
'console_scripts': [
|
|
|
|
|
'onnxruntime_test = onnxruntime.tools.onnxruntime_test:main',
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
classifiers=[
|
2019-12-30 22:51:01 +00:00
|
|
|
'Development Status :: 5 - Production/Stable',
|
2018-11-20 00:48:22 +00:00
|
|
|
'Environment :: Console',
|
|
|
|
|
'Intended Audience :: Developers',
|
2019-12-30 22:51:01 +00:00
|
|
|
'License :: OSI Approved :: MIT License',
|
2018-11-20 00:48:22 +00:00
|
|
|
'Operating System :: POSIX :: Linux',
|
2020-06-08 17:27:32 +00:00
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
|
'Operating System :: MacOS',
|
2018-11-20 00:48:22 +00:00
|
|
|
'Programming Language :: Python',
|
|
|
|
|
'Programming Language :: Python :: 3 :: Only',
|
|
|
|
|
'Programming Language :: Python :: 3.5',
|
|
|
|
|
'Programming Language :: Python :: 3.6',
|
|
|
|
|
'Programming Language :: Python :: 3.7'],
|
|
|
|
|
)
|