Bug 2083956

Summary: python-setuptools fails to build with Python 3.11: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: babelAssignee: Felix Schwarz <fschwarz>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, fschwarz, lewk, mhroncok, nphilipp, pviktori, python-maint, python-sig, rkuska, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-20 20:46:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2016048    

Description Tomáš Hrnčiar 2022-05-11 06:11:04 UTC
python-setuptools fails to build with Python 3.11.0b1.


=================================== FAILURES ===================================
_____________________ TestSphinxUploadDocs.test_sphinx_doc _____________________

self = <setuptools.tests.test_sphinx_upload_docs.TestSphinxUploadDocs object at 0x7f6ca15ad550>

    def test_sphinx_doc(self):
        params = dict(
            packages=['test'],
        )
        dist = Distribution(params)
    
        cmd = upload_docs(dist)
    
        cmd.initialize_options()
        assert cmd.upload_dir is None
        assert cmd.has_sphinx() is True
>       cmd.finalize_options()

/builddir/build/BUILD/setuptools-60.9.3/setuptools/tests/test_sphinx_upload_docs.py:37: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/setuptools-60.9.3/setuptools/command/upload_docs.py:63: in finalize_options
    build_sphinx = self.get_finalized_command('build_sphinx')
/builddir/build/BUILD/setuptools-60.9.3/setuptools/_distutils/cmd.py:298: in get_finalized_command
    cmd_obj = self.distribution.get_command_obj(command, create)
/builddir/build/BUILD/setuptools-60.9.3/setuptools/_distutils/dist.py:858: in get_command_obj
    klass = self.get_command_class(command)
/builddir/build/BUILD/setuptools-60.9.3/setuptools/dist.py:931: in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
/usr/lib64/python3.11/importlib/metadata/__init__.py:198: in load
    module = import_module(match.group('module'))
/usr/lib64/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1206: in _gcd_import
    ???
<frozen importlib._bootstrap>:1178: in _find_and_load
    ???
<frozen importlib._bootstrap>:1149: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:939: in exec_module
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
/usr/lib/python3.11/site-packages/sphinx/setup_command.py:13: in <module>
    from sphinx.application import Sphinx
/usr/lib/python3.11/site-packages/sphinx/application.py:24: in <module>
    from sphinx.config import Config
/usr/lib/python3.11/site-packages/sphinx/config.py:14: in <module>
    from sphinx.util.i18n import format_date
/usr/lib/python3.11/site-packages/sphinx/util/i18n.py:10: in <module>
    from babel.messages.mofile import write_mo
/usr/lib/python3.11/site-packages/babel/messages/__init__.py:12: in <module>
    from babel.messages.catalog import *
/usr/lib/python3.11/site-packages/babel/messages/catalog.py:14: in <module>
    from cgi import parse_header
/usr/lib64/python3.11/cgi.py:57: in <module>
    warnings._deprecated(__name__, remove=(3,13))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'cgi'
message = '{name!r} is deprecated and slated for removal in Python {remove}'

    def _deprecated(name, message=_DEPRECATED_MSG, *, remove, _version=sys.version_info):
        """Warn that *name* is deprecated or should be removed.
    
        RuntimeError is raised if *remove* specifies a major/minor tuple older than
        the current Python version or the same version but past the alpha.
    
        The *message* argument is formatted with *name* and *remove* as a Python
        version (e.g. "3.11").
    
        """
        remove_formatted = f"{remove[0]}.{remove[1]}"
        if (_version[:2] > remove) or (_version[:2] == remove and _version[3] != "alpha"):
            msg = f"{name!r} was slated for removal after Python {remove_formatted} alpha"
            raise RuntimeError(msg)
        else:
            msg = message.format(name=name, remove=remove_formatted)
>           warn(msg, DeprecationWarning, stacklevel=3)
E           DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13

/usr/lib64/python3.11/warnings.py:514: DeprecationWarning

PEP 594 led to the deprecations of the following modules which are slated for removal in Python 3.13:
    ...
    cgi
    ...

(Contributed by Brett Cannon in bpo-47061 and Victor Stinner in gh-68966.)
https://github.com/python/cpython/issues/68966
https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/04392661-python-setuptools/

For all our attempts to build python-setuptools with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-setuptools/

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.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
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 Miro Hrončok 2022-05-25 13:27:11 UTC
This was assigned to babel because the deprecation warning comes from babel and is fixed in https://github.com/python-babel/babel/pull/876

Comment 2 Felix Schwarz 2022-06-20 16:28:30 UTC
I saw  that the non-bootstrap build of setuptools did also fail during the Python 3.11 rebuild: https://koji.fedoraproject.org/koji/taskinfo?taskID=88259033

Should we add the upstream patch for babel 2.10.x to get this resolved?

Comment 3 Miro Hrončok 2022-06-20 16:48:39 UTC
That would be awesome. setuptools has removed the test in a newer release, but the upgrade breaks an untrivial amount of packages.

Fixing babel is also better for any other potential dependents that would treat this warning badly.

Comment 4 Felix Schwarz 2022-06-20 20:46:06 UTC
should be fixed in rawhide: https://koji.fedoraproject.org/koji/taskinfo?taskID=88508673

Comment 5 Miro Hrončok 2022-06-20 21:20:37 UTC
python-setuptools built, thanks.