From 664dc77078659f8d04aef86ce95d4a8b88f55203 Mon Sep 17 00:00:00 2001 From: Przemyslaw Wysocki Date: Fri, 6 Oct 2023 10:28:27 +0200 Subject: [PATCH] [PyOV] Drop Python 3.7 in OpenVINO Runtime (#19534) * Drop 37 * Fix linter * Minor change * Minor changes * update add_lib_path * Minor changes * Update pypi pages * Update pypi pages * Fix linter * Minor changes --------- Co-authored-by: Anastasia Kuporosova Co-authored-by: Jan Iwaszkiewicz Co-authored-by: Ilya Lavrenov --- .github/github_org_control/configs.py | 4 ++-- .github/workflows/py_checks.yml | 2 +- .../ncc_naming_style/requirements_dev.txt | 1 - scripts/setupvars/setupvars.bat | 2 +- scripts/setupvars/setupvars.sh | 2 +- .../src/compatibility/ngraph/utils/types.py | 6 +++--- .../python/src/openvino/runtime/utils/types.py | 6 +++--- src/bindings/python/src/openvino/utils.py | 5 +---- src/bindings/python/tests/test_graph/test_any.py | 4 ++-- src/bindings/python/tests/test_graph/test_if.py | 2 +- .../python/tests/test_graph/test_loop.py | 2 +- .../tests/test_graph/test_tensor_iterator.py | 2 +- .../python/tests/test_runtime/test_properties.py | 16 ++++++++-------- tools/deployment_manager/deployment_manager.py | 4 ++-- 14 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.github/github_org_control/configs.py b/.github/github_org_control/configs.py index 92ba0a96c2d..872638bb657 100644 --- a/.github/github_org_control/configs.py +++ b/.github/github_org_control/configs.py @@ -14,8 +14,8 @@ import json from pathlib import Path -if sys.version_info[:2] < (3, 7): - raise Exception("Python version must be >= 3.7") +if sys.version_info[:2] < (3, 8): + raise Exception("Python version must be >= 3.8") class ConfigException(Exception): diff --git a/.github/workflows/py_checks.yml b/.github/workflows/py_checks.yml index 2a2a5741754..c97d5167e2b 100644 --- a/.github/workflows/py_checks.yml +++ b/.github/workflows/py_checks.yml @@ -30,7 +30,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: '3.7' + python-version: '3.8' - name: Install dependencies run: python -m pip install -r src/bindings/python/requirements_test.txt diff --git a/cmake/developer_package/ncc_naming_style/requirements_dev.txt b/cmake/developer_package/ncc_naming_style/requirements_dev.txt index d7e1d3f8310..21e3e089b54 100644 --- a/cmake/developer_package/ncc_naming_style/requirements_dev.txt +++ b/cmake/developer_package/ncc_naming_style/requirements_dev.txt @@ -1,4 +1,3 @@ -clang==11.1.0; python_version == '3.7' clang==12.0.1; python_version == '3.8' clang==12.0.1; python_version == '3.9' clang==14.0; python_version == '3.10' diff --git a/scripts/setupvars/setupvars.bat b/scripts/setupvars/setupvars.bat index 9ef50fc88fa..bc5b94e5373 100644 --- a/scripts/setupvars/setupvars.bat +++ b/scripts/setupvars/setupvars.bat @@ -65,7 +65,7 @@ set "PATH=%OPENVINO_LIB_PATHS%;%PATH%" :: Check if Python is installed set PYTHON_VERSION_MAJOR=3 -set MIN_REQUIRED_PYTHON_VERSION_MINOR=7 +set MIN_REQUIRED_PYTHON_VERSION_MINOR=8 set MAX_SUPPORTED_PYTHON_VERSION_MINOR=11 python --version 2>NUL diff --git a/scripts/setupvars/setupvars.sh b/scripts/setupvars/setupvars.sh index 591b25e7bfb..bc5d257d68b 100755 --- a/scripts/setupvars/setupvars.sh +++ b/scripts/setupvars/setupvars.sh @@ -99,7 +99,7 @@ if command -v lsb_release >/dev/null 2>&1; then fi PYTHON_VERSION_MAJOR="3" -MIN_REQUIRED_PYTHON_VERSION_MINOR="7" +MIN_REQUIRED_PYTHON_VERSION_MINOR="8" MAX_SUPPORTED_PYTHON_VERSION_MINOR="11" check_python_version () { diff --git a/src/bindings/python/src/compatibility/ngraph/utils/types.py b/src/bindings/python/src/compatibility/ngraph/utils/types.py index 76d70894a28..9556fe2ccf0 100644 --- a/src/bindings/python/src/compatibility/ngraph/utils/types.py +++ b/src/bindings/python/src/compatibility/ngraph/utils/types.py @@ -105,16 +105,16 @@ def get_dtype(ngraph_type: NgraphType) -> np.dtype: def get_ndarray(data: NumericData) -> np.ndarray: """Wrap data into a numpy ndarray.""" - if type(data) == np.ndarray: + if isinstance(data, np.ndarray): return data return np.array(data) def get_shape(data: NumericData) -> TensorShape: """Return a shape of NumericData.""" - if type(data) == np.ndarray: + if isinstance(data, np.ndarray): return data.shape # type: ignore - elif type(data) == list: + if isinstance(data, list): return [len(data)] # type: ignore return [] diff --git a/src/bindings/python/src/openvino/runtime/utils/types.py b/src/bindings/python/src/openvino/runtime/utils/types.py index a127cb2e17b..5eeeb021a7c 100644 --- a/src/bindings/python/src/openvino/runtime/utils/types.py +++ b/src/bindings/python/src/openvino/runtime/utils/types.py @@ -121,16 +121,16 @@ def get_numpy_ctype(openvino_type: Type) -> type: def get_ndarray(data: NumericData) -> np.ndarray: """Wrap data into a numpy ndarray.""" - if type(data) == np.ndarray: + if isinstance(data, np.ndarray): return data # type: ignore return np.array(data) def get_shape(data: NumericData) -> TensorShape: """Return a shape of NumericData.""" - if type(data) == np.ndarray: + if isinstance(data, np.ndarray): return data.shape # type: ignore - elif type(data) == list: + if isinstance(data, list): return [len(data)] # type: ignore return [] diff --git a/src/bindings/python/src/openvino/utils.py b/src/bindings/python/src/openvino/utils.py index a62418d951f..d2c646ef986 100644 --- a/src/bindings/python/src/openvino/utils.py +++ b/src/bindings/python/src/openvino/utils.py @@ -36,10 +36,7 @@ def _add_openvino_libs_to_search_path() -> None: lib_path = os.path.join(os.path.dirname(__file__), lib) if os.path.isdir(lib_path): # On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH. - if (3, 8) <= sys.version_info: - os.add_dll_directory(os.path.abspath(lib_path)) - else: - os.environ["PATH"] = os.path.abspath(lib_path) + ";" + os.environ["PATH"] + os.add_dll_directory(os.path.abspath(lib_path)) def add_openvino_libs_to_path() -> None: diff --git a/src/bindings/python/tests/test_graph/test_any.py b/src/bindings/python/tests/test_graph/test_any.py index 439b4d5df98..a6ea4fc2f42 100644 --- a/src/bindings/python/tests/test_graph/test_any.py +++ b/src/bindings/python/tests/test_graph/test_any.py @@ -47,8 +47,8 @@ def test_any_dict(value_dict, value_type, data_type): assert isinstance(ovany.value, dict) assert ovany[key] == list(value_dict.values())[0] assert len(ovany.value) == 1 - assert type(ovany.value[key]) == value_type - assert type(list(value_dict.values())[0]) == data_type + assert isinstance(ovany.value[key], value_type) + assert isinstance(list(value_dict.values())[0], data_type) assert ovany.get() == value_dict diff --git a/src/bindings/python/tests/test_graph/test_if.py b/src/bindings/python/tests/test_graph/test_if.py index 7e165342a2c..39068fa29c4 100644 --- a/src/bindings/python/tests/test_graph/test_if.py +++ b/src/bindings/python/tests/test_graph/test_if.py @@ -195,7 +195,7 @@ def test_simple_if_basic(): if_node.set_function(0, then_body) subgraph_func = if_node.get_function(0) - assert type(subgraph_func) == type(then_body) + assert isinstance(subgraph_func, type(then_body)) assert compare_models(subgraph_func, then_body) assert subgraph_func._get_raw_address() == then_body._get_raw_address() diff --git a/src/bindings/python/tests/test_graph/test_loop.py b/src/bindings/python/tests/test_graph/test_loop.py index 9a2fb6fcaf6..235ea917ba5 100644 --- a/src/bindings/python/tests/test_graph/test_loop.py +++ b/src/bindings/python/tests/test_graph/test_loop.py @@ -142,7 +142,7 @@ def test_loop_basic(): subgraph_func = loop.get_function() - assert type(subgraph_func) == type(graph_body) + assert isinstance(subgraph_func, type(graph_body)) assert subgraph_func._get_raw_address() == graph_body._get_raw_address() assert compare_models(subgraph_func, graph_body) assert loop.get_special_body_ports() == body_ports diff --git a/src/bindings/python/tests/test_graph/test_tensor_iterator.py b/src/bindings/python/tests/test_graph/test_tensor_iterator.py index dd58b3da3f4..7dbeecc4c47 100644 --- a/src/bindings/python/tests/test_graph/test_tensor_iterator.py +++ b/src/bindings/python/tests/test_graph/test_tensor_iterator.py @@ -121,7 +121,7 @@ def test_tensor_iterator_basic(): subgraph_func = ti.get_function() - assert type(subgraph_func) == type(graph_body) + assert isinstance(subgraph_func, type(graph_body)) assert compare_models(subgraph_func, graph_body) assert subgraph_func._get_raw_address() == graph_body._get_raw_address() assert ti.get_num_iterations() == 16 diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.py index cb70887fb19..6a76ccb57cb 100644 --- a/src/bindings/python/tests/test_runtime/test_properties.py +++ b/src/bindings/python/tests/test_runtime/test_properties.py @@ -472,7 +472,7 @@ def test_single_property_setting(device): core.set_property(device, streams.num(streams.Num.AUTO)) assert props.streams.Num.AUTO.to_integer() == -1 - assert type(core.get_property(device, streams.num())) == int + assert isinstance(core.get_property(device, streams.num()), int) @pytest.mark.skipif(os.environ.get("TEST_DEVICE", "CPU") != "CPU", reason=f"Cannot run test on device {os.environ.get('TEST_DEVICE')}, Plugin specific test") @@ -539,10 +539,10 @@ def test_core_cpu_properties(properties_to_set): assert core.get_property("CPU", streams.num) == 5 # RO properties - assert type(core.get_property("CPU", props.supported_properties)) == dict - assert type(core.get_property("CPU", props.available_devices)) == list - assert type(core.get_property("CPU", props.optimal_number_of_infer_requests)) == int - assert type(core.get_property("CPU", props.range_for_streams)) == tuple - assert type(core.get_property("CPU", props.range_for_async_infer_requests)) == tuple - assert type(core.get_property("CPU", device.full_name)) == str - assert type(core.get_property("CPU", device.capabilities)) == list + assert isinstance(core.get_property("CPU", props.supported_properties), dict) + assert isinstance(core.get_property("CPU", props.available_devices), list) + assert isinstance(core.get_property("CPU", props.optimal_number_of_infer_requests), int) + assert isinstance(core.get_property("CPU", props.range_for_streams), tuple) + assert isinstance(core.get_property("CPU", props.range_for_async_infer_requests), tuple) + assert isinstance(core.get_property("CPU", device.full_name), str) + assert isinstance(core.get_property("CPU", device.capabilities), list) diff --git a/tools/deployment_manager/deployment_manager.py b/tools/deployment_manager/deployment_manager.py index 9cf07b3286b..7548ceb18f6 100755 --- a/tools/deployment_manager/deployment_manager.py +++ b/tools/deployment_manager/deployment_manager.py @@ -17,8 +17,8 @@ import sys -if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 7): - exit("Python* 3.7 or higher is required to run the Deployment Manager.") +if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 8): + exit("Python* 3.8 or higher is required to run the Deployment Manager.") if __name__ == '__main__': from deployman.main import main