Skip to content

Commit

Permalink
opencv: fix build with numpy on Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ahesford committed Oct 7, 2023
1 parent 2de3701 commit e96ec94
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions srcpkgs/opencv/patches/python3.12.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From 00ca8f455e6a5588d905e3a0b268f18ee3fda5dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9rgio=20M=2E=20Basto?= <[email protected]>
Date: Sun, 1 Oct 2023 16:12:25 +0100
Subject: [PATCH] `numpy.distutils` is removed in numpy 1.26 on Python 3.12.

so we don't use numpy.distutils to get includes dirs of python-numpy
---
cmake/OpenCVDetectPython.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
index 88a434185622..d4098ce8e60d 100644
--- a/cmake/OpenCVDetectPython.cmake
+++ b/cmake/OpenCVDetectPython.cmake
@@ -216,7 +216,7 @@ if(NOT ${found})
message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS")
else()
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
- 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()))"
+ execute_process(COMMAND "${_executable}" -c "import numpy; print(numpy.get_include())"
RESULT_VARIABLE _numpy_process
OUTPUT_VARIABLE _numpy_include_dirs
OUTPUT_STRIP_TRAILING_WHITESPACE)

0 comments on commit e96ec94

Please sign in to comment.