Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyOV] Migrate wheel building interface to `python -m build` for main OV wheel (#27190)

Przemyslaw Wysocki1b0a4cfdbd0b
diff --git a/src/bindings/python/constraints.txt b/src/bindings/python/constraints.txt
index 65ce94d71b3..4e603a41c88 100644
--- a/src/bindings/python/constraints.txt
+++ b/src/bindings/python/constraints.txt
@@ -8,6 +8,7 @@ pytest-html==4.1.1
pytest-timeout==2.3.1
# Python bindings
+build<1.3
py>=1.9.0
pygments>=2.8.1
setuptools>=65.6.1,<75.3.0
diff --git a/src/bindings/python/wheel/CMakeLists.txt b/src/bindings/python/wheel/CMakeLists.txt
index 7d8ebd5256a..72828a155dd 100644
--- a/src/bindings/python/wheel/CMakeLists.txt
+++ b/src/bindings/python/wheel/CMakeLists.txt
@@ -100,31 +100,14 @@ set(openvino_wheel_path "${openvino_wheels_output_dir}/${openvino_wheel_name}")
# create target for openvino.wheel
#
-execute_process(COMMAND ${Python3_EXECUTABLE} -m pip --version
- OUTPUT_VARIABLE pip_version OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-string(REGEX MATCH "pip[ ]+([\\.0-9]*)" pip_version "${pip_version}")
-set(pip_version ${CMAKE_MATCH_1})
-
-if(pip_version VERSION_GREATER_EQUAL 22.0)
- set(wheel_build_command
- ${Python3_EXECUTABLE} -m pip wheel
- --no-deps
- --wheel-dir ${openvino_wheels_output_dir}
- --verbose
- --build-option --build-number=${WHEEL_BUILD}
- --build-option --plat-name=${PLATFORM_TAG}
- "${CMAKE_CURRENT_SOURCE_DIR}")
-else()
- set(wheel_build_command
- ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/setup.py"
- --quiet
- --no-user-cfg
- bdist_wheel
- --dist-dir ${openvino_wheels_output_dir}
- --build-number=${WHEEL_BUILD}
- --plat-name=${PLATFORM_TAG})
-endif()
+# for --config-setting explanation see https://github.com/pypa/setuptools/issues/2491
+set(wheel_build_command
+ ${Python3_EXECUTABLE} -m build "${CMAKE_CURRENT_SOURCE_DIR}"
+ --outdir ${openvino_wheels_output_dir}
+ --config-setting=--build-option=--build-number=${WHEEL_BUILD}
+ --config-setting=--build-option=--plat-name=${PLATFORM_TAG}
+ --config-setting=--quiet
+ --wheel)
add_custom_command(OUTPUT ${openvino_wheel_path}
COMMAND ${setup_py_env} ${wheel_build_command}
diff --git a/src/bindings/python/wheel/requirements-dev.txt b/src/bindings/python/wheel/requirements-dev.txt
index c88d91751eb..a6c2dcbdf8f 100644
--- a/src/bindings/python/wheel/requirements-dev.txt
+++ b/src/bindings/python/wheel/requirements-dev.txt
@@ -1,4 +1,5 @@
-c ../constraints.txt
setuptools
wheel
+build
patchelf; sys_platform == 'linux' and platform_machine == 'x86_64'