diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-02-24 00:01:05 -0500 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2023-02-24 20:45:00 -0500 |
commit | 9f05d45b7084866f0b306f4685a118e5fea138af (patch) | |
tree | 9d042859953ec490353d1ec6e014e1ea6b265a59 /mesonbuild/scripts | |
parent | 8f683eeb21021f5907e8a6587c59d2d486399027 (diff) | |
download | meson-9f05d45b7084866f0b306f4685a118e5fea138af.zip meson-9f05d45b7084866f0b306f4685a118e5fea138af.tar.gz meson-9f05d45b7084866f0b306f4685a118e5fea138af.tar.bz2 |
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.
Diffstat (limited to 'mesonbuild/scripts')
-rwxr-xr-x | mesonbuild/scripts/python_info.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/mesonbuild/scripts/python_info.py b/mesonbuild/scripts/python_info.py index a851356..9c3a079 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): |