Commit graph

396 commits

Author SHA1 Message Date
Jörg Behrmann
61c801498f
Merge pull request #175 from keszybz/python3.14-and-license-file
Clean up Makefile and add license file declaration
2026-06-19 12:49:19 +02:00
Zbigniew Jędrzejewski-Szmek
6c08dd474c pyproject: add support for Python 3.14 2026-06-19 12:48:38 +02:00
Zbigniew Jędrzejewski-Szmek
e9bf5e5e0e pyproject: declare the license file
This helps to get it installed.
2026-06-19 11:35:14 +02:00
Zbigniew Jędrzejewski-Szmek
66a5c1951e Makefile: update upload target
This might now work because pypi changes its rules, but at
least update to modern names of the commands for now.
2026-06-19 08:54:27 +02:00
Jörg Behrmann
3a7daca0dd
Merge pull request #172 from keszybz/silence-warning v236
Silence warnings
2026-06-18 15:06:10 +02:00
Zbigniew Jędrzejewski-Szmek
4982d8d2fb id128: update constants for systemd-261 2026-06-18 15:05:05 +02:00
Zbigniew Jędrzejewski-Szmek
5f9508755a meson: silence warning about unused parameters
It seems some gcc versions enable it by default, so we get a lot
of warnings.
2026-06-18 15:04:20 +02:00
Zbigniew Jędrzejewski-Szmek
e528de6c89 pyutil: silence a warning caused by Python.h
There is no great solution. Python.h expects to be included first and to be
allowed to pollute the define namespace. We don't want to do that, because in
other places we want to include sd-messages.h early, and also we want to use a
higher standard than the obsolete version that Python.h declares.
Unfortunately, there is no nice solution to this problem. So call #undef
enough times to silence warnings and after including the header, define the
standard for our code to a recent version.
2026-06-18 14:49:49 +02:00
Zbigniew Jędrzejewski-Szmek
a5a6c86b17 util: fix warning about const char* 2026-06-18 14:37:08 +02:00
Jörg Behrmann
9fedf95d29 NEWS: prepare changes for v236 2026-06-18 14:30:05 +02:00
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