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
|
|
|
# --------------------------------------------------------------------------
|
2021-02-21 23:11:28 +00:00
|
|
|
"""
|
|
|
|
|
Ensure that dependencies are available and then load the extension module.
|
|
|
|
|
"""
|
2018-11-20 00:48:22 +00:00
|
|
|
import os
|
2020-05-13 00:07:06 +00:00
|
|
|
import platform
|
2021-09-02 16:54:32 +00:00
|
|
|
import sys
|
2022-03-18 01:56:43 +00:00
|
|
|
import warnings
|
2021-02-21 23:11:28 +00:00
|
|
|
|
|
|
|
|
from . import _ld_preload # noqa: F401
|
|
|
|
|
|
|
|
|
|
if platform.system() == "Windows":
|
|
|
|
|
from . import version_info
|
|
|
|
|
|
2022-03-18 01:56:43 +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, but it may also be found
|
2022-03-18 15:09:16 +00:00
|
|
|
# in some other locations.
|
2022-03-18 01:56:43 +00:00
|
|
|
# TODO, we may want to try to load the VC Runtime dlls instead of checking if the hardcoded file path
|
|
|
|
|
# is valid, and raise ImportError if the load fails
|
2021-02-21 23:11:28 +00:00
|
|
|
if version_info.vs2019 and platform.architecture()[0] == "64bit":
|
2022-03-18 15:09:16 +00:00
|
|
|
system_root = os.getenv("SystemRoot") or "C:\\Windows"
|
|
|
|
|
if not os.path.isfile(os.path.join(system_root, "System32", "vcruntime140_1.dll")):
|
|
|
|
|
warnings.warn("Please install the 2019 Visual C++ runtime and then try again. "
|
|
|
|
|
"If you've installed the runtime in a non-standard location "
|
|
|
|
|
"(other than %SystemRoot%\System32), "
|
|
|
|
|
"make sure it can be found by setting the correct path.")
|
2022-03-18 01:56:43 +00:00
|
|
|
|
2022-08-22 16:40:40 +00:00
|
|
|
@ONNXRUNTIME_IMPORT_PYTORCH_TO_RESOLVE_DLLS@
|
2021-09-02 16:54:32 +00:00
|
|
|
@ONNXRUNTIME_SETDLOPENFLAGS_GLOBAL@
|
2021-02-21 23:11:28 +00:00
|
|
|
from .onnxruntime_pybind11_state import * # noqa
|
2021-09-02 16:54:32 +00:00
|
|
|
@ONNXRUNTIME_SETDLOPENFLAGS_LOCAL@
|