Skip to content

Commit af80340

Browse files
committed
Move tasks from Makefile to Meson
1 parent c6e3143 commit af80340

33 files changed

+940
-168
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ jobs:
4848
python-version: ${{ matrix.python }}
4949
architecture: x64
5050

51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v5
53+
5154
- name: Install dependencies
5255
run: |
5356
sudo apt -y update
54-
sudo apt -y install gcc libsystemd-dev
55-
python -m pip install --break-system-packages pytest sphinx build
57+
sudo apt -y install gcc libsystemd-dev universal-ctags
5658
5759
- name: Build (Python ${{ matrix.python }})
5860
run: |
5961
set -x
60-
python -m build -Cbuild-dir=_build
61-
python -m pip install .
62-
cd _build && python -m sphinx -b html -W -v ../docs html
62+
uv build
63+
uv sync --no-editable
64+
cd _build
65+
uv run --no-editable --group docs -m sphinx -b html -W -v ../docs html

.github/workflows/codeql.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ jobs:
4545
- name: Install dependencies
4646
run: |
4747
sudo apt -y update
48-
sudo apt -y install gcc libsystemd-dev
48+
sudo apt -y install gcc libsystemd-dev universal-ctags
49+
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v5
4952

5053
- name: Autobuild
5154
uses: github/codeql-action/autobuild@v3

.github/workflows/install.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ jobs:
3333
image: ${{ matrix.container }}
3434
name: ${{ matrix.container }}
3535
steps:
36-
- name: Repository checkout
37-
uses: actions/checkout@v4
3836

3937
- name: Install dependencies
4038
shell: bash
@@ -48,31 +46,48 @@ jobs:
4846
pkg-config
4947
python3
5048
systemd
49+
rsync
50+
wget
5151
)
5252
5353
case "$DIST_ID" in
5454
arch)
55-
pacman --noconfirm -Sy "${DEPS_COMMON[@]}" systemd-libs python-pip
55+
pacman --noconfirm -Sy -u "${DEPS_COMMON[@]}" systemd-libs python-pip ctags gnupg
5656
;;
57-
centos|fedora)
58-
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip
57+
centos)
58+
dnf config-manager --set-enabled crb
59+
dnf install -y epel-release
60+
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ctags gnupg2
61+
;;
62+
fedora)
63+
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ctags gnupg2
5964
;;
6065
ubuntu|debian)
6166
apt -y update
62-
DEBIAN_FRONTEND=noninteractive apt -y install "${DEPS_COMMON[@]}" libsystemd-dev python3-dev python3-pip
67+
DEBIAN_FRONTEND=noninteractive apt -y install "${DEPS_COMMON[@]}" libsystemd-dev python3-dev python3-pip universal-ctags gpg
6368
;;
6469
*)
6570
echo >&2 "Invalid distribution ID: $DISTRO_ID"
6671
exit 1
6772
esac
6873
69-
python3 -m pip install --break-system-packages pytest sphinx
74+
python3 -m pip install --break-system-packages build pytest
75+
wget -qO- https://astral.sh/uv/install.sh | sh
76+
77+
- name: Fix Git config to satisfy Meson
78+
run: git config --global safe.directory "*"
79+
80+
# Checkout repo after installing Git, or the GH Action delete our .git folder.
81+
- name: Repository checkout
82+
uses: actions/checkout@v4
7083

7184
- name: Install & test
7285
shell: bash
7386
run: |
7487
set -x
75-
python3 -m pip install -I -v --break-system-packages .
88+
git --version
89+
python3 -m build
90+
python3 -m pip install --break-system-packages .
7691
# Avoid importing the systemd module from the git repository
7792
cd /
7893
python3 -c 'from systemd import journal; print(journal.__version__)'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
__pycache__/
22
*.py[co]
33
/journald/*.so
4-
/TAGS
4+
TAGS
55

66
# Packages
77
*.egg

Makefile

Lines changed: 0 additions & 68 deletions
This file was deleted.

meson.build

Lines changed: 14 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,90 +32,28 @@ common_c_args = [
3232
'-DLIBSYSTEMD_VERSION=' + libsystemd_dep.version(),
3333
]
3434

35-
# Build _journal extension module
36-
python.extension_module(
37-
'_journal',
38-
['systemd/_journal.c', 'systemd/pyutil.c'],
39-
dependencies: [libsystemd_dep],
40-
c_args: common_c_args,
41-
install: true,
42-
subdir: 'systemd',
43-
)
44-
45-
# Build _reader extension module
46-
python.extension_module(
47-
'_reader',
48-
['systemd/_reader.c', 'systemd/pyutil.c', 'systemd/strv.c'],
49-
dependencies: [libsystemd_dep],
50-
c_args: common_c_args,
51-
install: true,
52-
subdir: 'systemd',
53-
)
54-
55-
# Build _daemon extension module
56-
python.extension_module(
57-
'_daemon',
58-
['systemd/_daemon.c', 'systemd/pyutil.c', 'systemd/util.c'],
59-
dependencies: [libsystemd_dep],
60-
c_args: common_c_args,
61-
install: true,
62-
subdir: 'systemd',
63-
)
64-
65-
# Build id128 extension module
66-
python.extension_module(
67-
'id128',
68-
['systemd/id128.c', 'systemd/pyutil.c'],
69-
dependencies: [libsystemd_dep],
70-
c_args: common_c_args,
71-
install: true,
72-
subdir: 'systemd',
73-
)
35+
subdir('src')
7436

75-
# Build login extension module
76-
python.extension_module(
77-
'login',
78-
['systemd/login.c', 'systemd/pyutil.c', 'systemd/strv.c'],
79-
dependencies: [libsystemd_dep],
80-
c_args: common_c_args,
81-
install: true,
82-
subdir: 'systemd',
83-
)
84-
85-
# Install Python modules (matching py_modules in setup.py)
86-
python.install_sources(
87-
'systemd/__init__.py',
88-
'systemd/journal.py',
89-
'systemd/daemon.py',
90-
subdir: 'systemd',
91-
)
92-
93-
# Install test modules
94-
python.install_sources(
95-
'systemd/test/test_daemon.py',
96-
'systemd/test/test_journal.py',
97-
'systemd/test/test_login.py',
98-
'systemd/test/test_id128.py',
99-
subdir: 'systemd/test',
37+
run_target(
38+
'update-constants',
39+
command: [
40+
python,
41+
files('update-constants.py'),
42+
'-i', libsystemd_dep.get_variable('includedir'),
43+
'-s', meson.project_source_root() / 'systemd',
44+
],
10045
)
10146

10247
# Run target to generate TAGS file for Emacs
10348
run_target(
104-
'etags',
105-
command: ['etags', '-R', '@SOURCE_ROOT@/systemd'],
49+
'ctags',
50+
command: ['ctags', '-R', '@SOURCE_ROOT@/systemd'],
10651
)
10752

108-
# Use 'uv run' to ensure Sphinx and its dependencies are installed before being run.
109-
uv_prog = find_program('uv')
110-
111-
# The '--no-editable' option tells uv to install the systemd package so that Sphinx can import it and extract docstrings.
11253
run_target(
11354
'doc',
11455
command: [
115-
uv_prog,
116-
'run',
117-
'--group', 'docs',
118-
'--no-editable',
56+
python,
11957
'-m', 'sphinx',
12058
'-b', 'html',
12159
'-D', 'version=' + meson.project_version(),
@@ -125,14 +63,10 @@ run_target(
12563
],
12664
)
12765

128-
# The '--no-editable' option tells uv to install the systemd package so tests can import it.
12966
test(
13067
'pytest',
131-
uv_prog,
68+
python,
13269
args: [
133-
'run',
134-
'--group', 'test',
135-
'--no-editable',
13670
'-m', 'pytest',
13771
'../systemd/test',
13872
],
@@ -165,5 +99,5 @@ run_target(
16599
# NOTE: Run 'sign' target before 'upload' to ensure the signature file exists.
166100
run_target(
167101
'upload',
168-
command: ['uvx', 'twine', 'upload', archive, signature_filename],
102+
command: [python, '-m', 'twine', 'upload', archive, signature_filename],
169103
)

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,25 @@ Documentation = "https://www.freedesktop.org/software/systemd/python-systemd/"
3939
[dependency-groups]
4040
test = ["pytest", "pytest-cov"]
4141
docs = ["sphinx"]
42+
build = [
43+
"meson>=1.8.2",
44+
"twine>=4.0.2",
45+
]
4246

4347
[build-system]
4448
requires = ["meson-python", "ninja", "meson"]
4549
build-backend = "mesonpy"
4650

51+
[tool.uv]
52+
package = true
53+
54+
[tool.uv.config-settings]
55+
build-dir = "_build"
56+
57+
[tool.uv.build-backend]
58+
module-name = "systemd"
59+
module-root = "src"
60+
4761
[tool.coverage.run]
4862
source = ["systemd"]
4963
omit = ["systemd/test/*"]

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subdir('systemd')
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)