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.
pull/11133/head
Eli Schwartz 1 year ago
parent 710a753c78
commit 9f610ad5b7
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 4
      mesonbuild/dependencies/python.py

@ -115,7 +115,9 @@ class BasicPythonExternalProgram(ExternalProgram):
with importlib.resources.path('mesonbuild.scripts', 'python_info.py') as f:
cmd = self.get_command() + [str(f)]
p, stdout, stderr = mesonlib.Popen_safe(cmd)
env = os.environ.copy()
env['SETUPTOOLS_USE_DISTUTILS'] = 'stdlib'
p, stdout, stderr = mesonlib.Popen_safe(cmd, env=env)
try:
info = json.loads(stdout)

Loading…
Cancel
Save