opencv-4.8.1-python3_12-support.patch 1.3 KB

1234567891011121314151617181920212223242526
  1. https://github.com/opencv/opencv/pull/23991
  2. From 00ca8f455e6a5588d905e3a0b268f18ee3fda5dd Mon Sep 17 00:00:00 2001
  3. From: =?UTF-8?q?S=C3=A9rgio=20M=2E=20Basto?= <sergio@serjux.com>
  4. Date: Sun, 1 Oct 2023 16:12:25 +0100
  5. Subject: [PATCH] `numpy.distutils` is removed in numpy 1.26 on Python 3.12.
  6. so we don't use numpy.distutils to get includes dirs of python-numpy
  7. ---
  8. cmake/OpenCVDetectPython.cmake | 2 +-
  9. 1 file changed, 1 insertion(+), 1 deletion(-)
  10. diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
  11. index 88a434185622..d4098ce8e60d 100644
  12. --- a/cmake/OpenCVDetectPython.cmake
  13. +++ b/cmake/OpenCVDetectPython.cmake
  14. @@ -216,7 +216,7 @@ if(NOT ${found})
  15. message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
  16. else()
  17. # Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
  18. - execute_process(COMMAND "${_executable}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))"
  19. + execute_process(COMMAND "${_executable}" -c "import numpy; print(numpy.get_include())"
  20. RESULT_VARIABLE _numpy_process
  21. OUTPUT_VARIABLE _numpy_include_dirs
  22. OUTPUT_STRIP_TRAILING_WHITESPACE)