From 9f05d45b7084866f0b306f4685a118e5fea138af Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Fri, 24 Feb 2023 00:01:05 -0500 Subject: 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. --- mesonbuild/scripts/python_info.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'mesonbuild/scripts/python_info.py') diff --git a/mesonbuild/scripts/python_info.py b/mesonbuild/scripts/python_info.py index a851356e6..9c3a0791a 100755 --- a/mesonbuild/scripts/python_info.py +++ b/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): -- cgit v1.2.3