1
- //! Provides a mechanism for locating the OpenVINO shared libraries installed on a system.
1
+ //! This crate provides a mechanism for locating the OpenVINO files installed on a system.
2
+ //!
3
+ //! OpenVINO can be installed several ways: [from an archive][install-archive], [from an APT
4
+ //! repository][install-apt], [via Python `pip`][install-pip]. The Rust bindings need to be able to:
5
+ //! 1. locate the shared libraries (e.g., `libopenvino_c.so` on Linux) — see [`find`]
6
+ //! 2. locate the plugin configuration file (i.e., `plugins.xml`) — see [`find_plugins_xml`].
7
+ //! These files are located in different locations based on the installation method, so this crate
8
+ //! encodes "how to find" OpenVINO files. This crate's goal is to locate __only the latest version__
9
+ //! of OpenVINO; older versions may continue to be supported on a best-effort basis.
10
+ //!
11
+ //! [install-archive]: https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_from_archive_linux.html
12
+ //! [install-apt]: https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_apt.html
13
+ //! [install-pip]: https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_pip.html
14
+ //!
15
+ //! Problems with the OpenVINO bindings are most likely to be due to "finding" the right files. Both
16
+ //! [`find`] and [`find_plugins_xml`] provide various ways of configuring the search paths, first by
17
+ //! examining _special environment variables_ and then by looking in _known installation locations_.
18
+ //! When [installing from an archive][install-archive], OpenVINO provides a setup script (e.g.,
19
+ //! `source /opt/intel/openvino/setupvars.sh`) that sets these special environment variables. Note
20
+ //! that you may need to have the OpenVINO environment ready both when building (`cargo build`) and
21
+ //! running (e.g., `cargo test`) when the libraries are linked at compile-time (the default). By
22
+ //! using the `runtime-linking` feature, the libraries are only searched for at run-time.
23
+ //!
24
+ //! If you do run into problems, the following chart summarizes some of the known installation
25
+ //! locations of the OpenVINO files as of version `2022.3.0`:
26
+ //!
27
+ //! | Installation Method | Path | Available on | Notes |
28
+ //! | ------------------- | -------------------------------------------------- | --------------------- | -------------------------------- |
29
+ //! | Archive (`.tar.gz`) | `<extracted folder>/runtime/lib/<arch>` | Linux, MacOS | `<arch>`: `intel64,armv7l,arm64` |
30
+ //! | Archive (`.zip`) | `<unzipped folder>/runtime/bin/<arch>/Release` | Windows | `<arch>`: `intel64,armv7l,arm64` |
31
+ //! | PyPI | `<pip install folder>/site-packages/openvino/libs` | Linux, MacOS, Windows | Find install folder with `pip show openvino` |
32
+ //! | DEB | `/usr/lib/x86_64-linux-gnu/openvino-<version>/` | Linux (APT-based) | This path is for plugins; the libraries are one directory above |
33
+ //! | RPM | `/usr/lib64/` | Linux (YUM-based) | |
2
34
3
35
#![ deny( missing_docs) ]
4
36
#![ deny( clippy:: all) ]
@@ -22,11 +54,33 @@ macro_rules! check_and_return {
22
54
} ;
23
55
}
24
56
25
- /// Find the path to an OpenVINO library. This will try:
26
- /// - the `OPENVINO_INSTALL_DIR` environment variable with several subdirectories appended
27
- /// - the `INTEL_OPENVINO_DIR` environment variable with several subdirectories appended
28
- /// - the environment's library path (e.g. `LD_LIBRARY_PATH` in Linux)
29
- /// - OpenVINO's default installation paths for the OS
57
+ /// Find the path to an OpenVINO library.
58
+ ///
59
+ /// Because OpenVINO can be installed in quite a few ways (see module documentation), this function
60
+ /// attempts the difficult and thankless task of locating the installation's shared libraries for
61
+ /// use in the Rust bindings (i.e., [openvino] and [openvino-sys]). It uses observations from
62
+ /// various OpenVINO releases across several operating systems and conversations with the OpenVINO
63
+ /// development team, but it may not perfectly locate the libraries in every environment —
64
+ /// hence the `Option<PathBuf>` return type.
65
+ ///
66
+ /// [openvino]: https://docs.rs/openvino
67
+ /// [openvino-sys]: https://docs.rs/openvino-sys
68
+ ///
69
+ /// This function will probe:
70
+ /// - the `OPENVINO_BUILD_DIR` environment variable with known build subdirectories appended —
71
+ /// this is useful for finding libraries built from source
72
+ /// - the `OPENVINO_INSTALL_DIR`, `INTEL_OPENVINO_DIR`, and `LD_LIBRARY_PATH` (or OS-equivalent)
73
+ /// environment variables with known install subdirectories appended — one of these is set
74
+ /// by a version of OpenVINO's environment script (e.g., `source
75
+ /// /opt/intel/openvino/setupvars.sh`)
76
+ /// - OpenVINO's package installation paths for the OS (e.g., `/usr/lib64`) — this is useful
77
+ /// for DEB or RPM installations
78
+ /// - OpenVINO's documented extract paths — this is useful for users who extract the TAR or
79
+ /// ZIP archive to the default locations or use the Docker images
80
+ ///
81
+ /// The locations above may change over time. As OpenVINO has released new versions, the documented
82
+ /// locations of the shared libraries has changed. New versions of this function will reflect this,
83
+ /// removing older, unused locations over time.
30
84
pub fn find ( library_name : & str ) -> Option < PathBuf > {
31
85
let file = format ! (
32
86
"{}{}{}" ,
@@ -177,11 +231,11 @@ const KNOWN_BUILD_SUBDIRECTORIES: &[&str] = &[
177
231
/// DEB/RPM installations, it is found in a version-suffixed directory beside the OpenVINO libraries
178
232
/// (e.g., `openvino-2022.3.0/plugins.xml`).
179
233
///
180
- /// This function will check :
181
- /// - the `OPENVINO_PLUGINS_XML` environment variable-- this is specific to this library
234
+ /// This function will probe :
235
+ /// - the `OPENVINO_PLUGINS_XML` environment variable — this is specific to this library
182
236
/// - the same directory as the `openvino_c` shared library, as discovered by [find]
183
237
/// - the latest version directory beside the `openvino_c` shared library (i.e.,
184
- /// `openvino-<version>/`)
238
+ /// `openvino-<latest version>/`)
185
239
pub fn find_plugins_xml ( ) -> Option < PathBuf > {
186
240
const FILE_NAME : & str = "plugins.xml" ;
187
241
0 commit comments