Skip to content

Commit 1b0a4cf

Browse files
authored
[PyOV] Migrate wheel building interface to python -m build for main OV wheel (#27190)
### Details: - Direct `setup.py` calls are deprecated and using `build` package instead is recommended ([source](https://packaging.python.org/en/latest/discussions/setup-py-deprecated/)) - PR simplifies wheel building by using `python -m build` for all pip versions - A new build dependency has been added since `build` is not supplied with Python - `setuptools` (our current build backend) is not integrated well with `config_settings`, which leads to an unfriendly looking workaround for passing build settings (more details in pypa/setuptools#2491) - Migrations for other wheels will be delivered in separate PRs as they have a different scope (for example `openvino_dev` also requires migration from using `pkg_resources` package) ### Tickets: - CVS-155190
1 parent 75bbdf0 commit 1b0a4cf

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

src/bindings/python/constraints.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pytest-html==4.1.1
88
pytest-timeout==2.3.1
99

1010
# Python bindings
11+
build<1.3
1112
py>=1.9.0
1213
pygments>=2.8.1
1314
setuptools>=65.6.1,<75.3.0

src/bindings/python/wheel/CMakeLists.txt

+8-25
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,14 @@ set(openvino_wheel_path "${openvino_wheels_output_dir}/${openvino_wheel_name}")
100100
# create target for openvino.wheel
101101
#
102102

103-
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip --version
104-
OUTPUT_VARIABLE pip_version OUTPUT_STRIP_TRAILING_WHITESPACE)
105-
106-
string(REGEX MATCH "pip[ ]+([\\.0-9]*)" pip_version "${pip_version}")
107-
set(pip_version ${CMAKE_MATCH_1})
108-
109-
if(pip_version VERSION_GREATER_EQUAL 22.0)
110-
set(wheel_build_command
111-
${Python3_EXECUTABLE} -m pip wheel
112-
--no-deps
113-
--wheel-dir ${openvino_wheels_output_dir}
114-
--verbose
115-
--build-option --build-number=${WHEEL_BUILD}
116-
--build-option --plat-name=${PLATFORM_TAG}
117-
"${CMAKE_CURRENT_SOURCE_DIR}")
118-
else()
119-
set(wheel_build_command
120-
${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/setup.py"
121-
--quiet
122-
--no-user-cfg
123-
bdist_wheel
124-
--dist-dir ${openvino_wheels_output_dir}
125-
--build-number=${WHEEL_BUILD}
126-
--plat-name=${PLATFORM_TAG})
127-
endif()
103+
# for --config-setting explanation see https://github.com/pypa/setuptools/issues/2491
104+
set(wheel_build_command
105+
${Python3_EXECUTABLE} -m build "${CMAKE_CURRENT_SOURCE_DIR}"
106+
--outdir ${openvino_wheels_output_dir}
107+
--config-setting=--build-option=--build-number=${WHEEL_BUILD}
108+
--config-setting=--build-option=--plat-name=${PLATFORM_TAG}
109+
--config-setting=--quiet
110+
--wheel)
128111

129112
add_custom_command(OUTPUT ${openvino_wheel_path}
130113
COMMAND ${setup_py_env} ${wheel_build_command}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-c ../constraints.txt
22
setuptools
33
wheel
4+
build
45
patchelf; sys_platform == 'linux' and platform_machine == 'x86_64'

0 commit comments

Comments
 (0)