From 31b17c0b29a0984bfc4152c9ce4af8e3b87bd685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?= Date: Mon, 30 Jun 2025 12:07:47 +0700 Subject: [PATCH 1/2] Adopt pyproject.toml and Meson to build Python extension --- .editorconfig | 3 + .github/workflows/build.yml | 47 +++++--- .github/workflows/codeql.yml | 11 +- .github/workflows/install.yml | 36 +++--- .gitignore | 4 + Makefile | 49 ++++----- README.md | 3 +- meson.build | 22 ++++ pyproject.toml | 61 +++++++++++ setup.py | 103 ------------------ src/meson.build | 1 + {systemd => src/systemd}/.gitignore | 0 {systemd => src/systemd}/__init__.py | 0 {systemd => src/systemd}/_daemon.c | 0 {systemd => src/systemd}/_journal.c | 0 {systemd => src/systemd}/_reader.c | 0 {systemd => src/systemd}/daemon.py | 0 {systemd => src/systemd}/id128-constants.h | 0 {systemd => src/systemd}/id128-defines.h | 0 {systemd => src/systemd}/id128.c | 0 {systemd => src/systemd}/journal.py | 0 {systemd => src/systemd}/login.c | 0 {systemd => src/systemd}/macro.h | 0 src/systemd/meson.build | 61 +++++++++++ {systemd => src/systemd}/pyutil.c | 0 {systemd => src/systemd}/pyutil.h | 0 {systemd => src/systemd}/strv.c | 0 {systemd => src/systemd}/strv.h | 0 {systemd => src/systemd}/test/test_daemon.py | 0 {systemd => src/systemd}/test/test_id128.py | 0 {systemd => src/systemd}/test/test_journal.py | 0 {systemd => src/systemd}/test/test_login.py | 0 {systemd => src/systemd}/util.c | 0 {systemd => src/systemd}/util.h | 0 34 files changed, 233 insertions(+), 168 deletions(-) create mode 100644 .editorconfig create mode 100644 meson.build create mode 100644 pyproject.toml delete mode 100644 setup.py create mode 100644 src/meson.build rename {systemd => src/systemd}/.gitignore (100%) rename {systemd => src/systemd}/__init__.py (100%) rename {systemd => src/systemd}/_daemon.c (100%) rename {systemd => src/systemd}/_journal.c (100%) rename {systemd => src/systemd}/_reader.c (100%) rename {systemd => src/systemd}/daemon.py (100%) rename {systemd => src/systemd}/id128-constants.h (100%) rename {systemd => src/systemd}/id128-defines.h (100%) rename {systemd => src/systemd}/id128.c (100%) rename {systemd => src/systemd}/journal.py (100%) rename {systemd => src/systemd}/login.c (100%) rename {systemd => src/systemd}/macro.h (100%) create mode 100644 src/systemd/meson.build rename {systemd => src/systemd}/pyutil.c (100%) rename {systemd => src/systemd}/pyutil.h (100%) rename {systemd => src/systemd}/strv.c (100%) rename {systemd => src/systemd}/strv.h (100%) rename {systemd => src/systemd}/test/test_daemon.py (100%) rename {systemd => src/systemd}/test/test_id128.py (100%) rename {systemd => src/systemd}/test/test_journal.py (100%) rename {systemd => src/systemd}/test/test_login.py (100%) rename {systemd => src/systemd}/util.c (100%) rename {systemd => src/systemd}/util.h (100%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..04eb116 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,3 @@ +[meson.build] +indent_style = space +indent_size = 8 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93f1bb1..c653c83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ # vi: ts=2 sw=2 et: # SPDX-License-Identifier: LGPL-2.1-or-later # -name: Build test +name: Build on: pull_request: push: @@ -14,27 +14,35 @@ permissions: jobs: build: - runs-on: ubuntu-20.04 - concurrency: - group: ${{ github.workflow }}-${{ matrix.python }}-${{ github.ref }} - cancel-in-progress: true strategy: fail-fast: false matrix: + os: ["ubuntu-22.04", "ubuntu-24.04"] python: [ "3.7", "3.8", "3.9", "3.10", - "3.11.0-rc.1", + "3.11", + "3.12", + "3.13", ] - name: Python ${{ matrix.python }} + exclude: + - os: "ubuntu-22.04" + python: "3.13" + - os: "ubuntu-24.04" + python: "3.7" + runs-on: ${{ matrix.os }} + concurrency: + group: ${{ github.workflow }}-${{ matrix.python }}-${{ matrix.os }}-${{ github.ref }} + cancel-in-progress: true + name: Python ${{ matrix.python }} on ${{ matrix.os }} steps: - name: Repository checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Configure Python ${{ matrix.python }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: x64 @@ -43,14 +51,21 @@ jobs: run: | sudo apt -y update sudo apt -y install gcc libsystemd-dev - python -m pip install pytest sphinx + python -m pip install -U --break-system-packages pip build + - name: Install Sphinx (old pip) + if: ${{ matrix.python == '3.7' || matrix.python == '3.8' }} + run: python -m pip install sphinx + + - name: Install Sphinx (new pip) + if: ${{ matrix.python != '3.7' && matrix.python != '3.8' }} + run: python -m pip install --group docs + + # Note: The `pip install --group` is available on pip v25+ - name: Build (Python ${{ matrix.python }}) run: | set -x - make -j - make doc SPHINXOPTS="-W -v" - - - name: Test (Python ${{ matrix.python }}) - run: | - make check + python -m build -Cbuild-dir=build + python -m pip install . + cd build + python -m sphinx -b html -W -v ../docs html diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 48f504d..0e799f1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -18,7 +18,7 @@ permissions: jobs: analyze: name: Analyze - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 concurrency: group: ${{ github.workflow }}-${{ matrix.language }}-${{ github.ref }} cancel-in-progress: true @@ -33,10 +33,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} queries: +security-extended,security-and-quality @@ -45,9 +45,10 @@ jobs: run: | sudo apt -y update sudo apt -y install gcc libsystemd-dev + python -m pip install -U --break-system-packages pip build - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index c1d202c..055574f 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -2,7 +2,7 @@ # vi: ts=2 sw=2 et: # SPDX-License-Identifier: LGPL-2.1-or-later # -name: Install test +name: Install then test on: pull_request: push: @@ -24,16 +24,14 @@ jobs: container: [ "archlinux:latest", "debian:testing", - "quay.io/centos/centos:stream8", + "quay.io/centos/centos:stream10", "quay.io/fedora/fedora:rawhide", - "ubuntu:focal", + "ubuntu:noble", ] container: image: ${{ matrix.container }} name: ${{ matrix.container }} steps: - - name: Repository checkout - uses: actions/checkout@v2 - name: Install dependencies shell: bash @@ -51,10 +49,14 @@ jobs: case "$DIST_ID" in arch) - pacman --noconfirm -Sy "${DEPS_COMMON[@]}" systemd-libs - python3 -m ensurepip + pacman --noconfirm -Sy -u "${DEPS_COMMON[@]}" systemd-libs python-pip + ;; + centos) + dnf config-manager --set-enabled crb + dnf install -y epel-release + dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ;; - centos|fedora) + fedora) dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ;; ubuntu|debian) @@ -66,14 +68,22 @@ jobs: exit 1 esac - python3 -m pip install pytest sphinx + python3 -m pip install -U --break-system-packages build pytest + + - name: Fix Git config to satisfy Meson + run: git config --global safe.directory "*" + + # Checkout repo after installing Git, or the "checkout" GH Action will download our source as non-Git repo, making Meson fail + # to build Python source dist. + - name: Repository checkout + uses: actions/checkout@v4 - - name: Build & install + - name: Install & test shell: bash run: | set -x - python3 -m pip install -I -v . - # Avoid importing the systemd module from the git repository - cd / + git --version + python3 -m build + python3 -m pip install --break-system-packages . python3 -c 'from systemd import journal; print(journal.__version__)' pytest -v --pyargs systemd diff --git a/.gitignore b/.gitignore index e6610fe..caaa83a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ sdist develop-eggs .installed.cfg MANIFEST +.venv # Installer logs pip-log.txt @@ -30,3 +31,6 @@ pip-log.txt #Mr Developer .mr.developer.cfg + +# Zed +.zed diff --git a/Makefile b/Makefile index 02d357f..9a28097 100644 --- a/Makefile +++ b/Makefile @@ -3,67 +3,57 @@ SED = sed ETAGS = etags INCLUDE_DIR := $(shell pkg-config --variable=includedir libsystemd) INCLUDE_FLAGS := $(shell pkg-config --cflags libsystemd) -VERSION := $(shell $(PYTHON) setup.py --version) +VERSION := $(shell meson introspect --projectinfo build | jq -r .version) TESTFLAGS = -v - -define buildscript -import sys, sysconfig, setuptools -sversion = int(setuptools.__version__.split(".")[0]) -end = sys.implementation.cache_tag if sversion >= 61 else "{}.{}".format(*sys.version_info[:2]) -print("build/lib.{}-{}".format(sysconfig.get_platform(), end)) -endef - -builddir := $(shell $(PYTHON) -c '$(buildscript)') +BUILD_DIR = build all: build .PHONY: update-constants update-constants: update-constants.py $(INCLUDE_DIR)/systemd/sd-messages.h - $(PYTHON) $+ systemd/id128-defines.h | \ + $(PYTHON) $+ src/systemd/id128-defines.h | \ sort -u | \ - tee systemd/id128-defines.h.tmp | \ + tee src/systemd/id128-defines.h.tmp | \ $(SED) -n -r 's/,//g; s/#define (SD_MESSAGE_[A-Z0-9_]+)\s.*/add_id(m, "\1", \1) JOINER/p' | \ - sort -u >systemd/id128-constants.h.tmp - mv systemd/id128-defines.h{.tmp,} - mv systemd/id128-constants.h{.tmp,} + sort -u > src/systemd/id128-constants.h.tmp + mv src/systemd/id128-defines.h{.tmp,} + mv src/systemd/id128-constants.h{.tmp,} ($(SED) 9q docs/id128.rst.tmp + src/systemd/id128-defines.h) >docs/id128.rst.tmp mv docs/id128.rst{.tmp,} build: - $(PYTHON) setup.py build_ext $(INCLUDE_FLAGS) - $(PYTHON) setup.py build + $(PYTHON) -m build -Cbuild-dir=$(BUILD_DIR) install: - $(PYTHON) setup.py install --skip-build $(if $(DESTDIR),--root $(DESTDIR)) + $(PYTHON) -m pip install . dist: - $(PYTHON) setup.py sdist + $(PYTHON) -m build --sdist sign: dist/systemd-python-$(VERSION).tar.gz gpg --detach-sign -a dist/systemd-python-$(VERSION).tar.gz clean: - rm -rf build systemd/*.so systemd/*.py[co] *.py[co] systemd/__pycache__ + rm -rf $(BUILD_DIR) systemd/*.so systemd/*.py[co] *.py[co] systemd/__pycache__ distclean: clean rm -rf dist MANIFEST SPHINXOPTS += -D version=$(VERSION) -D release=$(VERSION) -sphinx-%: build - cd build && \ - PYTHONPATH=../$(builddir) $(PYTHON) -m sphinx -b $* $(SPHINXOPTS) ../docs $* - @echo Output has been generated in build/$* +sphinx-%: install + mkdir $(BUILD_DIR) && cd $(BUILD_DIR) && $(PYTHON) -m sphinx -b $* $(SPHINXOPTS) ../docs $* + @echo Output has been generated in $(BUILD_DIR)/$* doc: sphinx-html -check: build - (cd $(builddir) && $(PYTHON) -m pytest . ../../docs $(TESTFLAGS)) +check: build install + ($(PYTHON) -m pytest src/systemd/test docs $(TESTFLAGS)) www_target = www.freedesktop.org:/srv/www.freedesktop.org/www/software/systemd/python-systemd doc-sync: - rsync -rlv --delete --omit-dir-times build/html/ $(www_target)/ + rsync -rlv --delete --omit-dir-times $(BUILD_DIR)/html/ $(www_target)/ upload: dist/systemd-python-$(VERSION).tar.gz dist/systemd-python-$(VERSION).tar.gz.asc twine-3 upload $+ @@ -72,7 +62,6 @@ TAGS: $(shell git ls-files systemd/*.[ch]) $(ETAGS) $+ shell: -# we change the directory because python insists on adding $CWD to path - (cd $(builddir) && $(PYTHON)) + $(PYTHON) .PHONY: build install dist sign upload clean distclean TAGS doc doc-sync shell diff --git a/README.md b/README.md index 91809ea..d2edcce 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,8 @@ Quick way to view output with all fields as it comes in: Test Builds (for Development) ============================= - python setup.py build_ext -i + python -m build + python -m pip install . python >>> from systemd import journal >>> journal.send("Test") diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..22c80da --- /dev/null +++ b/meson.build @@ -0,0 +1,22 @@ +project( + 'python-systemd', + 'c', + version: '236', + license: 'LGPL-2.1-or-later', + default_options: ['warning_level=2', 'c_std=c99'], + meson_version: '>= 1.8.0', +) + +# Dependencies +python = import('python').find_installation('python3', pure: false) +python_dep = python.dependency() + +libsystemd_dep = dependency('libsystemd') + +common_c_args = [ + '-DPACKAGE_VERSION="@0@"'.format(meson.project_version()), + '-DLIBSYSTEMD_VERSION=@0@'.format(libsystemd_dep.version()), +] + +subdir('src') + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5f353ff --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,61 @@ +[project] +name = "systemd-python" +dynamic = ["version"] +description = "Python interface for libsystemd" +readme = "README.md" +license = { text = "LGPL-2.1-or-later" } +authors = [{ email = "david@davidstrauss.net" }] +maintainers = [ + { name = "systemd developers", email = "systemd-devel@lists.freedesktop.org" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", + "Operating System :: POSIX :: Linux", + "Programming Language :: C", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: System :: Logging", + "Topic :: System :: Systems Administration", +] +keywords = ["systemd", "journal", "logging", "daemon"] +requires-python = ">=3.7" +dependencies = [] + +[project.urls] +Homepage = "https://github.com/systemd/python-systemd" +Repository = "https://github.com/systemd/python-systemd.git" +Issues = "https://github.com/systemd/python-systemd/issues" +Documentation = "https://www.freedesktop.org/software/systemd/python-systemd/" + +[dependency-groups] +test = ["pytest", "pytest-cov"] +docs = ["sphinx"] +build = [ + "meson>=1.8.2", + "twine>=4.0.2", +] + +[build-system] +requires = ["meson-python", "ninja", "meson"] +build-backend = "mesonpy" + +[tool.coverage.run] +source = ["systemd"] +omit = ["systemd/test/*"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index fe9c03a..0000000 --- a/setup.py +++ /dev/null @@ -1,103 +0,0 @@ -import sys, os -from setuptools import setup, Extension -from subprocess import Popen, PIPE, check_output - -def call(*cmd): - cmd = Popen(cmd, - stdout=PIPE, stderr=PIPE, - universal_newlines=True) - if cmd.wait() == 0: - return cmd.returncode, cmd.stdout.read() - else: - return cmd.returncode, cmd.stderr.read() - -def pkgconfig(package, **kw): - pkg_version = package.replace('-', '_').upper() + '_VERSION' - flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'} - pkgconf = os.getenv('PKG_CONFIG', 'pkg-config') - status, result = call(pkgconf, '--libs', '--cflags', package) - if status != 0: - return status, result - for token in result.split(): - kw.setdefault(flag_map.get(token[:2]), []).append(token[2:]) - - # allow version detection to be overridden using environment variables - version = os.getenv(pkg_version) - if not version: - version = check_output([pkgconf, '--modversion', package], - universal_newlines=True).strip() - pair = (pkg_version, version) - defines = kw.setdefault('define_macros', []) - if pair not in defines: - defines.append(pair) - return status, kw - -def lib(*names, **kw): - if '--version' in sys.argv: - return {} - results = [] - for name in names: - status, result = pkgconfig(name, **kw) - if status == 0: - return result - results.append(result) - sys.stderr.write('Cannot find ' + ' or '.join(names) + ':\n\n' - + '\n'.join(results) + '\n') - sys.exit(status) - -version = '235' -defines = {'define_macros':[('PACKAGE_VERSION', '"{}"'.format(version))]} - -_journal = Extension('systemd/_journal', - sources = ['systemd/_journal.c', - 'systemd/pyutil.c'], - extra_compile_args=['-std=c99', '-Werror=implicit-function-declaration'], - **lib('libsystemd', 'libsystemd-journal', **defines)) -_reader = Extension('systemd/_reader', - sources = ['systemd/_reader.c', - 'systemd/pyutil.c', - 'systemd/strv.c'], - extra_compile_args=['-std=c99', '-Werror=implicit-function-declaration'], - **lib('libsystemd', 'libsystemd-journal', **defines)) -_daemon = Extension('systemd/_daemon', - sources = ['systemd/_daemon.c', - 'systemd/pyutil.c', - 'systemd/util.c'], - extra_compile_args=['-std=c99', '-Werror=implicit-function-declaration'], - **lib('libsystemd', 'libsystemd-daemon', **defines)) -id128 = Extension('systemd/id128', - sources = ['systemd/id128.c', - 'systemd/pyutil.c'], - extra_compile_args=['-std=c99', '-Werror=implicit-function-declaration'], - **lib('libsystemd', 'libsystemd-id128', **defines)) -login = Extension('systemd/login', - sources = ['systemd/login.c', - 'systemd/pyutil.c', - 'systemd/strv.c'], - extra_compile_args=['-std=c99', '-Werror=implicit-function-declaration'], - **lib('libsystemd', 'libsystemd-login', **defines)) -setup (name = 'systemd-python', - version = version, - description = 'Python interface for libsystemd', - author_email = 'david@davidstrauss.net', - maintainer = 'systemd developers', - maintainer_email = 'systemd-devel@lists.freedesktop.org', - url = 'https://github.com/systemd/python-systemd', - license = 'LGPLv2+', - classifiers = [ - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: System :: Logging', - 'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)', - ], - py_modules = ['systemd.journal', 'systemd.daemon', - 'systemd.test.test_daemon', - 'systemd.test.test_journal', - 'systemd.test.test_login', - 'systemd.test.test_id128'], - ext_modules = [_journal, - _reader, - _daemon, - id128, - login]) diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..250e6d6 --- /dev/null +++ b/src/meson.build @@ -0,0 +1 @@ +subdir('systemd') diff --git a/systemd/.gitignore b/src/systemd/.gitignore similarity index 100% rename from systemd/.gitignore rename to src/systemd/.gitignore diff --git a/systemd/__init__.py b/src/systemd/__init__.py similarity index 100% rename from systemd/__init__.py rename to src/systemd/__init__.py diff --git a/systemd/_daemon.c b/src/systemd/_daemon.c similarity index 100% rename from systemd/_daemon.c rename to src/systemd/_daemon.c diff --git a/systemd/_journal.c b/src/systemd/_journal.c similarity index 100% rename from systemd/_journal.c rename to src/systemd/_journal.c diff --git a/systemd/_reader.c b/src/systemd/_reader.c similarity index 100% rename from systemd/_reader.c rename to src/systemd/_reader.c diff --git a/systemd/daemon.py b/src/systemd/daemon.py similarity index 100% rename from systemd/daemon.py rename to src/systemd/daemon.py diff --git a/systemd/id128-constants.h b/src/systemd/id128-constants.h similarity index 100% rename from systemd/id128-constants.h rename to src/systemd/id128-constants.h diff --git a/systemd/id128-defines.h b/src/systemd/id128-defines.h similarity index 100% rename from systemd/id128-defines.h rename to src/systemd/id128-defines.h diff --git a/systemd/id128.c b/src/systemd/id128.c similarity index 100% rename from systemd/id128.c rename to src/systemd/id128.c diff --git a/systemd/journal.py b/src/systemd/journal.py similarity index 100% rename from systemd/journal.py rename to src/systemd/journal.py diff --git a/systemd/login.c b/src/systemd/login.c similarity index 100% rename from systemd/login.c rename to src/systemd/login.c diff --git a/systemd/macro.h b/src/systemd/macro.h similarity index 100% rename from systemd/macro.h rename to src/systemd/macro.h diff --git a/src/systemd/meson.build b/src/systemd/meson.build new file mode 100644 index 0000000..f39f8fb --- /dev/null +++ b/src/systemd/meson.build @@ -0,0 +1,61 @@ +# Build _journal extension module +python.extension_module( + '_journal', + ['_journal.c', 'pyutil.c'], + dependencies: [libsystemd_dep], + c_args: common_c_args, + install: true, + subdir: 'systemd', +) + +# Build _reader extension module +python.extension_module( + '_reader', + ['_reader.c', 'pyutil.c', 'strv.c'], + dependencies: [libsystemd_dep], + c_args: common_c_args, + install: true, + subdir: 'systemd', +) + +# Build _daemon extension module +python.extension_module( + '_daemon', + ['_daemon.c', 'pyutil.c', 'util.c'], + dependencies: [libsystemd_dep], + c_args: common_c_args, + install: true, + subdir: 'systemd', +) + +# Build id128 extension module +python.extension_module( + 'id128', + ['id128.c', 'pyutil.c'], + dependencies: [libsystemd_dep], + c_args: common_c_args, + install: true, + subdir: 'systemd', +) + +# Build login extension module +python.extension_module( + 'login', + ['login.c', 'pyutil.c', 'strv.c'], + dependencies: [libsystemd_dep], + c_args: common_c_args, + install: true, + subdir: 'systemd', +) + +# Install Python modules +python.install_sources('__init__.py', 'journal.py', 'daemon.py', subdir: 'systemd') + +# Install test modules +python.install_sources( + 'test/test_daemon.py', + 'test/test_journal.py', + 'test/test_login.py', + 'test/test_id128.py', + subdir: 'systemd/test', +) diff --git a/systemd/pyutil.c b/src/systemd/pyutil.c similarity index 100% rename from systemd/pyutil.c rename to src/systemd/pyutil.c diff --git a/systemd/pyutil.h b/src/systemd/pyutil.h similarity index 100% rename from systemd/pyutil.h rename to src/systemd/pyutil.h diff --git a/systemd/strv.c b/src/systemd/strv.c similarity index 100% rename from systemd/strv.c rename to src/systemd/strv.c diff --git a/systemd/strv.h b/src/systemd/strv.h similarity index 100% rename from systemd/strv.h rename to src/systemd/strv.h diff --git a/systemd/test/test_daemon.py b/src/systemd/test/test_daemon.py similarity index 100% rename from systemd/test/test_daemon.py rename to src/systemd/test/test_daemon.py diff --git a/systemd/test/test_id128.py b/src/systemd/test/test_id128.py similarity index 100% rename from systemd/test/test_id128.py rename to src/systemd/test/test_id128.py diff --git a/systemd/test/test_journal.py b/src/systemd/test/test_journal.py similarity index 100% rename from systemd/test/test_journal.py rename to src/systemd/test/test_journal.py diff --git a/systemd/test/test_login.py b/src/systemd/test/test_login.py similarity index 100% rename from systemd/test/test_login.py rename to src/systemd/test/test_login.py diff --git a/systemd/util.c b/src/systemd/util.c similarity index 100% rename from systemd/util.c rename to src/systemd/util.c diff --git a/systemd/util.h b/src/systemd/util.h similarity index 100% rename from systemd/util.h rename to src/systemd/util.h From 2653d19fc77b577e55b4496efeac67e5707fc8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?= Date: Mon, 30 Jun 2025 22:39:06 +0700 Subject: [PATCH 2/2] Drop Python 3.7 and 3.8 --- .github/workflows/build.yml | 13 +------------ pyproject.toml | 6 ++---- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c653c83..2dbc347 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,8 +19,6 @@ jobs: matrix: os: ["ubuntu-22.04", "ubuntu-24.04"] python: [ - "3.7", - "3.8", "3.9", "3.10", "3.11", @@ -30,8 +28,6 @@ jobs: exclude: - os: "ubuntu-22.04" python: "3.13" - - os: "ubuntu-24.04" - python: "3.7" runs-on: ${{ matrix.os }} concurrency: group: ${{ github.workflow }}-${{ matrix.python }}-${{ matrix.os }}-${{ github.ref }} @@ -53,19 +49,12 @@ jobs: sudo apt -y install gcc libsystemd-dev python -m pip install -U --break-system-packages pip build - - name: Install Sphinx (old pip) - if: ${{ matrix.python == '3.7' || matrix.python == '3.8' }} - run: python -m pip install sphinx - - - name: Install Sphinx (new pip) - if: ${{ matrix.python != '3.7' && matrix.python != '3.8' }} - run: python -m pip install --group docs - # Note: The `pip install --group` is available on pip v25+ - name: Build (Python ${{ matrix.python }}) run: | set -x python -m build -Cbuild-dir=build + python -m pip install --group docs python -m pip install . cd build python -m sphinx -b html -W -v ../docs html diff --git a/pyproject.toml b/pyproject.toml index 5f353ff..dc75dfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,6 @@ classifiers = [ "Operating System :: POSIX :: Linux", "Programming Language :: C", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -27,7 +25,7 @@ classifiers = [ "Topic :: System :: Systems Administration", ] keywords = ["systemd", "journal", "logging", "daemon"] -requires-python = ">=3.7" +requires-python = ">=3.9" dependencies = [] [project.urls] @@ -45,7 +43,7 @@ build = [ ] [build-system] -requires = ["meson-python", "ninja", "meson"] +requires = ["meson-python"] build-backend = "mesonpy" [tool.coverage.run]