Re: pytest ffi failure with a new port

From: Kubilay Kocak <koobs_at_FreeBSD.org>
Date: Wed, 29 Sep 2021 00:44:49 UTC
On 29/09/2021 7:38 am, Evgeniy Khramtsov via FreeBSD-ports wrote:
> Hi.
> 
> I am trying to get Wayland backend for x11-wm/qtile running, which
> requires three new dependencies: https://codeberg.org/ei/ports/commits/branch/qtile
> 
> I want to use tests/ in ports (i.e. x11/py-xkbcommon), so I added:
> 
> +do-test:
> +       @cd ${WRKSRC}/tests && ${PYTHON_CMD} -m pytest -v -rs
> +
> 
> to the Makefile, but make test results in:
> 
> ==================================== test session starts ====================================
> platform freebsd14 -- Python 3.8.12, pytest-4.6.11, py-1.9.0, pluggy-0.13.1 -- /usr/local/bin/python3.8
> cachedir: .pytest_cache
> rootdir: /usr/local/poudriere/ports/main/x11/py-xkbcommon/work-py38/xkbcommon-0.4
> collected 0 items / 1 errors
> 
> ========================================== ERRORS ===========================================
> ____________________________ ERROR collecting tests/test_xkb.py _____________________________
> ImportError while importing test module '/usr/local/poudriere/ports/main/x11/py-xkbcommon/work-py38/xkbcommon-0.4/tests/test_xkb.py'.
> Hint: make sure your test modules/packages have valid Python names.
> Traceback:
> test_xkb.py:6: in <module>
>      from xkbcommon import xkb
> ../xkbcommon/xkb.py:5: in <module>
>      from xkbcommon._ffi import ffi, lib
> E   ModuleNotFoundError: No module named 'xkbcommon._ffi'
> !!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!
> ================================== 1 error in 0.16 seconds ==================================
> *** Error code 2
> 
> I rg'ed the ports tree for various ways around this, but nothing worked,
> including PYTHONPATH, etc.
> 
> I have no idea why it can't find 'xkbcommon._ffi'. This port links to
> libxkbcommon, and the default x11-wm/qtile desktop with Wayland backend
> *seems* to be working. The same happens for other two ports (*._ffi not
> found).
> 
> Any idea what can be done with do-test?
> 

Hi Evgeniy,

try cd $WRKSRC && adding "tests/" to the end of the pytest invocation

Try also without tests/ at the end (pytest does autodiscovery)

Sometimes one needs to also do some PYTHONPATH environment mangling.

Jump on #freebsd-python on Libera IRC, and we can help you get it done

./koobs