From 19a9c9b97e87567d4e2f1f99cacbb149800d16fb Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Sat, 9 May 2026 20:47:59 +0300 Subject: [PATCH 1/2] fix: add explicit NumPy version constraints for Python 3.13+ and 3.14 - Changed install_requires to specify minimum numpy versions per Python version: - Python 3.9-3.12: numpy>=2.0.2 - Python 3.13: numpy>=2.1.3 - Python 3.14+: numpy>=2.3.0 - This fixes NumPy 2.x ABI compatibility issue where wheels compiled against NumPy 1.x fail at runtime with NumPy 2.x Fixes opencv/opencv-python#1201 --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d0c57b48..952f37ce 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,9 @@ def main(): install_requires = [ 'numpy<2.0; python_version<"3.9"', - 'numpy>=2; python_version>="3.9"', + 'numpy>=2.0.2; python_version>="3.9" and python_version<"3.13"', + 'numpy>=2.1.3; python_version>="3.13" and python_version<"3.14"', + 'numpy>=2.3.0; python_version>="3.14"', ] python_version = cmaker.CMaker.get_python_version() From 4e4505a2774a50ce1ad5a46b7673f71257d77265 Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Sat, 9 May 2026 21:02:40 +0300 Subject: [PATCH 2/2] docs: add multiprocessing fork safety warning Add documentation about OpenCV not being fork-safe and the 'corrupted double-linked list' issue that can occur when using cv2 functions after fork(). Fixes: #1166 --- scripts/__init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/__init__.py b/scripts/__init__.py index 587a42bf..c7086c07 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1,3 +1,22 @@ +""" +OpenCV Python bindings + +This module provides Python bindings for OpenCV. + +Important notes for multiprocessing: +- OpenCV is not fork-safe. Using cv2 functions after fork() can cause + "corrupted double-linked list" errors and memory corruption. +- If you use multiprocessing with fork (the default on Linux/macOS), + either: + 1. Use spawn mode: multiprocessing.set_start_method('spawn') + 2. Call cv2.setNumThreads(0) in each worker before using cv2 +- See: https://github.com/opencv/opencv-python/issues/1166 +""" + +import os +import sys +import warnings + PYTHON_EXTENSIONS_PATHS = [ LOADER_DIR ] + PYTHON_EXTENSIONS_PATHS @@ -21,4 +40,4 @@ if sys.platform.startswith("linux") and ci_and_not_headless: os.environ["QT_QPA_FONTDIR"] = os.path.join( os.path.dirname(os.path.abspath(__file__)), "qt", "fonts" - ) + ) \ No newline at end of file