Conversation
Import NumPy before OpenCV in platform.py to prevent import/segfault issues (FreeBSD & cross-platform safety)
|
Thanks for letting me know, I would be happy to upstream to avoid needing a patch! I can coordinate a new Python release with the fix as soon as possible (this should not affect the Windows distribution). |
There was a problem hiding this comment.
I'm curious, has this caused any actual issues? We also import cv2 in __init__.py before this code has run:
PySceneDetect/scenedetect/__init__.py
Lines 21 to 30 in ad9d35d
That being said, if this does need to be done, I think the patch was applied incorrectly since it looks like numpy is imported after OpenCV is.
|
Hi! Thanks for taking a look. I have recently started maintaining this port, and I thought this was the reason why the patch was added earlier. Since OpenCV is being loaded earlier (as shown in the code), I will remove the patch as well. If any of the users reports any issues, we can revisit here again. |
Thank you! Feel free to reach out if you encounter any issues after removing the patch, happy to coordinate any fixes. Cheers. |
Import NumPy before OpenCV in platform.py to prevent import/segfault issues (FreeBSD & cross-platform safety)
On FreeBSD, importing OpenCV (cv2) before NumPy can blow up with errors like “numpy.core.multiarray failed to import” or even a segfault. The reason is that OpenCV relies on NumPy under the hood, so if NumPy hasn’t been loaded yet, things can go wrong.
FreeBSD Ports Tree already carries a patch that imports numpy to prevent this. Thought it would not be a bad idea to upstream this
https://github.com/freebsd/freebsd-ports/blob/main/multimedia/py-scenedetect/files/patch-scenedetect_platform.py