Skip to content

Commit 7ecebd4

Browse files
meson: fix build when using pypy
1 parent 233f899 commit 7ecebd4

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

pkgs/by-name/me/meson/package.nix

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
pkg-config,
1111
python3,
1212
replaceVars,
13+
writeShellScriptBin,
1314
zlib,
1415
}:
1516

@@ -66,12 +67,34 @@ python3.pkgs.buildPythonApplication rec {
6667
./007-freebsd-pkgconfig-path.patch
6768
];
6869

70+
postPatch =
71+
if python3.isPyPy then
72+
''
73+
substituteInPlace mesonbuild/modules/python.py \
74+
--replace-fail "PythonExternalProgram('python3', mesonlib.python_command)" \
75+
"PythonExternalProgram('${python3.meta.mainProgram}', mesonlib.python_command)"
76+
substituteInPlace mesonbuild/modules/python3.py \
77+
--replace-fail "state.environment.lookup_binary_entry(mesonlib.MachineChoice.HOST, 'python3')" \
78+
"state.environment.lookup_binary_entry(mesonlib.MachineChoice.HOST, '${python3.meta.mainProgram}')"
79+
substituteInPlace "test cases"/*/*/*.py "test cases"/*/*/*/*.py \
80+
--replace-quiet '#!/usr/bin/env python3' '#!/usr/bin/env pypy3' \
81+
--replace-quiet '#! /usr/bin/env python3' '#!/usr/bin/env pypy3'
82+
chmod +x "test cases"/*/*/*.py "test cases"/*/*/*/*.py
83+
''
84+
else
85+
null;
86+
6987
nativeBuildInputs = [ installShellFiles ];
7088

71-
nativeCheckInputs = [
72-
ninja
73-
pkg-config
74-
];
89+
nativeCheckInputs =
90+
[
91+
ninja
92+
pkg-config
93+
]
94+
++ lib.optionals python3.isPyPy [
95+
# Several tests hardcode python3.
96+
(writeShellScriptBin "python3" ''exec pypy3 "$@"'')
97+
];
7598

7699
checkInputs =
77100
[
@@ -116,9 +139,15 @@ python3.pkgs.buildPythonApplication rec {
116139
# pch doesn't work quite right on FreeBSD, I think
117140
''test cases/common/13 pch''
118141
]
142+
++ lib.optionals python3.isPyPy [
143+
# fails for unknown reason
144+
''test cases/python/4 custom target depends extmodule''
145+
]
119146
))
120147
++ [
121-
''HOME="$TMPDIR" python ./run_project_tests.py''
148+
''HOME="$TMPDIR" ${
149+
if python3.isPyPy then python3.interpreter else "python"
150+
} ./run_project_tests.py''
122151
"runHook postCheck"
123152
]
124153
);

0 commit comments

Comments
 (0)