Repository navigation
Python packaging tools can't resolve the package metadata without libsystemd #167
Description
Activity
I don't think your solution in #168 is unreasonable. I think something like this would be reasonable to add, since even know there are Linux distributions around that don't have libsystemd and are wildly used in the container space, so even with the constraint
sys_platform == 'linux', this might very well fail. It would be easier if python-systemd could always be included as a dependency and would not need to be sequestered as an optional dependency.The meson-python stance does not sound entirely not entirely reasonable, since not all information can be statically known (e.g. the version), and if I'm not mistaken they do support editable installs nowadays. Though, I've yet to read the thread fully.
That being said, uv's approach does sound problematic to me here as well, for the problem you are running into. Could you open an issue? The astral folk are usually extremely receptive and quick to act on reports and all around lovely to work with.
- added a commit that references this issue
on Mar 9, 2026 @sandhose The log you are showing, is from an old version which uses setuptools as build backend, not mesonpy.
The version with mesonpy is not released yet. When it is released, it will allow to publish wheel files and metadata to PyPI and people without libsystemd won't get trouble (becauseuvdoesn't need to try to build systemd-python on developer machine).I think just publishing a newer release will solve this issue. Even re-releasing v235 with a newet setuptools version might fix it. I looked a bit further into this...
Context: We are adopting renovate-bot in some repos. As part of the updates it will regenerate lockfiles, in the case of uv it will call
uv --lock. This in turn will instruct uv to determine certain metadata. As there are no wheels fetches these from the source distribution (sdist) and therein looks for apyproject.tomlandPKG-INFOfile. The latter exists, however, it hasMetadata-Version: 2.1which means that any field is assumed to be "dynamic". This prevents uv from using that file and instead in needs to build the wheel itself (https://docs.astral.sh/uv/reference/troubleshooting/build-failures/#why-does-uv-build-a-package). Asuv syncalso updates the lockfile I assume this is also the cause for this issue.My best guess is that simply republishing a new 235.1 with the old code but a newer setuptools version would already fix this. Generally, publishing wheels would be much appreciated but maybe this could be a good quick solution?
PS: Running
python3 -m buildon thev235tag (and no further changes) andtar --to-stdout -axf dist/systemd_python-235.tar.gz systemd_python-235/PKG-INFOshowsMetadata-Version: 2.4So I think branching there and releasing a 235.1 would be good :)
newet setuptools version might fix it
It will not, because of the way this project's
setup.pyscript is written. See my explanation here: #148Running
python3 -m buildon the v235 tagThat
-m buildcommand works thanks to the switch to pyproject.toml and mesonpy.Running
python3 -m buildon the v235 tagThat
-m buildcommand works thanks to the switch to pyproject.toml and mesonpy.As written, I ran it on the old version and it worked fine, so the switch to mesonpy can not possibly have affected it. It also generated a new PKG-INFO file which should be sufficient for UV to avoid building a wheel. Please see the documentation I linked (I also did quite a code dive into uv to confirm this as best as I could).
Indeed, I assumed that the published version was already using
mesonpy. I did try to build a sdist with the latest main (python -m build), then used the sdist locally withuv add ../python-systemd/dist/systemd_python-236.tar.gz -m "sys_platform == 'linux'"works.As @septatrix pointed out, it even works when checking out the
v235tag and building an sdist withpython -m build. Not sure what's up there 🤔As @septatrix pointed out, it even works when checking out the
v235tag and building an sdist withpython -m build. Not sure what's up there 🤔As I said, the reason uv currently refuses the sdist is because the metadata file therein (
PKG-INFO) has too old of a version which is unfit for uv. Simply rebuilding it generates a metadata file conforming to a newer spec version enabling uv to rely on it.Reacted by Quentin GliechThanks, I may be wrong.
A new version has just been tagged, can you check whether this resolves your issue?
Not unless you also publish a new version to pypi.
Yeah, we're working on it. The publishing has to be fixed unfortunately.
Reacted by Tobias Udtke and Nils KWill v236 also include pre-built wheels on pypi? Exciting if so.
I'm looking into that.
May I ask what the state of publishing to PyPI is?
Ping?
If someone cannot wait for new release of
systemd-pythonand just want some library to write tojournald, you can take journald-send a look.Any update @behrmann?
I ran into this whilst trying to move my project to replace
poetrywithuv.One interesting property of
uv, is that it creates a lockfile that works for all platforms. This means that even ifsystemd-pythonis only installed on Linux ("systemd-python>=231; sys_platform == 'linux'"in the dependencies), it needs to be able to resolve the package metadata.The problem is, as far as I can tell,
mesonpyalways run the meson build, even just for resolving the package metadata. And because the current meson build will hard-fail if libsystemd isn't available, regardless of the platform, it makes generating/updating theuvlockfile impossible on non-linux platforms.Some background about this issue on the mesonpy side can be read here: mesonbuild/meson-python#236
Now, this could be solved by making the C extension optional, and throw at runtime if it was built without it. It's not ideal, it would stop failing at build-time, but would make it possible to use
python-systemdin projects usinguvwithout requiringlibsystemdto be availableAnother very creative solution would be to write a special build backend which delegates to mesonpy in most cases, but provides its own
prepare_metadata_for_build_wheelimplementation… but that feels a bit overkillLast but not least, using another build backend than
mesonpycould be a solution, but definitely more involved.I'll put up a draft PR for the first solution shortly to let you evaluate how that feels