-
Notifications
You must be signed in to change notification settings - Fork 69
meson: copy .py files to build directory #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/cc @jelly |
Neat, with this you can also introduce a test target:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Tested it and it works. I do wonder why it didn't work when we copied in the files manually
src/systemd/test/meson.build
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to propose to not ship the tests in the module, since they are not really useful to users anyway. This way this file would also not be needed.
d7809a1
to
945484a
Compare
Reworked. The new meson file in the subdirectory is dropped, the tests are run from the source directory. I think we want to rework the sphinx build process to not require an installation, but let's do that in #158. |
Running
fails for me, because the Since I also mentioned moving the tests out of the sources, by moving the tests up to the project root and then adding a new
The I've not yet thought about how to do it without moving the tests up to the top-level, since |
I think this was needed as some point in meson, but it isn't anymore and we dropped those in systemd a while ago.
This seems to do the trick: $ ninja -C build $ PYTHONPATH=build/src/ python -c 'from systemd import id128; print(id128)' <module 'systemd.id128' from '/home/zbyszek/src/python-systemd/build/src/systemd/id128.cpython-313-x86_64-linux-gnu.so'> $ PYTHONPATH=build/src/ pytest src/systemd/test ... ============================ test session starts ============================= platform linux -- Python 3.13.4, pytest-8.3.4, pluggy-1.5.0 rootdir: /home/zbyszek/src/python-systemd configfile: pyproject.toml plugins: ... collected 61 items build/src/systemd/test/test_daemon.py ........................ [ 39%] build/src/systemd/test/test_id128.py .... [ 45%] build/src/systemd/test/test_journal.py ............................ [ 91%] build/src/systemd/test/test_login.py ..... [100%] ============================= 61 passed in 0.21s =============================
The python binary that was initially found is used to launch pytest. It turns out to be surprisingly hard to run 'pytest' in test() with the python binary detected using meson's python module. test() does not allow the "program" argument to be a str, which is what python module's .full_path() returns. So let's "find" the program again. This results in one line of noise in meson output, but I don't see a nicer way. 'ninja -C build test' works. 'meson test -C build' is better, because it can be called with '-v' to print details of the test.
945484a
to
f654998
Compare
Oh, I messed up the paths. Can you try the current version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked, installation into a venv works with plain python -m venv
and uv
. Tests run with meson setup, compile, test cycle.
This seems to do the trick: