Re: opencv drop py2 (was Re: [update] Python 3.8.7)

2020-12-30 Thread Rafael Sadowski
On Wed Dec 30, 2020 at 01:21:54PM +, Stuart Henderson wrote:
> > > > > sadly this will break packaging for all python ports with shared
> > > > > libraries to the change they made for shared libraries :-(
> > > > 
> > > > 3.9 will have the same in the next release.
> > > > 
> > > > There are approx 178 ports to fix, they'll just need plist regen and
> > > > bumping (there is already an appropriate variable in python.port.mk).
> > > > I'm working on it.
> 
> opencv currently has py2+py3 in a single package, using 2.7
> MODPY_VERSION and manually adding the 3.x parts. This makes it difficult
> to use python.port.mk infrastructure to handle the .so renaming.
> 
> Is it OK to drop py2 support from opencv? Upstream say that it's
> deprecated, and nothing in ports is using it (only nomacs and digikam
> use opencv, and neither use Python).

I can confirm nothing in ports uses the opencv-python.

> 
> A few other small tweaks to the Makefile to remove some things which
> are set by default anyway (ONLY_FOR_ARCHS is set based on COMPILER
> settings), use consistent .if for arch-specific things, move the
> bsd.port.arch.mk include to the point where it's needed (it has
> side-effects, easier to reason with if it affects a smaller number of
> lines), and fix a typo in COMMENT.

Thanks Stuart for taking care of it. The python part was on my 2021
list.

Package fine and digikam is still happy. OK rsadowski@

> 
> Index: Makefile
> ===
> RCS file: /cvs/ports/graphics/opencv/Makefile,v
> retrieving revision 1.64
> diff -u -p -r1.64 Makefile
> --- Makefile  23 Dec 2020 18:33:05 -  1.64
> +++ Makefile  30 Dec 2020 13:16:24 -
> @@ -1,16 +1,16 @@
>  # $OpenBSD: Makefile,v 1.64 2020/12/23 18:33:05 rsadowski Exp $
>  
> -ONLY_FOR_ARCHS = ${GCC4_ARCHS} ${CLANG_ARCHS}
>  ONLY_FOR_ARCHS-java =aarch64 amd64 i386
>  
>  CATEGORIES = graphics devel
> -COMMENT-main =   library for computer vision real-time processin
> +COMMENT-main =   library for computer vision real-time processing
>  COMMENT-java =   Java bindings for OpenCV
>  
>  V =  4.5.1
>  GH_ACCOUNT = opencv
>  GH_PROJECT = opencv
>  GH_TAGNAME = ${V}
> +REVISION =   0
>  
>  PKGNAME-main =   opencv-${V}
>  PKGNAME-java =   opencv-java-${V}
> @@ -19,8 +19,6 @@ HOMEPAGE =  https://www.opencv.org/
>  
>  MAINTAINER = Rafael Sadowski 
>  
> -DISTFILES =  opencv-{opencv/archive/}${V}${EXTRACT_SUFX}
> -
>  .for i in opencv_calib3d opencv_core opencv_features2d \
>opencv_flann opencv_highgui opencv_imgproc opencv_ml opencv_objdetect \
>opencv_photo opencv_stitching opencv_video opencv_imgcodecs \
> @@ -47,18 +45,14 @@ FLAVOR ?=
>  # BSDL
>  PERMIT_PACKAGE = Yes
>  
> -.include 
> -
>  MODULES =devel/cmake \
>   lang/python
> +MODPY_VERSION =  ${MODPY_DEFAULT_VERSION_3}
>  
> -BUILD_DEPENDS =  lang/python/${MODPY_DEFAULT_VERSION_3} \
> - math/eigen3 \
> - math/py-numpy \
> - math/py-numpy,python3
> +BUILD_DEPENDS =  math/eigen3 \
> + math/py-numpy${MODPY_FLAVOR}
>  
> -RUN_DEPENDS-main =   math/py-numpy \
> - math/py-numpy,python3
> +RUN_DEPENDS-main =   math/py-numpy${MODPY_FLAVOR}
>  
>  RUN_DEPENDS-java =   ${MODJAVA_RUN_DEPENDS}
>  
> @@ -77,7 +71,7 @@ LIB_DEPENDS-java =  ${BUILD_PKGPATH},-mai
>  
>  # XXX PIE cannot be produced due to problems with inline assembly.
>  # Since OpenCV is mostly used as a LIBrary, switch to PIC.
> -.if ${ARCH:Mi386}
> +.if ${MACHINE_ARCH:Mi386}
>  CONFIGURE_ENV =  CFLAGS="${CFLAGS} -fPIC" \
>   CXXFLAGS="${CXXFLAGS} -fPIC"
>  .endif
> @@ -96,8 +90,11 @@ CONFIGURE_ARGS =   -DBUILD_DOCS=OFF \
>   -DBUILD_ITT=OFF \
>   -DBUILD_PERF_TESTS=OFF \
>   -DBUILD_TESTS=OFF \
> + -DBUILD_opencv_python2=OFF \
>   -DINSTALL_PYTHON_EXAMPLES=OFF \
>   -DINSTALL_TESTS=OFF \
> + -DOPENCV_SKIP_PYTHON_WARNING=ON \
> + -DPYTHON_DEFAULT_EXECUTABLE=${MODPY_BIN} \
>   -DWITH_1394=OFF \
>   -DWITH_ADE=OFF \
>   -DWITH_CUDA=OFF \
> @@ -107,6 +104,8 @@ CONFIGURE_ARGS =  -DBUILD_DOCS=OFF \
>   -DWITH_V4L=OFF \
>   -DWITH_VTK=OFF
>  
> +.include 
> +
>  .if ${BUILD_PACKAGES:M-java}
>  MODULES +=   java
>  MODJAVA_VER =1.8+
> @@ -120,8 +119,6 @@ CONFIG_ADJ_CMD =  perl -pi
>  .for _l _v in ${SHARED_LIBS}
>  CONFIG_ADJ_CMD +=-e 's,lib${_l}.so([^.]),lib${_l}.so.${_v}$$1,g;'
>  .endfor
> -
> -SUBST_VARS +=MODPY_DEFAULT_VERSION_3
>  
>  NO_TEST =Yes

opencv drop py2 (was Re: [update] Python 3.8.7)

2020-12-30 Thread Stuart Henderson
> > > > sadly this will break packaging for all python ports with shared
> > > > libraries to the change they made for shared libraries :-(
> > > 
> > > 3.9 will have the same in the next release.
> > > 
> > > There are approx 178 ports to fix, they'll just need plist regen and
> > > bumping (there is already an appropriate variable in python.port.mk).
> > > I'm working on it.

opencv currently has py2+py3 in a single package, using 2.7
MODPY_VERSION and manually adding the 3.x parts. This makes it difficult
to use python.port.mk infrastructure to handle the .so renaming.

Is it OK to drop py2 support from opencv? Upstream say that it's
deprecated, and nothing in ports is using it (only nomacs and digikam
use opencv, and neither use Python).

A few other small tweaks to the Makefile to remove some things which
are set by default anyway (ONLY_FOR_ARCHS is set based on COMPILER
settings), use consistent .if for arch-specific things, move the
bsd.port.arch.mk include to the point where it's needed (it has
side-effects, easier to reason with if it affects a smaller number of
lines), and fix a typo in COMMENT.

Index: Makefile
===
RCS file: /cvs/ports/graphics/opencv/Makefile,v
retrieving revision 1.64
diff -u -p -r1.64 Makefile
--- Makefile23 Dec 2020 18:33:05 -  1.64
+++ Makefile30 Dec 2020 13:16:24 -
@@ -1,16 +1,16 @@
 # $OpenBSD: Makefile,v 1.64 2020/12/23 18:33:05 rsadowski Exp $
 
-ONLY_FOR_ARCHS =   ${GCC4_ARCHS} ${CLANG_ARCHS}
 ONLY_FOR_ARCHS-java =  aarch64 amd64 i386
 
 CATEGORIES =   graphics devel
-COMMENT-main = library for computer vision real-time processin
+COMMENT-main = library for computer vision real-time processing
 COMMENT-java = Java bindings for OpenCV
 
 V =4.5.1
 GH_ACCOUNT =   opencv
 GH_PROJECT =   opencv
 GH_TAGNAME =   ${V}
+REVISION = 0
 
 PKGNAME-main = opencv-${V}
 PKGNAME-java = opencv-java-${V}
@@ -19,8 +19,6 @@ HOMEPAGE =https://www.opencv.org/
 
 MAINTAINER =   Rafael Sadowski 
 
-DISTFILES =opencv-{opencv/archive/}${V}${EXTRACT_SUFX}
-
 .for i in opencv_calib3d opencv_core opencv_features2d \
   opencv_flann opencv_highgui opencv_imgproc opencv_ml opencv_objdetect \
   opencv_photo opencv_stitching opencv_video opencv_imgcodecs \
@@ -47,18 +45,14 @@ FLAVOR ?=
 # BSDL
 PERMIT_PACKAGE =   Yes
 
-.include 
-
 MODULES =  devel/cmake \
lang/python
+MODPY_VERSION =${MODPY_DEFAULT_VERSION_3}
 
-BUILD_DEPENDS =lang/python/${MODPY_DEFAULT_VERSION_3} \
-   math/eigen3 \
-   math/py-numpy \
-   math/py-numpy,python3
+BUILD_DEPENDS =math/eigen3 \
+   math/py-numpy${MODPY_FLAVOR}
 
-RUN_DEPENDS-main = math/py-numpy \
-   math/py-numpy,python3
+RUN_DEPENDS-main = math/py-numpy${MODPY_FLAVOR}
 
 RUN_DEPENDS-java = ${MODJAVA_RUN_DEPENDS}
 
@@ -77,7 +71,7 @@ LIB_DEPENDS-java =${BUILD_PKGPATH},-mai
 
 # XXX PIE cannot be produced due to problems with inline assembly.
 # Since OpenCV is mostly used as a LIBrary, switch to PIC.
-.if ${ARCH:Mi386}
+.if ${MACHINE_ARCH:Mi386}
 CONFIGURE_ENV =CFLAGS="${CFLAGS} -fPIC" \
CXXFLAGS="${CXXFLAGS} -fPIC"
 .endif
@@ -96,8 +90,11 @@ CONFIGURE_ARGS = -DBUILD_DOCS=OFF \
-DBUILD_ITT=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_TESTS=OFF \
+   -DBUILD_opencv_python2=OFF \
-DINSTALL_PYTHON_EXAMPLES=OFF \
-DINSTALL_TESTS=OFF \
+   -DOPENCV_SKIP_PYTHON_WARNING=ON \
+   -DPYTHON_DEFAULT_EXECUTABLE=${MODPY_BIN} \
-DWITH_1394=OFF \
-DWITH_ADE=OFF \
-DWITH_CUDA=OFF \
@@ -107,6 +104,8 @@ CONFIGURE_ARGS =-DBUILD_DOCS=OFF \
-DWITH_V4L=OFF \
-DWITH_VTK=OFF
 
+.include 
+
 .if ${BUILD_PACKAGES:M-java}
 MODULES += java
 MODJAVA_VER =  1.8+
@@ -120,8 +119,6 @@ CONFIG_ADJ_CMD =perl -pi
 .for _l _v in ${SHARED_LIBS}
 CONFIG_ADJ_CMD +=  -e 's,lib${_l}.so([^.]),lib${_l}.so.${_v}$$1,g;'
 .endfor
-
-SUBST_VARS +=  MODPY_DEFAULT_VERSION_3
 
 NO_TEST =  Yes
 # Enable to run the regression tests
Index: pkg/PLIST-java
===
RCS file: /cvs/ports/graphics/opencv/pkg/PLIST-java,v
retrieving revision 1.11
diff -u -p -r1.11 PLIST-java
--- pkg/PLIST-java  23 Dec 2020 18:33:05 -  1.11
+++ pkg/PLIST-java  30 Dec 2020 13:16:24 -
@@ -1,5 +1,5 @@
 @comment $OpenBSD: PLIST-java,v 1.11 2020/12/23 18:33:05 rsadowski Exp $