opencv-4.9.0-drop-python2-detection.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From: Paul Zander <negril.nx+gentoo@gmail.com>
  2. python-2 is dead, don't check for it.
  3. diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
  4. index a6aacb4..d893486 100644
  5. --- a/cmake/OpenCVDetectPython.cmake
  6. +++ b/cmake/OpenCVDetectPython.cmake
  7. @@ -85,11 +85,7 @@ if(NOT ${found})
  8. endif()
  9. ocv_clear_vars(PYTHONINTERP_FOUND PYTHON_EXECUTABLE PYTHON_VERSION_STRING PYTHON_VERSION_MAJOR PYTHON_VERSION_MINOR PYTHON_VERSION_PATCH)
  10. if(NOT CMAKE_VERSION VERSION_LESS "3.12")
  11. - if(_python_version_major STREQUAL "2")
  12. - set(__PYTHON_PREFIX Python2)
  13. - else()
  14. - set(__PYTHON_PREFIX Python3)
  15. - endif()
  16. + set(__PYTHON_PREFIX Python3)
  17. find_host_package(${__PYTHON_PREFIX} "${preferred_version}" COMPONENTS Interpreter)
  18. if(${__PYTHON_PREFIX}_EXECUTABLE)
  19. set(PYTHON_EXECUTABLE "${${__PYTHON_PREFIX}_EXECUTABLE}")
  20. @@ -208,9 +204,6 @@ if(NOT ${found})
  21. if(CMAKE_CROSSCOMPILING)
  22. message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)")
  23. message(STATUS "If you want to enable Python/Numpy support, set the following variables:")
  24. - message(STATUS " PYTHON2_INCLUDE_PATH")
  25. - message(STATUS " PYTHON2_LIBRARIES (optional on Unix-like systems)")
  26. - message(STATUS " PYTHON2_NUMPY_INCLUDE_DIRS")
  27. message(STATUS " PYTHON3_INCLUDE_PATH")
  28. message(STATUS " PYTHON3_LIBRARIES (optional on Unix-like systems)")
  29. message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
  30. @@ -268,20 +261,6 @@ if(OPENCV_PYTHON_SKIP_DETECTION)
  31. return()
  32. endif()
  33. -ocv_check_environment_variables(OPENCV_ENABLE_PYTHON2)
  34. -ocv_check_environment_variables(PYTHON2_EXECUTABLE)
  35. -if((OPENCV_ENABLE_PYTHON2 OR PYTHON2_EXECUTABLE OR BUILD_opencv_python2)
  36. - AND NOT OPENCV_PYTHON2_SKIP_DETECTION
  37. -)
  38. - find_python("" "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
  39. - PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
  40. - PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
  41. - PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY
  42. - PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH
  43. - PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH
  44. - PYTHON2_NUMPY_INCLUDE_DIRS PYTHON2_NUMPY_VERSION)
  45. -endif()
  46. -
  47. option(OPENCV_PYTHON3_VERSION "Python3 version" "")
  48. find_python("${OPENCV_PYTHON3_VERSION}" "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR
  49. PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING
  50. @@ -294,12 +273,8 @@ find_python("${OPENCV_PYTHON3_VERSION}" "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYT
  51. if(PYTHON_DEFAULT_EXECUTABLE)
  52. set(PYTHON_DEFAULT_AVAILABLE "TRUE")
  53. -elseif(PYTHON2_EXECUTABLE AND PYTHON2INTERP_FOUND)
  54. - # Use Python 2 as default Python interpreter
  55. - set(PYTHON_DEFAULT_AVAILABLE "TRUE")
  56. - set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}")
  57. elseif(PYTHON3_EXECUTABLE AND PYTHON3INTERP_FOUND)
  58. - # Use Python 3 as fallback Python interpreter (if there is no Python 2)
  59. + # Use Python 3 as Python interpreter (there is no Python 2)
  60. set(PYTHON_DEFAULT_AVAILABLE "TRUE")
  61. set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}")
  62. endif()