Skip to content

Commit 172d886

Browse files
authored
[lldb] fix get_python_module_path for python 3.12 and greater (#11440)
[distutils](https://docs.python.org/3/library/distutils.html) was deprecated in 3.10 and removed in 3.11 this causes it to fail on python 3.12 or greater. Added the alternative api. (cherry picked from commit 01bbaaf)
1 parent 0d02465 commit 172d886

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lldb/bindings/python/prepare_binding_python.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,22 @@ def get_python_module_path(options):
366366
"Python",
367367
"lldb")
368368
else:
369-
from distutils.sysconfig import get_python_lib
369+
if sys.version_info.major == 3 and sys.version_info.minor >= 12:
370+
from sysconfig import get_path
371+
372+
if options.prefix is not None:
373+
module_path = get_path("platlib", vars={"prefix": options.prefix})
374+
else:
375+
module_path = get_path("platlib")
370376

371-
if options.prefix is not None:
372-
module_path = get_python_lib(True, False, options.prefix)
373377
else:
374-
module_path = get_python_lib(True, False)
375-
return os.path.normcase(
376-
os.path.join(module_path, "lldb"))
378+
from distutils.sysconfig import get_python_lib
379+
380+
if options.prefix is not None:
381+
module_path = get_python_lib(True, False, options.prefix)
382+
else:
383+
module_path = get_python_lib(True, False)
384+
return os.path.normcase(os.path.join(module_path, "lldb"))
377385

378386

379387
def main(options):

0 commit comments

Comments
 (0)