Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ jobs:
python-version: ${{ matrix.python }}
architecture: x64

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: |
sudo apt -y update
sudo apt -y install gcc libsystemd-dev
python -m pip install --break-system-packages pytest sphinx build
sudo apt -y install gcc libsystemd-dev universal-ctags

- name: Build (Python ${{ matrix.python }})
run: |
set -x
python -m build -Cbuild-dir=_build
python -m pip install .
cd _build && python -m sphinx -b html -W -v ../docs html
uv build
uv sync --no-editable
cd _build
uv run --no-editable --group docs -m sphinx -b html -W -v ../docs html
5 changes: 4 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ jobs:
- name: Install dependencies
run: |
sudo apt -y update
sudo apt -y install gcc libsystemd-dev
sudo apt -y install gcc libsystemd-dev universal-ctags

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Autobuild
uses: github/codeql-action/autobuild@v3
Expand Down
31 changes: 23 additions & 8 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ jobs:
image: ${{ matrix.container }}
name: ${{ matrix.container }}
steps:
- name: Repository checkout
uses: actions/checkout@v4

- name: Install dependencies
shell: bash
Expand All @@ -48,31 +46,48 @@ jobs:
pkg-config
python3
systemd
rsync
wget
)

case "$DIST_ID" in
arch)
pacman --noconfirm -Sy "${DEPS_COMMON[@]}" systemd-libs python-pip
pacman --noconfirm -Sy -u "${DEPS_COMMON[@]}" systemd-libs python-pip ctags gnupg
;;
centos|fedora)
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip
centos)
dnf config-manager --set-enabled crb
dnf install -y epel-release
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ctags gnupg2
;;
fedora)
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ctags gnupg2
;;
ubuntu|debian)
apt -y update
DEBIAN_FRONTEND=noninteractive apt -y install "${DEPS_COMMON[@]}" libsystemd-dev python3-dev python3-pip
DEBIAN_FRONTEND=noninteractive apt -y install "${DEPS_COMMON[@]}" libsystemd-dev python3-dev python3-pip universal-ctags gpg
;;
*)
echo >&2 "Invalid distribution ID: $DISTRO_ID"
exit 1
esac

python3 -m pip install --break-system-packages pytest sphinx
python3 -m pip install --break-system-packages build pytest
wget -qO- https://astral.sh/uv/install.sh | sh

- name: Fix Git config to satisfy Meson
run: git config --global safe.directory "*"

# Checkout repo after installing Git, or the GH Action delete our .git folder.
- name: Repository checkout
uses: actions/checkout@v4

- name: Install & test
shell: bash
run: |
set -x
python3 -m pip install -I -v --break-system-packages .
git --version
python3 -m build
python3 -m pip install --break-system-packages .
# Avoid importing the systemd module from the git repository
cd /
python3 -c 'from systemd import journal; print(journal.__version__)'
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__pycache__/
*.py[co]
/journald/*.so
/TAGS
TAGS

# Packages
*.egg
Expand Down
68 changes: 0 additions & 68 deletions Makefile

This file was deleted.

94 changes: 14 additions & 80 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,90 +32,28 @@ common_c_args = [
'-DLIBSYSTEMD_VERSION=' + libsystemd_dep.version(),
]

# Build _journal extension module
python.extension_module(
'_journal',
['systemd/_journal.c', 'systemd/pyutil.c'],
dependencies: [libsystemd_dep],
c_args: common_c_args,
install: true,
subdir: 'systemd',
)

# Build _reader extension module
python.extension_module(
'_reader',
['systemd/_reader.c', 'systemd/pyutil.c', 'systemd/strv.c'],
dependencies: [libsystemd_dep],
c_args: common_c_args,
install: true,
subdir: 'systemd',
)

# Build _daemon extension module
python.extension_module(
'_daemon',
['systemd/_daemon.c', 'systemd/pyutil.c', 'systemd/util.c'],
dependencies: [libsystemd_dep],
c_args: common_c_args,
install: true,
subdir: 'systemd',
)

# Build id128 extension module
python.extension_module(
'id128',
['systemd/id128.c', 'systemd/pyutil.c'],
dependencies: [libsystemd_dep],
c_args: common_c_args,
install: true,
subdir: 'systemd',
)
subdir('src')

# Build login extension module
python.extension_module(
'login',
['systemd/login.c', 'systemd/pyutil.c', 'systemd/strv.c'],
dependencies: [libsystemd_dep],
c_args: common_c_args,
install: true,
subdir: 'systemd',
)

# Install Python modules (matching py_modules in setup.py)
python.install_sources(
'systemd/__init__.py',
'systemd/journal.py',
'systemd/daemon.py',
subdir: 'systemd',
)

# Install test modules
python.install_sources(
'systemd/test/test_daemon.py',
'systemd/test/test_journal.py',
'systemd/test/test_login.py',
'systemd/test/test_id128.py',
subdir: 'systemd/test',
run_target(
'update-constants',
command: [
python,
files('update-constants.py'),
'-i', libsystemd_dep.get_variable('includedir'),
'-s', meson.project_source_root() / 'systemd',
],
)

# Run target to generate TAGS file for Emacs
run_target(
'etags',
command: ['etags', '-R', '@SOURCE_ROOT@/systemd'],
'ctags',
command: ['ctags', '-R', '@SOURCE_ROOT@/systemd'],
)

# Use 'uv run' to ensure Sphinx and its dependencies are installed before being run.
uv_prog = find_program('uv')

# The '--no-editable' option tells uv to install the systemd package so that Sphinx can import it and extract docstrings.
run_target(
'doc',
command: [
uv_prog,
'run',
'--group', 'docs',
'--no-editable',
python,
'-m', 'sphinx',
'-b', 'html',
'-D', 'version=' + meson.project_version(),
Expand All @@ -125,14 +63,10 @@ run_target(
],
)

# The '--no-editable' option tells uv to install the systemd package so tests can import it.
test(
'pytest',
uv_prog,
python,
args: [
'run',
'--group', 'test',
'--no-editable',
'-m', 'pytest',
'../systemd/test',
],
Expand Down Expand Up @@ -165,5 +99,5 @@ run_target(
# NOTE: Run 'sign' target before 'upload' to ensure the signature file exists.
run_target(
'upload',
command: ['uvx', 'twine', 'upload', archive, signature_filename],
command: [python, '-m', 'twine', 'upload', archive, signature_filename],
)
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,25 @@ 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.uv]
package = true

[tool.uv.config-settings]
build-dir = "_build"

[tool.uv.build-backend]
module-name = "systemd"
module-root = "src"

[tool.coverage.run]
source = ["systemd"]
omit = ["systemd/test/*"]
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subdir('systemd')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
61 changes: 61 additions & 0 deletions src/systemd/meson.build
Original file line number Diff line number Diff line change
@@ -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 (matching py_modules in setup.py)
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',
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading