Support python3-opencv
[platform/upstream/opencv.git] / packaging / opencv.spec
index 28a0618..2c0c875 100644 (file)
@@ -1,11 +1,17 @@
 Name: opencv
 Summary: OpenCV library
 Version: 4.5.0
-Release: 0
+Release: 1
 Group: Development/Libraries
 License: Apache-2.0 and BSD-3-Clause
 Source0: %{name}-%{version}.tar.gz
 Source100: opencv-contrib-4.5.0.tar.gz
+# In cmake/OpenCVDetectPython.cmake, python packages are installed
+# in lib/ regardless of i586, armv7l, x86_64, aarch64
+# So, this patch installs the python packages in:
+# lib64/ if x86_64 or aarch64
+# lib/ if i586 or armv7l
+Source1001: 1001-TIZEN-OPENCV-PYTHON3-LIB64-PATH.patch
 
 BuildRequires:  cmake
 BuildRequires:  pkg-config
@@ -19,7 +25,9 @@ BuildRequires:  libavutil-devel
 BuildRequires:  libavcodec-devel
 BuildRequires:  libavformat-devel
 BuildRequires:  libswscale-devel
-
+#support python3
+BuildRequires:  python3-devel
+BuildRequires:  python3-numpy-devel
 
 Requires(post):  /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
@@ -35,10 +43,21 @@ Requires:    %{name} = %{version}-%{release}
 %description devel
 The Open Computer Vision Library (Dev) includes various algorithms for computer vision problems.
 
+%package -n python3-opencv
+Summary:    OpenCV Python3 Library
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description -n python3-opencv
+The Open Computer Vision Library (Python3) includes various algorithms for computre vision problems.
+
 %prep
 %setup -q
 %setup -q -T -D -a 100
 
+cp %{SOURCE1001} .
+patch -p1 < %{SOURCE1001}
+
 %build
 %ifarch aarch64
 ARCH=aarch64
@@ -80,7 +99,7 @@ cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
        -DBUILD_opencv_objdetect=ON \
        -DBUILD_opencv_photo=ON \
        -DBUILD_opencv_python2=OFF \
-       -DBUILD_opencv_python3=OFF \
+       -DBUILD_opencv_python3=ON \
        -DBUILD_opencv_shape=OFF \
        -DBUILD_opencv_stitching=OFF \
        -DBUILD_opencv_superres=OFF \
@@ -89,7 +108,6 @@ cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
        -DBUILD_opencv_videoio=ON \
        -DBUILD_opencv_videostab=OFF \
        -DBUILD_opencv_world=OFF \
-       -DBUILD_opencv_python=OFF \
        -DBUILD_opencv_viz=OFF \
        -DOPENCV_EXTRA_MODULES_PATH=../opencv-contrib/modules \
        -DBUILD_opencv_aruco=OFF \
@@ -283,6 +301,10 @@ fi
 %exclude /usr/share/opencv4/lbpcascades/*silverware*
 %exclude /usr/share/opencv4/*.supp
 
+%files -n python3-opencv
+%{python3_sitearch}/cv2/*.py
+%{python3_sitearch}/cv2/*/*.so
+
 %files devel
 /usr/include/*
 %{_libdir}/pkgconfig/*.pc