aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2022-04-09 13:20:07 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2022-04-10 17:13:51 +0300
commit3c80f8f96591a03207b58e8201700bfcbcfa95a1 (patch)
treece814dd32d504401f0adf7baa1d667ce30a9cb5a
parentd27fd555e8226a024c64343931a24fafd7492546 (diff)
downloadmeson-3c80f8f96591a03207b58e8201700bfcbcfa95a1.zip
meson-3c80f8f96591a03207b58e8201700bfcbcfa95a1.tar.gz
meson-3c80f8f96591a03207b58e8201700bfcbcfa95a1.tar.bz2
Use a temp file to invoke the introspection command.
This is more reliable as '-c' can, for example, exhaust the maximum command line length.
-rw-r--r--mesonbuild/modules/python.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
index 691942e..000f0c6 100644
--- a/mesonbuild/modules/python.py
+++ b/mesonbuild/modules/python.py
@@ -408,8 +408,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: