Skip to content

Commit 231abcd

Browse files
committed
Trick to keep Meson from demanding other tools when building Python extension
1 parent 7d34abe commit 231abcd

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

.github/workflows/install.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,36 @@ jobs:
4646
pkg-config
4747
python3
4848
systemd
49-
rsync
50-
wget
5149
)
5250
5351
case "$DIST_ID" in
5452
arch)
55-
pacman --noconfirm -Sy -u "${DEPS_COMMON[@]}" systemd-libs python-pip ctags gnupg
53+
pacman --noconfirm -Sy -u "${DEPS_COMMON[@]}" systemd-libs python-pip
5654
;;
5755
centos)
5856
dnf config-manager --set-enabled crb
5957
dnf install -y epel-release
60-
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ctags gnupg2
58+
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip
6159
;;
6260
fedora)
63-
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip ctags gnupg2
61+
dnf -y install "${DEPS_COMMON[@]}" systemd-devel python3-devel python3-pip
6462
;;
6563
ubuntu|debian)
6664
apt -y update
67-
DEBIAN_FRONTEND=noninteractive apt -y install "${DEPS_COMMON[@]}" libsystemd-dev python3-dev python3-pip universal-ctags gpg
65+
DEBIAN_FRONTEND=noninteractive apt -y install "${DEPS_COMMON[@]}" libsystemd-dev python3-dev python3-pip
6866
;;
6967
*)
7068
echo >&2 "Invalid distribution ID: $DISTRO_ID"
7169
exit 1
7270
esac
7371
7472
python3 -m pip install --break-system-packages build pytest
75-
wget -qO- https://astral.sh/uv/install.sh | sh
7673
7774
- name: Fix Git config to satisfy Meson
7875
run: git config --global safe.directory "*"
7976

80-
# Checkout repo after installing Git, or the GH Action delete our .git folder.
77+
# Checkout repo after installing Git, or the "checkout" GH Action will download our source as non-Git repo, making Meson fail
78+
# to build Python source dist.
8179
- name: Repository checkout
8280
uses: actions/checkout@v4
8381

meson.build

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,14 @@ common_c_args = [
3434

3535
subdir('src')
3636

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',
37+
test(
38+
'pytest',
39+
python,
40+
args: [
41+
'-m', 'pytest',
42+
meson.project_source_root() / 'src/systemd/test',
4443
],
45-
)
46-
47-
# Run target to generate TAGS file for Emacs
48-
run_target(
49-
'ctags',
50-
command: ['ctags', '-R', '@SOURCE_ROOT@/systemd'],
44+
workdir: meson.project_build_root(),
5145
)
5246

5347
run_target(
@@ -63,20 +57,31 @@ run_target(
6357
],
6458
)
6559

66-
test(
67-
'pytest',
68-
python,
69-
args: [
70-
'-m', 'pytest',
71-
'../systemd/test',
60+
run_target(
61+
'update-constants',
62+
command: [
63+
python,
64+
files('update-constants.py'),
65+
'-i', libsystemd_dep.get_variable('includedir'),
66+
'-s', meson.project_source_root() / 'systemd',
7267
],
73-
workdir: meson.project_build_root(),
7468
)
7569

70+
# Trick to keep Meson from demanding other tools to be available at building Python extention time.
71+
env_bin = find_program('env', required: false)
72+
73+
# Run target to generate TAGS file for Emacs
74+
run_target(
75+
'ctags',
76+
command: [env_bin, 'ctags', '-R', '@SOURCE_ROOT@/src/systemd'],
77+
)
78+
79+
7680
# Sync built HTML docs to the remote server using rsync.
7781
run_target(
7882
'doc-sync',
7983
command: [
84+
env_bin,
8085
'rsync',
8186
'-rlv',
8287
'--delete',
@@ -93,7 +98,7 @@ signature_filename = 'systemd-python-' + version + '.tar.gz.asc'
9398
# Run target to sign the distribution tarball using GPG.
9499
run_target(
95100
'sign',
96-
command: ['gpg', '--detach-sign', '-a', archive],
101+
command: [env_bin, 'gpg', '--detach-sign', '-a', archive],
97102
)
98103

99104
# NOTE: Run 'sign' target before 'upload' to ensure the signature file exists.

0 commit comments

Comments
 (0)