mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-20 21:40:57 +00:00
* Enable running PEP8 checks via flake8 as part of the build if flake8 is installed. Update scripts in \tools and \onnxruntime\python. Excluding \onnxruntime\python\tools which needs a lot more work to be PEP8 compliant. Also excluding orttraining\tools for the same reason. Install flake8 as part of the static_analysis build task in the Win-CPU CI so the checks are run in one CI build. Update coding standards doc.
26 lines
1.4 KiB
Python
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")
|