work around circular imports in python probe script

It seems this happens because at some point setuptools imports gettext,
and we have a script by the same name.

In general, this path injection by default is bad news for our use case.
Python 3.11 introduced -P for this reason, but we cannot depend on that.
Instead, check for it first, and delete it, before doing more imports.
pull/11461/head
Eli Schwartz 2 years ago committed by Xavier Claessens
parent 8f683eeb21
commit 9f05d45b70
  1. 10
      mesonbuild/scripts/python_info.py

@ -5,10 +5,14 @@
# type: ignore
# pylint: disable=deprecated-module
import os.path
import sysconfig
import json
import sys
# do not inject mesonbuild.scripts
# python -P would work too, but is exclusive to >=3.11
if sys.path[0].endswith('scripts'):
del sys.path[0]
import json, os, sysconfig
import distutils.command.install
def get_distutils_paths(scheme=None, prefix=None):

Loading…
Cancel
Save