commit:     bc0cde8e770d972fd2dd2061fe1d26e7a4c3a220
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 31 20:07:10 2021 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sun Jan 31 22:59:59 2021 +0000
URL:        https://gitweb.gentoo.org/proj/kde.git/commit/?id=bc0cde8e

media-sound/kid3: Make test dependencies optional, add missing BDEPEND

Use CMake 3.12's Python3 module to inject PYTHON

Bug: https://bugs.gentoo.org/768084
Package-Manager: Portage-3.0.14, Repoman-3.0.2
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../kid3/files/kid3-3.8.5-tests-optional.patch     | 99 ++++++++++++++++++++++
 media-sound/kid3/kid3-9999.ebuild                  | 21 +++--
 2 files changed, 115 insertions(+), 5 deletions(-)

diff --git a/media-sound/kid3/files/kid3-3.8.5-tests-optional.patch 
b/media-sound/kid3/files/kid3-3.8.5-tests-optional.patch
new file mode 100644
index 0000000000..d5b74ca561
--- /dev/null
+++ b/media-sound/kid3/files/kid3-3.8.5-tests-optional.patch
@@ -0,0 +1,99 @@
+From 4efe62089eff54ac844c70382d432f2abb24c06e Mon Sep 17 00:00:00 2001
+From: Andreas Sturmlechner <[email protected]>
+Date: Sun, 31 Jan 2021 20:38:41 +0100
+Subject: [PATCH 1/2] Use include(CTest) and BUILD_TESTING to make Qt5Test and
+ Python optional
+
+Signed-off-by: Andreas Sturmlechner <[email protected]>
+---
+ CMakeLists.txt | 25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 92d50265..557a208d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -211,8 +211,11 @@ endif()
+ set(CFG_QMLSRCDIR "${kid3_SOURCE_DIR}/src/qml")
+ 
+ find_package(Threads)
+-set(Python_ADDITIONAL_VERSIONS 3)
+-find_package(PythonInterp REQUIRED)
++include(CTest)
++if(BUILD_TESTING)
++  set(Python_ADDITIONAL_VERSIONS 3)
++  find_package(PythonInterp REQUIRED)
++endif()
+ include (CheckCXXSourceCompiles)
+ include (CheckCXXCompilerFlag)
+ include (CheckLibraryExists)
+@@ -256,7 +259,10 @@ else()
+   find_package(Qt5Core)
+ endif()
+ if(Qt5Core_FOUND)
+-  set(_qtComponents Core Gui Widgets Network Xml Multimedia LinguistTools 
Test)
++  set(_qtComponents Core Gui Widgets Network Xml Multimedia LinguistTools)
++  if(BUILD_TESTING)
++    set(_qtComponents ${_qtComponents} Test)
++  endif()
+   if(WITH_DBUS)
+     set(_qtComponents ${_qtComponents} DBus)
+   endif()
+@@ -472,12 +478,13 @@ if(ANDROID)
+ endif()
+ 
+ 
+-enable_testing()
+-add_test(NAME test_cli_functions
+-         COMMAND ${PYTHON_EXECUTABLE} 
${CMAKE_SOURCE_DIR}/src/test/test_cli_functions.py)
+-add_custom_target(check ${CMAKE_CTEST_COMMAND} --output-on-failure)
+-if(NOT CMAKE_VERSION VERSION_LESS "3.17")
+-  list(APPEND CMAKE_CTEST_ARGUMENTS --output-on-failure)
++if(BUILD_TESTING)
++  add_test(NAME test_cli_functions
++           COMMAND ${PYTHON_EXECUTABLE} 
${CMAKE_SOURCE_DIR}/src/test/test_cli_functions.py)
++  add_custom_target(check ${CMAKE_CTEST_COMMAND} --output-on-failure)
++  if(NOT CMAKE_VERSION VERSION_LESS "3.17")
++    list(APPEND CMAKE_CTEST_ARGUMENTS --output-on-failure)
++  endif()
+ endif()
+ 
+ 
+-- 
+2.30.0
+
+
+From 1e264e918686d5d09a5457513f3aadeea25d6e5e Mon Sep 17 00:00:00 2001
+From: Andreas Sturmlechner <[email protected]>
+Date: Sun, 31 Jan 2021 23:43:49 +0100
+Subject: [PATCH 2/2] Use CMake FindPython3 module if available (CMake >=3.12)
+
+Signed-off-by: Andreas Sturmlechner <[email protected]>
+---
+ CMakeLists.txt | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 557a208d..706167e6 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -213,8 +213,14 @@ set(CFG_QMLSRCDIR "${kid3_SOURCE_DIR}/src/qml")
+ find_package(Threads)
+ include(CTest)
+ if(BUILD_TESTING)
+-  set(Python_ADDITIONAL_VERSIONS 3)
+-  find_package(PythonInterp REQUIRED)
++  if(CMAKE_VERSION VERSION_LESS 3.12.0)
++    set(Python_ADDITIONAL_VERSIONS 3)
++    find_package(PythonInterp REQUIRED)
++    # PythonInterp sets PYTHON_EXECUTABLE
++  else()
++    find_package(Python3 COMPONENTS Interpreter REQUIRED)
++    set(PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
++  endif()
+ endif()
+ include (CheckCXXSourceCompiles)
+ include (CheckCXXCompilerFlag)
+-- 
+2.30.0
+

diff --git a/media-sound/kid3/kid3-9999.ebuild 
b/media-sound/kid3/kid3-9999.ebuild
index a047ed173a..5e87f72029 100644
--- a/media-sound/kid3/kid3-9999.ebuild
+++ b/media-sound/kid3/kid3-9999.ebuild
@@ -3,7 +3,8 @@
 
 EAPI=7
 
-inherit kde.org cmake xdg
+PYTHON_COMPAT=( python3_{7..9} )
+inherit cmake kde.org python-any-r1 xdg
 
 DESCRIPTION="Simple tag editor based on Qt"
 HOMEPAGE="https://kid3.kde.org/";
@@ -15,15 +16,17 @@ fi
 
 LICENSE="GPL-2+"
 SLOT="5"
-IUSE="acoustid flac kde mp3 mp4 +mpris +taglib vorbis"
+IUSE="acoustid flac kde mp3 mp4 +mpris +taglib test vorbis"
 
 REQUIRED_USE="flac? ( vorbis )"
+RESTRICT+=" !test? ( test )"
 
 BDEPEND="
        dev-qt/linguist-tools:5
        kde? ( kde-frameworks/extra-cmake-modules:5 )
+       test? ( ${PYTHON_DEPS} )
 "
-DEPEND="
+RDEPEND="
        dev-qt/qtcore:5
        dev-qt/qtdeclarative:5
        dev-qt/qtgui:5
@@ -57,10 +60,16 @@ DEPEND="
                media-libs/libvorbis
        )
 "
-RDEPEND="${DEPEND}
-       !media-sound/kid3:4
+DEPEND="${RDEPEND}
+       test? ( dev-qt/qttest:5 )
 "
 
+PATCHES=( "${FILESDIR}/${PN}-3.8.5-tests-optional.patch" )
+
+pkg_setup() {
+       use test && python-any-r1_pkg_setup
+}
+
 src_prepare() {
        # overengineered upstream build system
        cmake_src_prepare
@@ -76,8 +85,10 @@ src_configure() {
                -DWITH_ID3LIB=$(usex mp3)
                -DWITH_MP4V2=$(usex mp4)
                -DWITH_TAGLIB=$(usex taglib)
+               -DBUILD_TESTING=$(usex test)
                -DWITH_VORBIS=$(usex vorbis)
        )
+       use test && mycmakeargs+=( -DPython3_EXECUTABLE="${PYTHON}" )
 
        if use kde ; then
                mycmakeargs+=( "-DWITH_APPS=KDE;CLI" )

Reply via email to