Skip to content

Python module distutils is deprecated, consider replacing it #9289

Open
@stevapple

Description

@stevapple

lldb/bindings/python/prepare_binding_python.py imports distutils which used to be a part of Python standard libraries, but was deprecated long ago and finally removed in Python 3.12. Thus we'll get the following error if we tried to build with a vallina Python 3.12 install:

FAILED: tools/lldb/bindings/python/LLDBWrapPython.cpp tools/lldb/bindings/python/lldb.py E:/swift-build/5/tools/lldb/bindings/python/LLDBWrapPython.cpp E:/swift-build/5/tools/lldb/bindings/python/lldb.py
C:\Windows\system32\cmd.exe /C "cd /D E:\swift-build\5\tools\lldb\bindings\python && E:\swift-build\python\3.12.6\amd64\Python312\python.exe C:/Users/stevapple/Developer/llvm-project/lldb/bindings/prepare_bindings.py --srcRoot=C:/Users/stevapple/Developer/llvm-project/lldb --buildRoot=E:/swift-build/5/tools/lldb --targetDir=E:/swift-build/5/tools/lldb/bindings/python --cfgBldDir=E:/swift-build/5/tools/lldb/bindings/python --prefix=E:/swift-build/5 --use-static-binding"
Traceback (most recent call last):
  File "C:\Users\stevapple\Developer\llvm-project\lldb\bindings\prepare_bindings.py", line 290, in <module>
    main(sys.argv[1:])
  File "C:\Users\stevapple\Developer\llvm-project\lldb\bindings\prepare_bindings.py", line 285, in main
    prepare_all_bindings(options)
  File "C:\Users\stevapple\Developer\llvm-project\lldb\bindings\prepare_bindings.py", line 74, in prepare_all_bindings
    prepare_binding_for_language(bindings_dir, script_lang, options)
  File "C:\Users\stevapple\Developer\llvm-project\lldb\bindings\prepare_bindings.py", line 49, in prepare_binding_for_language
    module.main(options)
  File "c:\users\stevapple\developer\llvm-project\lldb\bindings\python\prepare_binding_python.py", line 443, in main
    python_module_path = get_python_module_path(options)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\users\stevapple\developer\llvm-project\lldb\bindings\python\prepare_binding_python.py", line 369, in get_python_module_path
    from distutils.sysconfig import get_python_lib
ModuleNotFoundError: No module named 'distutils'
ninja: build stopped: subcommand failed.

We should consider replacing it with a modernized module, though they're most likely not included in the standard libraries

FYI Upstream LLVM's choice was packaging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions