Skip to content

Commit 01bbaaf

Browse files
committed
[lldb] fix get_python_module_path for python 3.12 and greater
[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.
1 parent bf26a63 commit 01bbaaf

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
@@ -367,14 +367,22 @@ def get_python_module_path(options):
367367
"Python",
368368
"lldb")
369369
else:
370-
from distutils.sysconfig import get_python_lib
370+
if sys.version_info.major == 3 and sys.version_info.minor >= 12:
371+
from sysconfig import get_path
372+
373+
if options.prefix is not None:
374+
module_path = get_path("platlib", vars={"prefix": options.prefix})
375+
else:
376+
module_path = get_path("platlib")
371377

372-
if options.prefix is not None:
373-
module_path = get_python_lib(True, False, options.prefix)
374378
else:
375-
module_path = get_python_lib(True, False)
376-
return os.path.normcase(
377-
os.path.join(module_path, "lldb"))
379+
from distutils.sysconfig import get_python_lib
380+
381+
if options.prefix is not None:
382+
module_path = get_python_lib(True, False, options.prefix)
383+
else:
384+
module_path = get_python_lib(True, False)
385+
return os.path.normcase(os.path.join(module_path, "lldb"))
378386

379387

380388
def main(options):

0 commit comments

Comments
 (0)