Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 932652

Summary: app-emulation/libvirt-10.1.0-r1 fails tests: no module named pytest
Product: Gentoo Linux Reporter: matoro <matoro_gentoo>
Component: Current packagesAssignee: Matthias Maier <tamiko>
Status: RESOLVED FIXED    
Severity: normal CC: matoro_gentoo, michal.privoznik, virtualization
Priority: Normal Keywords: PullRequest, TESTFAILURE
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=930933
https://github.com/gentoo/gentoo/pull/36814
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: build.log and emerge --info

Description matoro archtester 2024-05-24 19:16:30 UTC
3/145 libvirt:script / rpcgen-pytest                         FAIL             0.21s   exit status 1                                                   
>>> LANG=C LC_CTYPE=en_US.UTF-8 MALLOC_PERTURB_=132 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 LC_ALL='' ASAN_OPT
IONS=halt_on_error=1:abort_on_error=1:print_summary=1 /var/tmp/portage/app-emulation/libvirt-10.1.0-r1/temp/python3.12/bin/python3 -mpytest /var/tmp/por
tage/app-emulation/libvirt-10.1.0-r1/work/libvirt-10.1.0-build/../libvirt-10.1.0/scripts/rpcgen/tests/test_generator.py /var/tmp/portage/app-emulation/l
ibvirt-10.1.0-r1/work/libvirt-10.1.0-build/../libvirt-10.1.0/scripts/rpcgen/tests/test_lexer.py /var/tmp/portage/app-emulation/libvirt-10.1.0-r1/work/li
bvirt-10.1.0-build/../libvirt-10.1.0/scripts/rpcgen/tests/test_parser.py                                                                                
 ✀                                                                                                                                                      
stderr:                                                                                                                                                 
/usr/bin/python3.12: No module named pytest
Comment 1 matoro archtester 2024-05-24 19:17:11 UTC
Created attachment 894272 [details]
build.log and emerge --info
Comment 2 Michal Prívozník 2024-05-25 05:17:25 UTC
From build.log:

Program pytest found: YES (/usr/bin/pytest)
...
  3/145 libvirt:script / rpcgen-pytest                         FAIL             0.21s   exit status 1
>>> LANG=C LC_CTYPE=en_US.UTF-8 MALLOC_PERTURB_=132 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 LC_ALL='' ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 /var/tmp/portage/app-emulation/libvirt-10.1.0-r1/temp/python3.12/bin/python3 -mpytest /var/tmp/portage/app-emulation/libvirt-10.1.0-r1/work/libvirt-10.1.0-build/../libvirt-10.1.0/scripts/rpcgen/tests/test_generator.py /var/tmp/portage/app-emulation/libvirt-10.1.0-r1/work/libvirt-10.1.0-build/../libvirt-10.1.0/scripts/rpcgen/tests/test_lexer.py /var/tmp/portage/app-emulation/libvirt-10.1.0-r1/work/libvirt-10.1.0-build/../libvirt-10.1.0/scripts/rpcgen/tests/test_parser.py
 ✀  
stderr:
/usr/bin/python3.12: No module named pytest


Now, libvirt checks for presence of /usr/bin/pytest assuming 'python -mpytest' is going to work then. Just out of curiosity - what package provides the path?
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-25 05:35:17 UTC
You need to use python-any-r1 here to ensure pytest is available for the Python used during the build. Check out https://projects.gentoo.org/python/guide/any.html#conditional-python-use.
Comment 4 Larry the Git Cow gentoo-dev 2024-05-28 01:59:03 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bba723505f488b52bd593869b5b9a0df096ffbb4

commit bba723505f488b52bd593869b5b9a0df096ffbb4
Author:     Michal Privoznik <michal.privoznik@gmail.com>
AuthorDate: 2024-05-25 16:40:56 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-05-28 01:51:21 +0000

    app-emulation/libvirt: Drag in dev-python/pytest
    
    As of its upstream commit v9.10.0-rc1~114 libvirt introduced its
    own RPC generator written in python and also some tests for it.
    But these require pytest. Therefore, generate corresponding
    dependency if running tests.
    
    Closes: https://bugs.gentoo.org/932652
    Signed-off-by: Michal Privoznik <michal.privoznik@gmail.com>
    Closes: https://github.com/gentoo/gentoo/pull/36814
    Signed-off-by: Sam James <sam@gentoo.org>

 app-emulation/libvirt/libvirt-10.0.0-r2.ebuild | 10 ++++++++++
 app-emulation/libvirt/libvirt-10.1.0-r1.ebuild | 10 ++++++++++
 app-emulation/libvirt/libvirt-10.2.0.ebuild    | 10 ++++++++++
 app-emulation/libvirt/libvirt-10.3.0-r1.ebuild | 10 ++++++++++
 app-emulation/libvirt/libvirt-9999.ebuild      | 10 ++++++++++
 5 files changed, 50 insertions(+)
Comment 5 Larry the Git Cow gentoo-dev 2024-07-11 16:29:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=424908701d9854699393101d9a732cfd6a450ef7

commit 424908701d9854699393101d9a732cfd6a450ef7
Author:     Eli Schwartz <eschwartz@gentoo.org>
AuthorDate: 2024-07-11 15:14:42 +0000
Commit:     Eli Schwartz <eschwartz@gentoo.org>
CommitDate: 2024-07-11 16:28:29 +0000

    app-emulation/libvirt: implement a correct python_check_deps
    
    Due to portage design whereby commands which fail aren't considered
    failures unless you explicitly use `|| die`, a common footgun in bash
    scripting propagates throughout the portage ecosystem:
    
    the use of `cmd1 && cmd2` for conditional logic.
    
    This python_check_deps function did such, and then handled the case
    where `use test` was false by unconditionally ignoring the result of the
    previous line by returning 0. Hence, python_check_deps could never
    decide that an impl was unable to be used. As a result, if python 3.13
    and 3.12 were both installed, but $(python_gen_any_dep ...) discovered
    pytest installed solely for 3.12, portage would not reinstall pytest for
    3.13 support whereas the eclass would select 3.13 as the preferred
    (latest) python impl.
    
    Fix this by correctly using bash, shunning `cmd1 && cmd2`, and instead
    using `if cmd1; then cmd2; fi`, which returns correct return values
    based on the return value of both cmd1 and cmd2, without requiring
    hardcoded `return 0`s of any variety, unconditional or otherwise.
    
    Fixes: bba723505f488b52bd593869b5b9a0df096ffbb4
    Bug: https://bugs.gentoo.org/932652
    Closes: https://bugs.gentoo.org/935849
    Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>

 app-emulation/libvirt/libvirt-10.0.0-r3.ebuild | 5 +++--
 app-emulation/libvirt/libvirt-10.1.0-r2.ebuild | 5 +++--
 app-emulation/libvirt/libvirt-10.2.0-r1.ebuild | 5 +++--
 app-emulation/libvirt/libvirt-10.3.0-r2.ebuild | 5 +++--
 app-emulation/libvirt/libvirt-10.5.0.ebuild    | 5 +++--
 app-emulation/libvirt/libvirt-9999.ebuild      | 5 +++--
 6 files changed, 18 insertions(+), 12 deletions(-)