Skip to content

Commit

Permalink
[PyOV] Migrate wheel building interface to python -m build for main…
Browse files Browse the repository at this point in the history
… OV wheel (openvinotoolkit#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
  • Loading branch information
p-wysocki authored and CuriousPanCake committed Nov 6, 2024
1 parent 301b8b2 commit dcdcc5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/bindings/python/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 8 additions & 25 deletions src/bindings/python/wheel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions src/bindings/python/wheel/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-c ../constraints.txt
setuptools
wheel
build
patchelf; sys_platform == 'linux' and platform_machine == 'x86_64'

0 comments on commit dcdcc5d

Please sign in to comment.