aboutsummaryrefslogtreecommitdiff
path: root/package/opencv3/opencv3.mk
diff options
context:
space:
mode:
authorGravatar Sasha Shyrokov <alexander-shyrokov@idexx.com>2018-03-06 10:58:10 -0500
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2018-04-01 10:46:16 +0200
commit8ba80282c3bb580c6a45ea114e70acac98fe1690 (patch)
treeb00486fb7fc296aa967af6f8857e86e747cc3564 /package/opencv3/opencv3.mk
parentb757f9aca356824e47ce2de27deb91b1992c0313 (diff)
downloadbuildroot-8ba80282c3bb580c6a45ea114e70acac98fe1690.tar.gz
buildroot-8ba80282c3bb580c6a45ea114e70acac98fe1690.tar.bz2
opencv3: fix Python module build for Python 3.x
When the OpenCV3 Python support is enabled with Python 3.x, it builds properly, and the resulting .so file is built for the target architecture, but its name is wrong: output/target/usr/lib/python3.6/site-packages/cv2.cpython-36m-x86_64-linux-gnu.so This prevents Python 3.x from importing the module: >>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'cv2' In order to fix this, we simply need to pass PKG_PYTHON_DISTUTILS_ENV in the environment. The Python module then gets named: output/target/usr/lib/python3.6/site-packages/cv2.cpython-36m-arm-linux-gnueabi.so And can be imported properly: >>> import cv2 >>> This solution was suggested by Arnout Vandecappelle in https://stackoverflow.com/questions/49059035/buildroot-opencv3-python-package-builds-for-the-wrong-target. With Python 2.x, the module is named just cv2.so so this problem isn't visible. However, for consistency, we also pass PKG_PYTHON_DISTUTILS_ENV when building against Python 2.x, by putting the OPENCV3_CONF_ENV assignment inside the BR2_PACKAGE_OPENCV3_LIB_PYTHON condition, but outside the BR2_PACKAGE_PYTHON3/BR2_PACKAGE_PYTHON condition. Signed-off-by: Sasha Shyrokov <alexander-shyrokov@idexx.com> [Thomas: extend the commit log, apply the solution to Python 2.x.] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'package/opencv3/opencv3.mk')
-rw-r--r--package/opencv3/opencv3.mk1
1 files changed, 1 insertions, 0 deletions
diff --git a/package/opencv3/opencv3.mk b/package/opencv3/opencv3.mk
index cffe66b892..15e4eadfe3 100644
--- a/package/opencv3/opencv3.mk
+++ b/package/opencv3/opencv3.mk
@@ -327,6 +327,7 @@ OPENCV3_CONF_OPTS += \
-DPYTHON3_NUMPY_VERSION=$(PYTHON_NUMPY_VERSION)
OPENCV3_DEPENDENCIES += python3
endif
+OPENCV3_CONF_ENV += $(PKG_PYTHON_DISTUTILS_ENV)
OPENCV3_DEPENDENCIES += python-numpy
else
OPENCV3_CONF_OPTS += \