Bug 2152651 - gdb fails to build with Python 3.12: ModuleNotFoundError: No module named 'distutils'
Summary: gdb fails to build with Python 3.12: ModuleNotFoundError: No module named 'di...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Kevin Buettner
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.12
TreeView+ depends on / blocked
 
Reported: 2022-12-12 15:38 UTC by Tomáš Hrnčiar
Modified: 2023-01-23 08:47 UTC (History)
11 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-01-23 08:47:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2022-12-12 15:38:50 UTC
gdb fails to build with Python 3.12.0a3.

Traceback (most recent call last):
  File "/builddir/build/BUILD/gdb-12.1/build-x86_64-redhat-linux-gnu/gdb/../../gdb/python/python-config.py", line 7, in <module>
    from distutils import sysconfig
ModuleNotFoundError: No module named 'distutils'

Remove the distutils package. It was deprecated in Python 3.10 by PEP 632 “Deprecate distutils module”. For projects still using distutils and cannot be updated to something else, the setuptools project can be installed: it still provides distutils. (Contributed by Victor Stinner in gh-92584.)

https://docs.python.org/3.12/whatsnew/3.12.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05127792-gdb/

For all our attempts to build gdb with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/gdb/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.12:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Kevin Buettner 2023-01-13 04:48:52 UTC
It appears that this bug might be fixed by backporting the following upstream commit:

commit be2057b902e834bba6fe7d3ded16177ec5624f3b
Author: Lancelot SIX <lancelot.six>
Date:   Fri Aug 26 08:39:03 2022 +0000

    gdb/python-config: replace deprecated distutils.sysconfig
    
    When running the gdb/configure script on ubuntu 22.04 with
    python-3.10.4, I see:
    
        checking for python... no
        checking for python3... /usr/bin/python3
        [...]/gdb/python/python-config.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
          from distutils import sysconfig
        [...]/gdb/python/python-config.py:7: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
          from distutils import sysconfig
        [...]/gdb/python/python-config.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
          from distutils import sysconfig
        [...]/gdb/python/python-config.py:7: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
          from distutils import sysconfig
        [...]/gdb/python/python-config.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
          from distutils import sysconfig
        [...]/gdb/python/python-config.py:7: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
          from distutils import sysconfig
        checking for python... yes
    
    The distutils module is deprecated as per the PEP 632[1] and will be
    removed in python-3.12.
    
    This patch migrates gdb/python/python-config.py from distutils.sysconfig
    to the sysconfig module[2].
    
    The sysconfig module has has been introduced in the standard library in
    python 3.2.  Given that support for python < 3.2 has been removed by
    edae3fd6600f: "gdb/python: remove Python 2 support", this patch does not
    need to support both implementations for backward compatibility.
    
    Tested on ubuntu-22.04 and ubuntu 20.04.
    
    [1] https://peps.python.org/pep-0632/
    [2] https://docs.python.org/3/library/sysconfig.html

I'll give it a try...

Comment 2 Kevin Buettner 2023-01-21 01:14:22 UTC
We've updated rawhide with fixes for this issue as well as some which fix problems introduced by GCC 13.

I've done a mock build using your provided instructions. It works for me, but we'd prefer that you try it before closing this bug.

Comment 3 Tomáš Hrnčiar 2023-01-23 08:47:19 UTC
Works also in Python 3.12 COPR, thank you.

https://copr.fedorainfracloud.org/coprs/g/python/python3.12/build/5284551/


Note You need to log in before you can comment on or make changes to this bug.