commit:     6a21e8643a56f91c724f23d652fb43ead5c1e2af
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 19 14:27:42 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Apr 23 20:49:26 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6a21e864

install-qa-check.d: Add a install log check for missing dev-python/cython dep

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1024
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                                |  2 ++
 bin/install-qa-check.d/90cython-dep | 45 +++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/NEWS b/NEWS
index e60262509..50d96402c 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ Features:
   - -Wmain
   - -Wimplicit-int
   - -Wstring-compare
+* install-qa-check.d: cython-dep: Report packages that are using Cython
+  but are missing BDEPEND on it.
 
 Bug fixes:
 * econf now checks for proper end of string in "configure --help" output for

diff --git a/bin/install-qa-check.d/90cython-dep 
b/bin/install-qa-check.d/90cython-dep
new file mode 100644
index 000000000..4932c0242
--- /dev/null
+++ b/bin/install-qa-check.d/90cython-dep
@@ -0,0 +1,45 @@
+# Check for missing dev-python/cython dep based on output
+# from setuptools cythonize() support
+
+cython_dep_check() {
+       [[ ${CATEGORY}/${PN} == dev-python/cython ]] && return
+       # grepping log files is expensive, so do it only for ebuilds using
+       # distutils-r1
+       has distutils-r1 ${INHERITED} || return
+       [[ ${BDEPEND} == *dev-python/cython* ]] && return
+
+       # Evaluate misc gcc warnings
+       if [[ -n ${PORTAGE_LOG_FILE} && -r ${PORTAGE_LOG_FILE} ]] ; then
+               # In debug mode, the grep calls will produce false positives
+               # if they're shown in the trace.
+               local reset_debug=0
+               if [[ ${-/x/} != $- ]] ; then
+                       set +x
+                       reset_debug=1
+               fi
+
+               local grep_cmd=grep
+               [[ ${PORTAGE_LOG_FILE} = *.gz ]] && grep_cmd=zgrep
+
+               # Force C locale to work around slow multibyte locales, bug 
#160234
+               # Force text mode as newer grep will treat non-ASCII (e.g. 
UTF-8) as
+               # binary when we run in the C locale.
+               local f=$(
+                       LC_CTYPE=C LC_COLLATE=C "${grep_cmd}" -a "Cythonizing" \
+                               "${PORTAGE_LOG_FILE}" | uniq
+               )
+               if [[ -n ${f} ]] ; then
+                       __vecho -ne '\n'
+                       eqawarn "QA Notice: Package seems to be missing a 
BDEPEND on dev-python/cython."
+                       eqawarn "${f}"
+                       __vecho -ne '\n'
+               fi
+
+               [[ ${reset_debug} = 1 ]] && set -x
+       fi
+}
+
+cython_dep_check
+: # guarantee successful exit
+
+# vim:ft=sh

Reply via email to