Skip to content

Downgrade LIMITED_API_VERSION, if python3 is older than 3.6#24860

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
asmorkalov:as/fix_python_limited_api
Jan 17, 2024
Merged

Downgrade LIMITED_API_VERSION, if python3 is older than 3.6#24860
asmorkalov merged 1 commit intoopencv:4.xfrom
asmorkalov:as/fix_python_limited_api

Conversation

@asmorkalov
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov commented Jan 15, 2024

Fixes #24773 (comment)

force_builders=Win64 OpenCL

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov asmorkalov force-pushed the as/fix_python_limited_api branch from 1045e7a to 5c8df75 Compare January 15, 2024 18:20
if(PYTHON3_LIMITED_API)
set(PYTHON3_LIMITED_API_VERSION "0x03060000" CACHE STRING "Minimal Python version for Limited API")
# set LIMITED API version that corresponds to current python version, if python3 is too old
if(${PYTHON}_VERSION_STRING VERSION_GREATER "3.5.999")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be more readable to use negative condition (+avoid docstring duplication):

set(_default_ver "0x03060000")
if(${PYTHON}_VERSION_STRING VERSION_LESS "3.6")
  # fix for older pythons
  set(_default_ver "0x030${PYTHON3_VERSION_MINOR}0000")
endif()
set(PYTHON3_LIMITED_API_VERSION ${_default_ver} CACHE STRING "Minimal Python version for Limited API")

Copy link
Copy Markdown
Contributor

@mshabunin mshabunin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, except cosmetic comments.
Verified with Ubuntu 16:

--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.5.2)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2)
--     Limited API:                 YES (ver 0x03050000)
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.11.0)
--     install path:                lib/python3.5/site-packages/cv2/python-3

@asmorkalov asmorkalov force-pushed the as/fix_python_limited_api branch from 5c8df75 to d87768b Compare January 16, 2024 06:21
@asmorkalov asmorkalov force-pushed the as/fix_python_limited_api branch 2 times, most recently from b04b307 to 218c4fb Compare January 16, 2024 10:31
@mshabunin
Copy link
Copy Markdown
Contributor

It seems that you've reverted previous cosmetic fix while fixing unrelated change, was it intended?

@asmorkalov asmorkalov force-pushed the as/fix_python_limited_api branch from 218c4fb to 985506c Compare January 17, 2024 10:09
@asmorkalov
Copy link
Copy Markdown
Contributor Author

@mshabunin @opencv-alalek I fixed the issue, please take a look.

@asmorkalov asmorkalov merged commit 9e001d4 into opencv:4.x Jan 17, 2024
@asmorkalov asmorkalov mentioned this pull request Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants