onnxruntime/onnxruntime/python/_pybind_state.py
Changming Sun 925879a8b0
Remove python 3.8 Windows GPU build from python packaging pipeline (#6054)
Revert the last a few changes to get the pipeline back to a normal state.
2020-12-07 10:23:07 -08:00

26 lines
1.4 KiB
Python

# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------
import os
import platform
import warnings
import onnxruntime.capi._ld_preload # noqa: F401
try:
from onnxruntime.capi.onnxruntime_pybind11_state import * # noqa
except ImportError as e:
warnings.warn("Cannot load onnxruntime.capi. Error: '{0}'.".format(str(e)))
# 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
# because the machine might be missing the 2019 VC Runtime but it is not actually needed in that case and the
# import error might actually be due to some other reason.
# TODO: Add a guard against False Positive error message
# 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
if platform.system().lower() == 'windows' and not os.path.isfile('c:\\Windows\\System32\\vcruntime140_1.dll'):
warnings.warn("Unless you have built the wheel using VS 2017, "
"please install the 2019 Visual C++ runtime and then try again")