File: add_openvino_win_libs.py

package info (click to toggle)
onnxruntime 1.23.2%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 340,756 kB
  • sloc: cpp: 3,222,136; python: 188,267; ansic: 114,318; asm: 37,927; cs: 36,849; java: 10,962; javascript: 6,811; pascal: 4,126; sh: 2,996; xml: 705; objc: 281; makefile: 67
file content (35 lines) | stat: -rw-r--r-- 1,637 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright (C) 2022-2023 Intel Corporation
# Licensed under the MIT License

import os
import site
import sys


def add_openvino_libs_to_path() -> None:
    """Adds OpenVINO libraries to the PATH environment variable on Windows."""
    if sys.platform == "win32":
        # Installer, pip installs openvino dlls to the different directories
        # and those paths need to be visible to the openvino-ep modules
        #
        # If you're using a custom installation of openvino,
        # add the location of openvino dlls to your system PATH.
        openvino_libs = []
        # looking for the libs in the pip installation path.
        if os.path.isdir(os.path.join(site.getsitepackages()[1], "openvino", "libs")):
            openvino_libs.append(os.path.join(site.getsitepackages()[1], "openvino", "libs"))
        else:
            # setupvars.bat script set all libs paths to OPENVINO_LIB_PATHS environment variable.
            openvino_libs_installer = os.getenv("OPENVINO_LIB_PATHS")
            if openvino_libs_installer:
                openvino_libs.extend(openvino_libs_installer.split(";"))
            else:
                sys.exit(
                    "Error: Please set the OPENVINO_LIB_PATHS environment variable. "
                    "If you use an install package, please, run setupvars.bat"
                )
        for lib in openvino_libs:
            lib_path = os.path.join(os.path.dirname(__file__), lib)
            if os.path.isdir(lib_path):
                os.environ["PATH"] = os.path.abspath(lib_path) + ";" + os.environ["PATH"]
                os.add_dll_directory(os.path.abspath(lib_path))