Skip to content

Commit f8b2ee1

Browse files
eli-schwartznirbheek
authored andcommitted
python dependency: ensure that setuptools doesn't inject itself into distutils
We do not use setuptools for anything, and only lightly use distutils. Unpredictable issues can occur due to setuptools monkey-patching, which interferes with our intended use. Tell setuptools to simply never get involved. Note: while it's otherwise possible to check if the probe is run using sys.executable and avoid forking, setuptools unconditionally injects itself at startup in a way that requires subprocess isolation to disable.
1 parent 030d0fc commit f8b2ee1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mesonbuild/dependencies/python.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def sanity(self) -> bool:
113113

114114
with importlib.resources.path('mesonbuild.scripts', 'python_info.py') as f:
115115
cmd = self.get_command() + [str(f)]
116-
p, stdout, stderr = mesonlib.Popen_safe(cmd)
116+
env = os.environ.copy()
117+
env['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
118+
p, stdout, stderr = mesonlib.Popen_safe(cmd, env=env)
117119

118120
try:
119121
info = json.loads(stdout)

0 commit comments

Comments
 (0)