From 085d492021b0b22eda256396301f0bd159ccd019 Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Fri, 6 Sep 2024 15:45:42 +0800 Subject: [PATCH 01/10] chore: upgrade system version of build container * close https://github.com/radxa-pkg/mraa/issues/1 --- .github/container/Dockerfile | 5 +++-- Makefile | 2 +- debian/python3-mraa.install | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/container/Dockerfile b/.github/container/Dockerfile index 4d1955e66..8275ad3d8 100644 --- a/.github/container/Dockerfile +++ b/.github/container/Dockerfile @@ -1,9 +1,10 @@ -FROM debian:bullseye +FROM debian:bookworm RUN dpkg --add-architecture arm64 && \ apt-get update && \ apt-get full-upgrade --no-install-recommends -y \ build-essential crossbuild-essential-arm64 default-jdk-headless git \ - cmake debhelper devscripts lintian swig pkgconf:arm64 python3-dev:arm64 libjson-c-dev:arm64 && \ + cmake debhelper devscripts lintian swig pkgconf:arm64 python3-dev:arm64 libjson-c-dev:arm64 libstdc++6:arm64 && \ + ln -s /usr/bin/python3 /usr/bin/python && \ adduser --gecos runner --disabled-password runner && \ rm -rf /var/lib/apt/lists/* diff --git a/Makefile b/Makefile index 2c9249c3c..65c7217e4 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ dch: debian/changelog EDITOR=true gbp dch --commit --debian-branch=master --release --dch-opt=--upstream .PHONY: deb -deb: debian +deb: debian SOURCE debuild --no-lintian --lintian-hook "lintian --fail-on error,warning --suppress-tags bad-distribution-in-changes-file -- %p_%v_*.changes" --no-sign -b -aarm64 -Pcross .PHONY: release diff --git a/debian/python3-mraa.install b/debian/python3-mraa.install index 8d1b877d1..1dd6507e9 100644 --- a/debian/python3-mraa.install +++ b/debian/python3-mraa.install @@ -1 +1 @@ -usr/lib/python3.9/dist-packages/* usr/lib/python3/dist-packages/ +usr/lib/python3.11/dist-packages/* usr/lib/python3/dist-packages/ From 9ad951c1d66f769228fd69a42ec115de429e4481 Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Fri, 6 Sep 2024 15:56:15 +0800 Subject: [PATCH 02/10] feat: add CODEOWNERS Signed-off-by: Chen Jiali --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..2e0fd7602 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @RadxaYuntian From c38414eacf5d1bfffa4c6a0323e9f72d780588af Mon Sep 17 00:00:00 2001 From: CodeChenL <43897062+CodeChenL@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:05:37 +0800 Subject: [PATCH 03/10] fix: install python3-mraa using wildcard Co-authored-by: ZHANG Yuntian --- debian/python3-mraa.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/python3-mraa.install b/debian/python3-mraa.install index 1dd6507e9..37ed7ce5d 100644 --- a/debian/python3-mraa.install +++ b/debian/python3-mraa.install @@ -1 +1 @@ -usr/lib/python3.11/dist-packages/* usr/lib/python3/dist-packages/ +usr/lib/python3*/dist-packages/* usr/lib/python3/dist-packages/ From 0884058bdacc87c53cafb4c2a0e2df389396b26b Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Fri, 6 Sep 2024 19:08:31 +0800 Subject: [PATCH 04/10] fix: change by reviewer --- .github/container/Dockerfile | 8 ++++++-- .github/container/equivs-dummy.equivs | 1 + Makefile | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .github/container/equivs-dummy.equivs diff --git a/.github/container/Dockerfile b/.github/container/Dockerfile index 8275ad3d8..ec8b79539 100644 --- a/.github/container/Dockerfile +++ b/.github/container/Dockerfile @@ -1,10 +1,14 @@ FROM debian:bookworm +COPY equivs-dummy.equivs /tmp/equivs-dummy.equivs + RUN dpkg --add-architecture arm64 && \ apt-get update && \ + apt-get full-upgrade --no-install-recommends -y equivs && \ + equivs-build /tmp/equivs-dummy.equivs && \ apt-get full-upgrade --no-install-recommends -y \ build-essential crossbuild-essential-arm64 default-jdk-headless git \ - cmake debhelper devscripts lintian swig pkgconf:arm64 python3-dev:arm64 libjson-c-dev:arm64 libstdc++6:arm64 && \ - ln -s /usr/bin/python3 /usr/bin/python && \ + cmake debhelper devscripts lintian swig pkgconf:arm64 python-is-python3 \ + python3-dev:arm64 libjson-c-dev:arm64 libstdc++6:arm64 /equivs-dummy_1.0_all.deb && \ adduser --gecos runner --disabled-password runner && \ rm -rf /var/lib/apt/lists/* diff --git a/.github/container/equivs-dummy.equivs b/.github/container/equivs-dummy.equivs new file mode 100644 index 000000000..1cacfc3ec --- /dev/null +++ b/.github/container/equivs-dummy.equivs @@ -0,0 +1 @@ +Provides: python3:amd64 (= 3.11) diff --git a/Makefile b/Makefile index 65c7217e4..2c9249c3c 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ dch: debian/changelog EDITOR=true gbp dch --commit --debian-branch=master --release --dch-opt=--upstream .PHONY: deb -deb: debian SOURCE +deb: debian debuild --no-lintian --lintian-hook "lintian --fail-on error,warning --suppress-tags bad-distribution-in-changes-file -- %p_%v_*.changes" --no-sign -b -aarm64 -Pcross .PHONY: release From 2b9a52b6a31ee51a5c681cc0c7edf57f9825ba53 Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Tue, 10 Sep 2024 17:07:37 +0800 Subject: [PATCH 05/10] fix: uninstall python-is-python3 --- .github/container/Dockerfile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/container/Dockerfile b/.github/container/Dockerfile index ec8b79539..6b91f0e89 100644 --- a/.github/container/Dockerfile +++ b/.github/container/Dockerfile @@ -1,14 +1,10 @@ FROM debian:bookworm -COPY equivs-dummy.equivs /tmp/equivs-dummy.equivs - RUN dpkg --add-architecture arm64 && \ apt-get update && \ - apt-get full-upgrade --no-install-recommends -y equivs && \ - equivs-build /tmp/equivs-dummy.equivs && \ apt-get full-upgrade --no-install-recommends -y \ build-essential crossbuild-essential-arm64 default-jdk-headless git \ - cmake debhelper devscripts lintian swig pkgconf:arm64 python-is-python3 \ - python3-dev:arm64 libjson-c-dev:arm64 libstdc++6:arm64 /equivs-dummy_1.0_all.deb && \ + cmake debhelper devscripts lintian swig pkgconf:arm64 python3-dev:arm64 \ + libjson-c-dev:arm64 libstdc++6:arm64 && \ adduser --gecos runner --disabled-password runner && \ rm -rf /var/lib/apt/lists/* From 505299b38cd0091940d2686c916fc02194da82d6 Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Tue, 10 Sep 2024 17:09:30 +0800 Subject: [PATCH 06/10] fix: determining major version when finding PythonInterp --- cmake/modules/OpenCVDetectPython.cmake | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmake/modules/OpenCVDetectPython.cmake b/cmake/modules/OpenCVDetectPython.cmake index c0441c458..a1362e818 100644 --- a/cmake/modules/OpenCVDetectPython.cmake +++ b/cmake/modules/OpenCVDetectPython.cmake @@ -37,13 +37,17 @@ if(NOT ${found}) endif() if(PYTHONINTERP_FOUND) - # Copy outputs - set(_found ${PYTHONINTERP_FOUND}) - set(_executable ${PYTHON_EXECUTABLE}) - set(_version_string ${PYTHON_VERSION_STRING}) - set(_version_major ${PYTHON_VERSION_MAJOR}) - set(_version_minor ${PYTHON_VERSION_MINOR}) - set(_version_patch ${PYTHON_VERSION_PATCH}) + if("${PYTHON_VERSION_MAJOR}" STREQUAL "${${version_major}}") + # Copy outputs + set(_found ${PYTHONINTERP_FOUND}) + set(_executable ${PYTHON_EXECUTABLE}) + set(_version_string ${PYTHON_VERSION_STRING}) + set(_version_major ${PYTHON_VERSION_MAJOR}) + set(_version_minor ${PYTHON_VERSION_MINOR}) + set(_version_patch ${PYTHON_VERSION_PATCH}) + else() + message(STATUS "Found Python ${PYTHON_VERSION_STRING}, but major version ${${version_major}} is required") + endif() # Clear find_host_package side effects unset(PYTHONINTERP_FOUND) @@ -138,6 +142,9 @@ endfunction(find_python) set(MIN_VER_PYTHON2 2.7) set(MIN_VER_PYTHON3 3.2) +set(PYTHON2_VERSION_MAJOR 2) +set(PYTHON3_VERSION_MAJOR 3) + find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND From a82907b318203ef1b9787ab79a353e23e6acfe26 Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Tue, 10 Sep 2024 17:12:32 +0800 Subject: [PATCH 07/10] fix: remove equivs-dummy.equivs --- .github/container/equivs-dummy.equivs | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .github/container/equivs-dummy.equivs diff --git a/.github/container/equivs-dummy.equivs b/.github/container/equivs-dummy.equivs deleted file mode 100644 index 1cacfc3ec..000000000 --- a/.github/container/equivs-dummy.equivs +++ /dev/null @@ -1 +0,0 @@ -Provides: python3:amd64 (= 3.11) From 28088ef7f550821bfd42d898c71eab5f8e83fa5c Mon Sep 17 00:00:00 2001 From: Chen Jiali Date: Wed, 11 Sep 2024 10:03:28 +0800 Subject: [PATCH 08/10] feat: add FindPython support --- cmake/modules/OpenCVDetectPython.cmake | 59 +++++++++++++++++--------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/cmake/modules/OpenCVDetectPython.cmake b/cmake/modules/OpenCVDetectPython.cmake index a1362e818..606be9000 100644 --- a/cmake/modules/OpenCVDetectPython.cmake +++ b/cmake/modules/OpenCVDetectPython.cmake @@ -29,15 +29,39 @@ function(find_python preferred_version min_version library_env include_dir_env if(NOT ${found}) if(${executable}) set(PYTHON_EXECUTABLE "${${executable}}") + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") endif() - find_package(PythonInterp "${preferred_version}") - if(NOT PYTHONINTERP_FOUND) - find_package(PythonInterp "${min_version}") - endif() + if(${CMAKE_VERSION} VERSION_GREATER "3.12") + find_package(Python "${preferred_version}" COMPONENTS Interpreter) + if(NOT Python_Interpreter_FOUND) + find_package(Python "${min_version}" COMPONENTS Interpreter) + endif() - if(PYTHONINTERP_FOUND) - if("${PYTHON_VERSION_MAJOR}" STREQUAL "${${version_major}}") + if(Python_Interpreter_FOUND) + # Copy outputs + set(_found ${Python_Interpreter_FOUND}) + set(_executable ${Python_EXECUTABLE}) + set(_version_string ${Python_VERSION}) + set(_version_major ${Python_VERSION_MAJOR}) + set(_version_minor ${Python_VERSION_MINOR}) + set(_version_patch ${Python_VERSION_PATCH}) + + # Clear find_host_package side effects + unset(Python_Interpreter_FOUND) + unset(Python_EXECUTABLE CACHE) + unset(Python_VERSION) + unset(Python_VERSION_MAJOR) + unset(Python_VERSION_MINOR) + unset(Python_VERSION_PATCH) + endif() + else() + find_package(PythonInterp "${preferred_version}") + if(NOT PYTHONINTERP_FOUND) + find_package(PythonInterp "${min_version}") + endif() + + if(PYTHONINTERP_FOUND) # Copy outputs set(_found ${PYTHONINTERP_FOUND}) set(_executable ${PYTHON_EXECUTABLE}) @@ -45,17 +69,15 @@ if(NOT ${found}) set(_version_major ${PYTHON_VERSION_MAJOR}) set(_version_minor ${PYTHON_VERSION_MINOR}) set(_version_patch ${PYTHON_VERSION_PATCH}) - else() - message(STATUS "Found Python ${PYTHON_VERSION_STRING}, but major version ${${version_major}} is required") - endif() - # Clear find_host_package side effects - unset(PYTHONINTERP_FOUND) - unset(PYTHON_EXECUTABLE CACHE) - unset(PYTHON_VERSION_STRING) - unset(PYTHON_VERSION_MAJOR) - unset(PYTHON_VERSION_MINOR) - unset(PYTHON_VERSION_PATCH) + # Clear find_host_package side effects + unset(PYTHONINTERP_FOUND) + unset(PYTHON_EXECUTABLE CACHE) + unset(PYTHON_VERSION_STRING) + unset(PYTHON_VERSION_MAJOR) + unset(PYTHON_VERSION_MINOR) + unset(PYTHON_VERSION_PATCH) + endif() endif() if(_found) @@ -142,9 +164,6 @@ endfunction(find_python) set(MIN_VER_PYTHON2 2.7) set(MIN_VER_PYTHON3 3.2) -set(PYTHON2_VERSION_MAJOR 2) -set(PYTHON3_VERSION_MAJOR 3) - find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND @@ -167,4 +186,4 @@ elseif(PYTHON3INTERP_FOUND) # Use Python 3 as default Python interpreter elseif(PYTHON2INTERP_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 3) set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}") -endif() +endif() \ No newline at end of file From 596e4e5383b8a54dadd4b40435bd56d647051197 Mon Sep 17 00:00:00 2001 From: CodeChenL <43897062+CodeChenL@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:48:24 +0800 Subject: [PATCH 09/10] fix: apply suggestions from code review Co-authored-by: ZHANG Yuntian --- cmake/modules/OpenCVDetectPython.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/OpenCVDetectPython.cmake b/cmake/modules/OpenCVDetectPython.cmake index 606be9000..a50e7accf 100644 --- a/cmake/modules/OpenCVDetectPython.cmake +++ b/cmake/modules/OpenCVDetectPython.cmake @@ -32,7 +32,7 @@ if(NOT ${found}) set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") endif() - if(${CMAKE_VERSION} VERSION_GREATER "3.12") + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") find_package(Python "${preferred_version}" COMPONENTS Interpreter) if(NOT Python_Interpreter_FOUND) find_package(Python "${min_version}" COMPONENTS Interpreter) @@ -186,4 +186,4 @@ elseif(PYTHON3INTERP_FOUND) # Use Python 3 as default Python interpreter elseif(PYTHON2INTERP_FOUND) # Use Python 2 as fallback Python interpreter (if there is no Python 3) set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}") -endif() \ No newline at end of file +endif() From cbcd0eba9bb6296d2468e23306e28876a376ec5b Mon Sep 17 00:00:00 2001 From: CodeChenL <43897062+CodeChenL@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:58:05 +0800 Subject: [PATCH 10/10] fix: apply suggestions from code review Co-authored-by: ZHANG Yuntian --- cmake/modules/OpenCVDetectPython.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/OpenCVDetectPython.cmake b/cmake/modules/OpenCVDetectPython.cmake index a50e7accf..5f3db2d89 100644 --- a/cmake/modules/OpenCVDetectPython.cmake +++ b/cmake/modules/OpenCVDetectPython.cmake @@ -29,7 +29,7 @@ function(find_python preferred_version min_version library_env include_dir_env if(NOT ${found}) if(${executable}) set(PYTHON_EXECUTABLE "${${executable}}") - set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}") + set(Python_EXECUTABLE "${${executable}}") endif() if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")