From e5ed51d5aec53afc7238f6ad999c398d3c831c1b Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 9 Apr 2022 13:20:07 +0300 Subject: [PATCH] Use a temp file to invoke the introspection command. This is more reliable as '-c' can, for example, exhaust the maximum command line length. --- mesonbuild/modules/python.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py index 90335a12e..05c4e1b5a 100644 --- a/mesonbuild/modules/python.py +++ b/mesonbuild/modules/python.py @@ -380,8 +380,13 @@ class PythonExternalProgram(ExternalProgram): def sanity(self, state: T.Optional['ModuleState'] = None) -> bool: # Sanity check, we expect to have something that at least quacks in tune - cmd = self.get_command() + ['-c', INTROSPECT_COMMAND] + from tempfile import NamedTemporaryFile + with NamedTemporaryFile(suffix='.py', delete=False, mode='w', encoding='utf-8') as tf: + tmpfilename = tf.name + tf.write(INTROSPECT_COMMAND) + cmd = self.get_command() + [tmpfilename] p, stdout, stderr = mesonlib.Popen_safe(cmd) + os.unlink(tmpfilename) try: info = json.loads(stdout) except json.JSONDecodeError: