From 0266f25f9b32cd53fd93e722679f223d61256c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= Date: Fri, 26 Aug 2022 10:21:24 +0200 Subject: [PATCH] [PYTHON] Align versions for subpackages, add get_version method for all subpackages (#12220) --- src/bindings/python/BUILDING.md | 18 ++++++------ src/bindings/python/setup.py | 3 ++ .../python/src/openvino/frontend/__init__.py | 4 ++- .../offline_transformations/__init__.py | 4 ++- .../src/openvino/preprocess/__init__.py | 4 ++- .../python/src/openvino/runtime/__init__.py | 12 ++------ .../python/tests/test_package_versions.py | 29 +++++++++++++++++++ 7 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 src/bindings/python/tests/test_package_versions.py diff --git a/src/bindings/python/BUILDING.md b/src/bindings/python/BUILDING.md index af05c28af02..ffde4b31316 100644 --- a/src/bindings/python/BUILDING.md +++ b/src/bindings/python/BUILDING.md @@ -157,7 +157,7 @@ pip3 install openvino-0.0.0-cp-cp-linux_x86_64.whl ### Prerequisites -In order to build OpenVINO™ and the nGraph Python wheel on Windows, you need to install Microsoft Visual Studio* and Python. +In order to build OpenVINO™ and its Python wheel on Windows, you need to install Microsoft Visual Studio* and Python. Once Python is installed, you also need to install Cython using `pip install cython`. @@ -206,17 +206,17 @@ Set up the OpenVINO™ environment in order to add a module path to `PYTHONPATH` %OPENVINO_BASEDIR%\openvino_dist\setupvars.bat -### Build an nGraph Python Wheel on Windows +### Build a Python Wheel on Windows Build the Python wheel package: - cd "%OPENVINO_BASEDIR%/openvino/ngraph/python" + cd "%OPENVINO_BASEDIR%/openvino/src/bindings/python" python setup.py bdist_wheel -The final wheel should be located in the `ngraph\python\dist` directory. +The final wheel should be located in the `bindings\python\dist` directory. - dir openvino\ngraph\python\dist\ - 10/09/2020 04:06 PM 4,010,943 ngraph_core-0.0.0-cp38-cp38-win_amd64.whl + dir openvino/src/bindings/python/dist/ + 10/09/2020 04:06 PM 4,010,943 openvino-0.0.0.dev0-cp-cp-win_amd64.whl ## Run Tests @@ -228,12 +228,12 @@ You may wish to use a virutualenv for your installation. $ source venv/bin/activate (venv) $ -### Install the nGraph Wheel and Other Requirements +### Install the Wheel and Other Requirements - (venv) $ cd "${OPENVINO_BASEDIR}/openvino/ngraph/python" + (venv) $ cd "${OPENVINO_BASEDIR}/openvino/src/bindings/python" (venv) $ pip3 install -r requirements.txt (venv) $ pip3 install -r requirements_test.txt - (venv) $ pip3 install dist/ngraph_core-0.0.0-cp38-cp38-linux_x86_64.whl + (venv) $ pip3 install dist/openvino-0.0.0.dev0-cp38-cp38-linux_x86_64.whl ### Run Tests diff --git a/src/bindings/python/setup.py b/src/bindings/python/setup.py index 8ec1916456e..f39bee9a1b6 100644 --- a/src/bindings/python/setup.py +++ b/src/bindings/python/setup.py @@ -41,7 +41,9 @@ packages = [ "ngraph.impl.passes", "openvino", "openvino.frontend", + "openvino.preprocess", "openvino.offline_transformations", + "openvino.runtime", "openvino.runtime.opset1", "openvino.runtime.opset2", "openvino.runtime.opset3", @@ -50,6 +52,7 @@ packages = [ "openvino.runtime.opset6", "openvino.runtime.opset7", "openvino.runtime.opset8", + "openvino.runtime.opset9", "openvino.runtime.utils", "openvino.runtime.op", "openvino.runtime.op.util", diff --git a/src/bindings/python/src/openvino/frontend/__init__.py b/src/bindings/python/src/openvino/frontend/__init__.py index 90f6a240e3a..bcb3f5aefed 100644 --- a/src/bindings/python/src/openvino/frontend/__init__.py +++ b/src/bindings/python/src/openvino/frontend/__init__.py @@ -9,9 +9,11 @@ Low level wrappers for the FrontEnd C++ API. # flake8: noqa from openvino.utils import add_openvino_libs_to_path - add_openvino_libs_to_path() +from openvino.pyopenvino import get_version +__version__ = get_version() + # main classes from openvino.pyopenvino import FrontEndManager from openvino.pyopenvino import FrontEnd diff --git a/src/bindings/python/src/openvino/offline_transformations/__init__.py b/src/bindings/python/src/openvino/offline_transformations/__init__.py index a18e88eb8b0..b8d105a5392 100644 --- a/src/bindings/python/src/openvino/offline_transformations/__init__.py +++ b/src/bindings/python/src/openvino/offline_transformations/__init__.py @@ -5,9 +5,11 @@ # flake8: noqa from openvino.utils import add_openvino_libs_to_path - add_openvino_libs_to_path() +from openvino.pyopenvino import get_version +__version__ = get_version() + from openvino.pyopenvino.offline_transformations import apply_moc_transformations from openvino.pyopenvino.offline_transformations import apply_moc_legacy_transformations from openvino.pyopenvino.offline_transformations import apply_pot_transformations diff --git a/src/bindings/python/src/openvino/preprocess/__init__.py b/src/bindings/python/src/openvino/preprocess/__init__.py index 5f391f30fad..f8b0cc1a264 100644 --- a/src/bindings/python/src/openvino/preprocess/__init__.py +++ b/src/bindings/python/src/openvino/preprocess/__init__.py @@ -9,9 +9,11 @@ Low level wrappers for the PrePostProcessing C++ API. # flake8: noqa from openvino.utils import add_openvino_libs_to_path - add_openvino_libs_to_path() +from openvino.pyopenvino import get_version +__version__ = get_version() + # main classes from openvino.pyopenvino.preprocess import InputInfo from openvino.pyopenvino.preprocess import OutputInfo diff --git a/src/bindings/python/src/openvino/runtime/__init__.py b/src/bindings/python/src/openvino/runtime/__init__.py index 5d04e168372..de0d002ab9f 100644 --- a/src/bindings/python/src/openvino/runtime/__init__.py +++ b/src/bindings/python/src/openvino/runtime/__init__.py @@ -6,16 +6,11 @@ # noqa: F401 from openvino.utils import add_openvino_libs_to_path -from pkg_resources import get_distribution, DistributionNotFound - - -try: - __version__ = get_distribution("openvino-core").version -except DistributionNotFound: - __version__ = "0.0.0.dev0" - add_openvino_libs_to_path() +from openvino.pyopenvino import get_version +__version__ = get_version() + # Openvino pybind bindings and python extended classes from openvino.pyopenvino import Dimension from openvino.pyopenvino import Model @@ -44,7 +39,6 @@ from openvino.pyopenvino import Version from openvino.pyopenvino import Tensor from openvino.pyopenvino import Extension from openvino.pyopenvino import ProfilingInfo -from openvino.pyopenvino import get_version from openvino.pyopenvino import get_batch from openvino.pyopenvino import set_batch from openvino.pyopenvino import serialize diff --git a/src/bindings/python/tests/test_package_versions.py b/src/bindings/python/tests/test_package_versions.py new file mode 100644 index 00000000000..115538efc45 --- /dev/null +++ b/src/bindings/python/tests/test_package_versions.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2018-2022 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +import openvino.preprocess as ov_pre +import openvino.runtime as ov_run +import openvino.frontend as ov_front +import openvino.offline_transformations as ov_off_transf +import openvino.pyopenvino as ov_py + + +def test_get_version_match(): + packages = [ov_run, ov_front, ov_pre, ov_off_transf, ov_py] + versions = set() + + for package in packages: + versions.add(package.get_version()) + + assert len(versions) == 1 + + +def test_dunder_version_match(): + packages = [ov_run, ov_front, ov_pre, ov_off_transf] + versions = set() + + for package in packages: + versions.add(package.__version__) + + assert len(versions) == 1