2020-05-14 21:15:06 +00:00
|
|
|
# -------------------------------------------------------------------------
|
2018-11-20 00:48:22 +00:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
# Licensed under the MIT License.
|
2020-05-14 21:15:06 +00:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
|
|
2018-11-20 00:48:22 +00:00
|
|
|
import os
|
2020-05-13 00:07:06 +00:00
|
|
|
import platform
|
2018-11-20 00:48:22 +00:00
|
|
|
import warnings
|
2020-05-14 21:15:06 +00:00
|
|
|
import onnxruntime.capi._ld_preload # noqa: F401
|
2018-11-20 00:48:22 +00:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from onnxruntime.capi.onnxruntime_pybind11_state import * # noqa
|
|
|
|
|
except ImportError as e:
|
2020-05-13 00:07:06 +00:00
|
|
|
warnings.warn("Cannot load onnxruntime.capi. Error: '{0}'.".format(str(e)))
|
2020-05-14 21:15:06 +00:00
|
|
|
|
2020-05-13 00:07:06 +00:00
|
|
|
# If on Windows, check if this import error is caused by the user not installing the 2019 VC Runtime
|
|
|
|
|
# The VC Redist installer usually puts the VC Runtime dlls in the System32 folder
|
|
|
|
|
# This may not always paint the true picture as anyone building from source using VS 2017 might hit this error
|
2020-05-14 21:15:06 +00:00
|
|
|
# because the machine might be missing the 2019 VC Runtime but it is not actually needed in that case and the
|
2020-05-13 00:07:06 +00:00
|
|
|
# import error might actually be due to some other reason.
|
|
|
|
|
# TODO: Add a guard against False Positive error message
|
2020-05-14 21:15:06 +00:00
|
|
|
# As a proxy for checking if the 2019 VC Runtime is installed,
|
|
|
|
|
# we look for a specific dll only shipped with the 2019 VC Runtime
|
2020-12-07 18:23:07 +00:00
|
|
|
if platform.system().lower() == 'windows' and not os.path.isfile('c:\\Windows\\System32\\vcruntime140_1.dll'):
|
2020-05-14 21:15:06 +00:00
|
|
|
warnings.warn("Unless you have built the wheel using VS 2017, "
|
2020-12-07 18:23:07 +00:00
|
|
|
"please install the 2019 Visual C++ runtime and then try again")
|