Commit graph

386 commits

Author SHA1 Message Date
Stefano Rivera
ce7c18dc0b Update Debian install instructions
Systemd has had a single -dev binary package since ~2014, so these have
not worked for a long time.

Noted in #138 (but not the main thrust of the issue)
2026-04-30 18:29:00 +02:00
Jelle van der Waa
cb50f8b057 meson: build docs with meson
Introduce a custom target `html` and a build configuration option
`docs` to build the sphinx html documentation.
2025-11-03 09:49:35 +01:00
Zbigniew Jędrzejewski-Szmek
f7883c1c5d
Merge pull request #161 from keszybz/copy-python-files
meson: copy .py files to build directory
2025-10-16 12:44:03 +02:00
Zbigniew Jędrzejewski-Szmek
f65499816c meson: add test to run pytest
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.
2025-10-15 18:03:56 +02:00
Zbigniew Jędrzejewski-Szmek
17016e1a76 meson: copy .py files to build directory
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 =============================
2025-10-15 18:03:31 +02:00
Zbigniew Jędrzejewski-Szmek
e6877e54a4 meson: drop '-impl' from phony target output
I think this was needed as some point in meson, but it isn't anymore and
we dropped those in systemd a while ago.
2025-10-15 18:03:11 +02:00
Jörg Behrmann
e77279d606 test: drop SO_PASSCRED python2 workaround 2025-10-15 16:47:11 +02:00
Jörg Behrmann
5b6d4fd0a9 journal: use datetime.timestamp() instead of int-float-stftime-dance
datetime.timestamp() will already return the time as a float, so returning it
as a string and parsing that back to a float can be omitted.
2025-10-15 16:47:11 +02:00
Jörg Behrmann
8f12291b95 tests: use ENOMEDIUM in test_id128 2025-10-15 16:47:11 +02:00
Zbigniew Jędrzejewski-Szmek
1afbdabfb9
Merge pull request #160 from keszybz/modernize-code-and-silence-all-warnings
Modernize code and silence all warnings
2025-10-15 09:59:26 +02:00
Zbigniew Jędrzejewski-Szmek
163a99aa25 modules: include Python.h from one place only, clean up includes
systemd headers should be included using <>.
And use a single include of Python.h and define PY_SSIZE_T_CLEAN
before it, so that we're using a consistent API everywhere.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
5906f045a4 meson: add global defines using add_project_arguments()
We're not going to be compiling any other C code, so let's simplify
this.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
6e9b86eb1d modules: get rid of python2-era compat ifdefs
They were a 1:1 mapping anyway.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
92db8b9cd4 modules: drop references to IOError
Since Python 3.0 it is an alias for OSError.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
f54b50c82e modules: modernize variable declarations 2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
549e3cb614 reader: rename .j to .journal
One-letter name is fine for a local variable, but it seems iffy to name
a structure field like this.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
329e71a18d daemon: silence warning about casts for kwargs functions
[6/18] Compiling C object src/systemd/_daemon.cpython-313-x86_64-linux-gnu.so.p/_daemon.c.o
../src/systemd/_daemon.c:415:37: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
  415 |         { "notify",                 (PyCFunction) notify,     METH_VARARGS | METH_KEYWORDS, notify__doc__                },
      |                                     ^
../src/systemd/_daemon.c:416:37: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
  416 |         { "_listen_fds",            (PyCFunction) listen_fds, METH_VARARGS | METH_KEYWORDS, listen_fds__doc__            },
      |                                     ^
../src/systemd/_daemon.c:417:37: warning: cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *, struct _object *)’} to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’} [-Wcast-function-type]
  417 |         { "_listen_fds_with_names", (PyCFunction) listen_fds_with_names,
      |                                     ^

This is a problem in the Python C API… They should have used a union type.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
35f146f2e6 login: silence warning about missing initializer for slots
[5/10] Compiling C object src/systemd/login.cpython-313-x86_64-linux-gnu.so.p/login.c.o
../src/systemd/login.c:321:1: warning: missing initializer for field ‘m_slots’ of ‘struct PyModuleDef’ [-Wmissing-field-initializers]
  321 | };
      | ^
In file included from /usr/include/python3.13/Python.h:95,
                 from ../src/systemd/login.c:6:
/usr/include/python3.13/moduleobject.h:113:21: note: ‘m_slots’ declared here
  113 |   PyModuleDef_Slot *m_slots;
      |                     ^~~~~~~
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
764a131110 modules: indent tables
Only whitespace changes.
2025-10-15 09:50:59 +02:00
Zbigniew Jędrzejewski-Szmek
56e2adccc5 reader: drop kwargs declaration in the _reader.Journal.add_match registration
Drop specification of kwargs in the _reader.Journal.add_match registration. The
handling was never implemented, so any any kwargs would be summarilly ignored.

The handling of kwargs is done in the python wrapper, so no kwargs are passed
to the native C function (and would be ignored if they were). IIRC, the plan
was initially to do this in the C extension, but then we realized that this is
very much not a hot path and doing in the the wrapper is just fine.
2025-10-15 09:44:11 +02:00
Jörg Behrmann
63961267fc
Merge pull request #157 from keszybz/update-constants
Update constants for systemd 258
2025-10-14 16:12:23 +02:00
Zbigniew Jędrzejewski-Szmek
87e9eda858 reader: drop pointless type suffixes
In C, a narrow type is automatically extended, so those verbose suffixes
are not needed for anything.
2025-10-11 22:30:10 +02:00
Zbigniew Jędrzejewski-Szmek
3ab8f5b753 modules: silence warnings about unused params
_unused_ is used for 'self' wherever the function does not use self.
assert(!args) is added in the places where METH_NOARGS is used.
assert(self) is added in a few places where self _is_ used.
2025-10-11 22:30:10 +02:00
Zbigniew Jędrzejewski-Szmek
1e29ed11ad id128: update constants for systemd 258
The previous commit changes the sorting algorithm, so a few lines moved
up or down a bit.
2025-10-11 22:26:41 +02:00
Zbigniew Jędrzejewski-Szmek
7704ae04c6 meson: hook up update-constants helper
$ ninja -C build update-constants -v
ninja: Entering directory `build'
[1/1] /home/zbyszek/src/python-systemd/update-constants.py /home/zbyszek/src/python-systemd/src/systemd/id128-constants.h /home/zbyszek/src/python-systemd/docs/id128.rst /home/zbyszek/src/python-systemd/src/systemd/id128-defines.h /usr/include/systemd/sd-messages.h
Writing /home/zbyszek/src/python-systemd/src/systemd/id128-constants.h…
Writing /home/zbyszek/src/python-systemd/src/systemd/id128-defines.h…
Writing /home/zbyszek/src/python-systemd/docs/id128.rst…

The helper is updated to do the everything in the python script. The wrapper in
Makefile is dropped. It wasn't working properly anyway, and I think the version
in meson is enough.
2025-10-11 22:26:41 +02:00
Zbigniew Jędrzejewski-Szmek
628319c6ec
Merge pull request #156 from keszybz/drop-copyright-tags
Drop copyright tags. All people who were listed have given agreement in the pull request.
2025-10-05 08:32:59 +02:00
Jelle van der Waa
93ace3f653 Remove unused MANIFEST.IN
With the switch to meson-python, meson makes the dist which includes
everything required already by default. (meson-python also does not
support a MANIFEST file)
2025-10-04 14:25:25 +02:00
Zbigniew Jędrzejewski-Szmek
32ca47f6f2 reader: fix indentation 2025-10-03 18:11:44 +02:00
Jörg Behrmann
a32fcd00c5
Merge pull request #154 from keszybz/modernize-file-headers
Modernize file headers
2025-10-03 17:25:00 +02:00
Zbigniew Jędrzejewski-Szmek
a7623b30b2 Drop Steven's copyright tags 2025-10-03 16:32:44 +02:00
Zbigniew Jędrzejewski-Szmek
e1adb2410b Drop Marti's copyright tags 2025-10-03 16:32:44 +02:00
Zbigniew Jędrzejewski-Szmek
1101593edd Drop David's copyright tags 2025-10-03 16:32:44 +02:00
Zbigniew Jędrzejewski-Szmek
84fb33c219 Drop Lennart's copyright tags 2025-10-03 16:32:44 +02:00
Zbigniew Jędrzejewski-Szmek
655cd0ea96 Drop my copyright tags
The copyright is implicit and git blame provides a better overview
of who changed which file.
2025-10-03 16:32:44 +02:00
Zbigniew Jędrzejewski-Szmek
0677c4a2a5 Use SPDX license tags instead of old-style license headers
This matches the change that was done in the systemd repo
a few years ago.
2025-10-03 16:32:42 +02:00
Zbigniew Jędrzejewski-Szmek
fd11077533 Drop some python2 remnants 2025-10-03 16:32:16 +02:00
Zbigniew Jędrzejewski-Szmek
bce69f553c dir-locals.el: update emacs config to match meson style
The config is copied from systemd. The existing config specified 4-space
indent for C, but individual files override this and the files in fact use
8 spaces.

The config for Python doesn't seem necessary anymore either. I think utf-8
is used everywhere by default.
2025-10-03 16:16:31 +02:00
Zbigniew Jędrzejewski-Szmek
eba21faa3b meson: remove unnecessary meson.build file 2025-10-03 14:36:25 +02:00
Jelle van der Waa
1417c40282 pyproject: move pytest configuration to pyproject.toml
With pytest 6 this is now supported.
2025-10-03 14:32:31 +02:00
Zbigniew Jędrzejewski-Szmek
b0acce412c
Merge pull request #148 from hongquan/feature/meson-build-step-1
Adopt pyproject.toml and Meson to build Python extension
2025-10-03 12:24:18 +02:00
Nguyễn Hồng Quân
2653d19fc7 Drop Python 3.7 and 3.8 2025-06-30 22:39:06 +07:00
Nguyễn Hồng Quân
31b17c0b29 Adopt pyproject.toml and Meson to build Python extension 2025-06-30 18:58:20 +07:00
Zbigniew Jędrzejewski-Szmek
9031424234 docs: update intersphinx_mapping
Newer sphinx doesn't like the old syntax:
  Running Sphinx v8.1.3
  loading translations [en]... done
  making output directory... done
  Converting `source_suffix = '.rst'` to `source_suffix = {'.rst': 'restructuredtext'}`.
  ERROR: Invalid value `None` in intersphinx_mapping['http://docs.python.org/']. Expected a two-element tuple or list.
2025-01-19 16:59:22 +01:00
Eric T. Johnson
3f0801c8ac Fix test failure
One usage of `connection_error` got missed when dropping Python 2 support.
2023-03-26 17:09:46 +02:00
Jelle van der Waa
684a6cc222 README: stop mentioning Python 2 build dependencies
Python 2 support was fully dropped in 802c8dcaa3 so it can
be a bit confusing to advertise Python 2 build dependencies in the
README.
2023-03-26 17:08:44 +02:00
Guiorgy
f95161fccd fixed PyPI url in last commit 2023-03-04 13:01:11 +01:00
Joerg Behrmann
802c8dcaa3 treewide: remove python 2 support and assume we have python 3.3+ 2023-02-11 14:39:52 +01:00
Zbigniew Jędrzejewski-Szmek
7e3313a15b
Merge pull request #123 from Guiorgy/patch-1
Update README.md
2023-02-11 14:39:12 +01:00
Guiorgy
9267af36d8
Update README.md
Moved pypi instructions under the Installation heading and added a pypi badge
2023-02-06 19:49:12 +04:00
Frantisek Sumsal
263dc92d55 ci: use CodeQL instead of LGTM
As LGTM is going to be shut down by EOY[0], let's move the code scanning to
CodeQL as recommended. Thanks to GH integration the results from such
scans will be shown both in the respective PR and in the Security ->
Code Scanning tab[1].

[0] https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/
[1] https://github.com/systemd/python-systemd/security/code-scanning
2022-09-22 13:13:56 +02:00