diff --git a/recipe/bld.bat b/recipe/bld.bat index 9eb54c65..ea2c00b5 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -12,6 +12,10 @@ if "%PY3K%" == "0" ( mkdir build cd build +if "%qt_version%"=="5" set WITH_QT="-DWITH_QT=5" +if "%qt_version%"=="6" set WITH_QT="-DWITH_QT=6" +if "%qt_version%"=="none" set WITH_QT="-DWITH_QT=0" + for /F "tokens=1,2 delims=. " %%a in ("%PY_VER%") do ( set "PY_MAJOR=%%a" set "PY_MINOR=%%b" @@ -85,7 +89,7 @@ cmake -LAH -G "Ninja" -DWITH_TESSERACT=0 ^ -DWITH_VTK=0 ^ -DWITH_WIN32UI=0 ^ - -DWITH_QT=5 ^ + %WITH_QT% ^ -DINSTALL_C_EXAMPLES=0 ^ -DOPENCV_EXTRA_MODULES_PATH=%UNIX_SRC_DIR%/opencv_contrib/modules ^ -DPYTHON_EXECUTABLE="" ^ diff --git a/recipe/build.sh b/recipe/build.sh index a5f3af2f..19cd9219 100644 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -5,7 +5,6 @@ set -ex # https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindPNG.cmake#L55 ln -s $PREFIX/include/libpng16 $PREFIX/include/libpng -QT="5" V4L="1" OPENVINO="1" @@ -16,17 +15,24 @@ if [[ "${target_platform}" == linux-* ]]; then OPENMP="-DWITH_OPENMP=1" fi -if [[ "${target_platform}" == osx-* ]]; then +if [[ "$qt_version" == "5" ]]; then + QT="5" +elif [[ "$qt_version" == "6" ]]; then + QT="6" +else QT="0" +fi + +if [[ "${target_platform}" == osx-* ]]; then V4L="0" elif [[ "${target_platform}" == linux-ppc64le ]]; then - QT="0" OPENVINO="0" fi if [[ "${target_platform}" != "${build_platform}" ]]; then CMAKE_ARGS="${CMAKE_ARGS} -DProtobuf_PROTOC_EXECUTABLE=$BUILD_PREFIX/bin/protoc" + CMAKE_ARGS="${CMAKE_ARGS} -DQT_HOST_PATH=${BUILD_PREFIX}" fi diff --git a/recipe/conda_build_config.yaml b/recipe/conda_build_config.yaml index ae6976b1..c0140948 100644 --- a/recipe/conda_build_config.yaml +++ b/recipe/conda_build_config.yaml @@ -1,4 +1,16 @@ -MACOSX_SDK_VERSION: # [osx and x86_64] - - "10.13" # [osx and x86_64] -MACOSX_DEPLOYMENT_TARGET: # [osx and x86_64] - - "10.13" # [osx and x86_64] +MACOSX_SDK_VERSION: # [osx and x86_64 and qt_version!=6] + - "10.13" # [osx and x86_64 and qt_version!=6] +MACOSX_DEPLOYMENT_TARGET: # [osx and x86_64 and qt_version!=6] + - "10.13" # [osx and x86_64 and qt_version==none] + - "10.13" # [osx and x86_64 and qt_version==5] + +# https://doc.qt.io/qt-6/macos.html +MACOSX_DEPLOYMENT_TARGET: # [osx and qt_version == 6] + - '11.0' # [osx and qt_version == 6] +MACOSX_SDK_VERSION: # [osx and qt_version == 6] + - '12.3' # [osx and qt_version == 6] + +qt_version: + - none + - 5 # [not ppc64le] + - 6 # [not ppc64le] diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a382b8eb..e3310253 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -24,6 +24,16 @@ {% set PY_VER_MAJOR = PY_VER.split('.')[0] %} {% set PY_VER_MINOR = PY_VER.split('.')[1] %} +{% set build = 10 %} + +{% if qt_version == "5" %} +{% set build = build + 200 %} +{% endif %} + +{% if qt_version == "6" %} +{% set build = build + 400 %} +{% endif %} + package: name: libopencv version: {{ version }} @@ -35,6 +45,7 @@ source: patches: # backport https://github.com/opencv/opencv/pull/21611 (unmerged as of 06/2023) - patches_opencv/0001-Add-installation-of-pip-metadata-from-cmake.patch + - patches_opencv/0001-Also-install-metadata-for-opencv-python-headless.patch - patches_opencv/0002-delete-lines-that-download-opencv.patch - patches_opencv/0003-find-pkgconfig-on-windows.patch - patches_opencv/0004-fix-detection-for-protobuf-23.x.patch @@ -50,14 +61,16 @@ source: sha256: 78884f64b564a3b06dc6ee731ed33b60c6d8cd864cea07f21d94ba0f90c7b310 build: - number: 9 - string: py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} + number: {{ build }} + string: qt{{ qt_version }}_py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} run_exports: # https://abi-laboratory.pro/index.php?view=timeline&l=opencv # Things seem to change every patch versions, mostly the dnn module - {{ pin_subpackage('libopencv', max_pin='x.x.x') }} ignore_run_exports_from: - python + # Skip for now. remove me later + skip: true # [py!=310] requirements: build: @@ -65,6 +78,7 @@ requirements: - cross-python_{{ target_platform }} # [build_platform != target_platform] - numpy # [build_platform != target_platform] - libprotobuf # [build_platform != target_platform] + - qt6-main # [build_platform != target_platform and qt_version == 6] # pkg-config is required to find ffpmeg - pkg-config - cmake @@ -91,8 +105,9 @@ requirements: # binary - ffmpeg {{ ffmpeg }}=lgpl_* - freetype - - glib # [unix] + # harfbuzz and glib are both needed for freetype support - harfbuzz + - glib - hdf5 - jasper - libcblas @@ -105,7 +120,8 @@ requirements: - libtiff - libwebp - openexr - - qt-main # [not osx and not ppc64le] + - qt-main # [qt_version == 5] + - qt6-main # [qt_version == 6] - zlib - libopenvino-dev # [not ppc64le] @@ -181,15 +197,16 @@ test: {{ opencv_libs.append("xobjdetect") or "" }} {{ opencv_libs.append("xphoto") or "" }} {{ opencv_libs.append("freetype") or "" }} - - export MACOSX_DEPLOYMENT_TARGET={{ MACOSX_DEPLOYMENT_TARGET }} # [osx] - - export CONDA_BUILD_SYSROOT={{ CONDA_BUILD_SYSROOT }} # [osx] - - OPENCV_FLAGS=`pkg-config --cflags opencv4` # [unix] - - $CXX -std=c++11 $RECIPE_DIR/test.cpp ${OPENCV_FLAGS} -o test # [unix] + - export MACOSX_DEPLOYMENT_TARGET={{ MACOSX_DEPLOYMENT_TARGET }} # [osx] + - export CONDA_BUILD_SYSROOT={{ CONDA_BUILD_SYSROOT }} # [osx] + - OPENCV_FLAGS=`pkg-config --cflags opencv4` # [unix] + - $CXX -std=c++11 $RECIPE_DIR/test.cpp ${OPENCV_FLAGS} -o test # [unix] - if [[ $(./test) != $PKG_VERSION ]]; then exit 1 ; fi # [unix] {% for each_opencv_lib in opencv_libs %} - echo Testing for presence of {{ each_opencv_lib }} - - test -f $PREFIX/lib/libopencv_{{ each_opencv_lib }}${SHLIB_EXT} # [unix] + - test -f $PREFIX/lib/libopencv_{{ each_opencv_lib }}${SHLIB_EXT} # [unix] - if not exist %PREFIX%\\Library\\bin\\opencv_{{ each_opencv_lib }}{{ win_ver_lib }}.dll exit 1 # [win] + - echo Found {{ each_opencv_lib }} {% endfor %} - test -f $PREFIX/lib/libopencv_bioinspired${SHLIB_EXT} # [unix] - test -f $PREFIX/lib/libopencv_hdf${SHLIB_EXT} # [unix] @@ -202,7 +219,9 @@ outputs: - name: libopencv - name: opencv build: - string: py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} + string: qt{{ qt_version }}_py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} + # Skip for now. remove me later + skip: true # [py!=310] requirements: host: # Explicitely add a python requirement so that the hash changes between @@ -220,7 +239,9 @@ outputs: - name: py-opencv build: - string: py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} + # Skip for now. remove me later + skip: true # [py!=310] + string: qt{{ qt_version }}_py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} run_exports: # Should we even have this??? # don't pin the python version so hard. @@ -262,7 +283,8 @@ outputs: - python -c "import cv2, re; assert re.search('Lapack:\s+YES', cv2.getBuildInformation())" - pip check - pip list - - test $(pip list | grep opencv-python | wc -l) -eq 1 # [unix] + - test $(pip list | grep opencv-python | wc -l) -eq 2 # [unix] + - test $(pip list | grep opencv-python-headless | wc -l) -eq 1 # [unix] requires: - pip diff --git a/recipe/patches_opencv/0001-Also-install-metadata-for-opencv-python-headless.patch b/recipe/patches_opencv/0001-Also-install-metadata-for-opencv-python-headless.patch new file mode 100644 index 00000000..e6a28e1e --- /dev/null +++ b/recipe/patches_opencv/0001-Also-install-metadata-for-opencv-python-headless.patch @@ -0,0 +1,34 @@ +From bab68f46520a60ed4fa6b384fe36d7174183e983 Mon Sep 17 00:00:00 2001 +From: Mark Harfouche +Date: Mon, 11 Mar 2024 22:40:08 -0400 +Subject: [PATCH] Also install metadata for opencv-python-headless + +--- + modules/python/common.cmake | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/modules/python/common.cmake b/modules/python/common.cmake +index 88f4189206..f4c8ec7258 100644 +--- a/modules/python/common.cmake ++++ b/modules/python/common.cmake +@@ -252,6 +252,17 @@ if (OPENCV_PYTHON_PIP_METADATA_INSTALL) + FILES "${CMAKE_CURRENT_BINARY_DIR}/METADATA" "${CMAKE_CURRENT_BINARY_DIR}/INSTALLER" + DESTINATION ${OPENCV_PYTHON_INSTALL_PATH}/opencv_python-${OPENCV_VERSION}.dist-info + COMPONENT python) ++ ++ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info") ++ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/METADATA "") ++ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/METADATA "Metadata-Version: 2.1\n") ++ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/METADATA "Name: opencv-python-headless\n") ++ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/METADATA "Version: ${OPENCV_VERSION}\n") ++ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/INSTALLER "${OPENCV_PYTHON_PIP_METADATA_INSTALLER}\n") ++ install( ++ FILES "${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/METADATA" "${CMAKE_CURRENT_BINARY_DIR}/ocvph.dist-info/INSTALLER" ++ DESTINATION ${OPENCV_PYTHON_INSTALL_PATH}/opencv_python_headless-${OPENCV_VERSION}.dist-info ++ COMPONENT python) + endif() + + unset(PYTHON_SRC_DIR) +-- +2.43.2 + diff --git a/recipe/yum_requirements.txt b/recipe/yum_requirements.txt index 0e16b14e..30ef650b 100644 --- a/recipe/yum_requirements.txt +++ b/recipe/yum_requirements.txt @@ -1 +1,4 @@ mesa-libGL +mesa-libEGL +libglvnd-glx +libglvnd-opengl