Hi Miro, Miro Hrončok <mhroncok@xxxxxxxxxx> writes: > Hello Python RPM packagers, > > based on some discussion in the "F35 Change: Python Packaging Guidelines > overhaul (System-Wide Change proposal)" thread [0], I've drafted a macro that > can help to test-import a Python module in %check when no other tests exist or > are when they cannot be executed during build [1]. > > The semantics is quite simple: > > > %check > %py3_check_import mymodule mymodule.submodule > > When all listed modules are successfully imported, "nothing happens", when at > lest one fails to import, the entire build fails. The above line is translated > very-roughly to `python3 -c 'import mymodule, mymodule.submodule'` (see the > implementation [0] for more accurate representation). Given the Python > semantics, it is possible to use commas as module separators as well (but no > parentheses). > > The %buildroot's %pythn3_site{lib,arch} is added to PYTHONPATH. > > The runtime dependencies are obviously needed for this to work, so they need to > be manually BuildRequired or even better, generated in %generate_buildrequires > via `%pyproject_buildrequires -r` to use this macro. > > The macro can be used repeatedly when importing multiple modules at once is > undesired (e.g. when only one module can be imported from the same Python > interpreter): > > %check > %py3_check_import mymodule.either > %py3_check_import mymodule.or > > Before I merge this and backport to all Fedoras and EPELs, I'd like to know: > > - Do you have better ideas for the macro name? > - Do you have better ideas for the macro semantics? This looks pretty good imho. Would it somehow be possible for the macro to automatically try to import the module name from the generated python3.Ydist() provides? That would make the macro even more convenient to use and reduce any potential user error further. Cheers, Dan _______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure