Am 17.06.21 um 03:05 schrieb Michael Ströder:
On 6/16/21 7:06 PM, Michael Ströder wrote:
Another question related to %check during build: Are any special things needed for C wrapper modules?
The C wrapper part of my ldap0 module seems not to be imported during %check:
https://build.opensuse.org/package/live_build_log/home:stroeder:branches:hom...
The shared library file _libldap0.cpython-3*m-x86_64-linux-gnu.so seems to get installed. %pytest_arch seems to work, despite some other details.
But I'd like to avoid pytest. Is there an arch-specific macro for using unittest module? Yes, %pyunittest_arch, or if you don't have a recent python-rpm-macros:
%{python_expand # export PYTHONPATH=%{buildroot}%{$python_sitearch} $python -B -m unittest discover -v } Two mistakes from my first reply: - %buildroot, not %builddir. - I forgot to mention the -B (or export PYTHONDONTWRITEBYTECODE=1). It should also be present in order to avoid unreproducible builds. The difference between pure libs and packages with C extensions is %{$python_sitelib} (= /usr/lib/python3.X/site-packages) vs %{$python_sitearch} (= /usr/lib64/python3.X/site-packages). For everything else, see [1, 2]. I am not a d:l:p maintainer, but I am sure the manual expansion is acceptable. Nobody is forced to use the macros. It is always good to check upstream's tox.ini or CI setups. Instead of discover, they may also directly invoke the test modules like `python -m unittest testdir.runtests` Another complication is the automatic population of sys.path with the current directory. You have to make sure, that `import mypkg` imports from the buildroot, not from the srcdir in order to find the compiled extensions. `pytest` usually does it as intended, `python -m unittest` does not [3, 4, 5].
Ciao, Michael.
Ben [1] Current README https://github.com/openSUSE/python-rpm-macros/blob/master/README.md [2] Old README of the Leap version: https://github.com/openSUSE/python-rpm-macros/blob/5feb6c1f09bb7771ef5826e51... [3] https://docs.pytest.org/en/6.2.x/pythonpath.html [4] https://docs.python.org/3/using/cmdline.html#cmdoption-m [5] https://lists.opensuse.org/archives/list/python@lists.opensuse.org/thread/QG...