Bug 2440552

Summary: python-setuptools fails to build with Python 3.15: DeprecationWarning: '__version__' is deprecated and slated for removal in Python 3.20
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-setuptoolsAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, mhroncok, python-maint, python-packagers-sig, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: python-setuptools-80.10.2-2.fc45 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2026-03-10 13:24:56 UTC Type: ---
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: 2412434    

Description Karolina Surma 2026-02-18 09:53:24 UTC
With Python 3.15.0a6, the older __version__ way of getting a version is deprecated:

________________________ TestDepends.testModuleExtract _________________________

self = <setuptools.tests.test_setuptools.TestDepends object at 0x7f07b8dda060>

    @needs_bytecode
    def testModuleExtract(self):
>       from json import __version__

/builddir/build/BUILD/python-setuptools-80.10.2-build/setuptools-80.10.2/setuptools/tests/test_setuptools.py:82: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
<frozen importlib._bootstrap>:1336: in _handle_fromlist
    ???
/usr/lib64/python3.15/json/__init__.py:371: in __getattr__
    _deprecated("__version__", remove=(3, 20))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = '__version__'
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 tuple (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)
>           _wm.warn(msg, DeprecationWarning, stacklevel=3)
E           DeprecationWarning: '__version__' is deprecated and slated for removal in Python 3.20

/usr/lib64/python3.15/_py_warnings.py:889: DeprecationWarning
___________________________ TestDepends.testRequire ____________________________

self = <setuptools.tests.test_setuptools.TestDepends object at 0x7f07b8dd9f30>

    @needs_bytecode
    def testRequire(self):
        req = Require('Json', '1.0.3', 'json')
    
        assert req.name == 'Json'
        assert req.module == 'json'
        assert req.requested_version == Version('1.0.3')
        assert req.attribute == '__version__'
        assert req.full_name() == 'Json-1.0.3'
    
>       from json import __version__

/builddir/build/BUILD/python-setuptools-80.10.2-build/setuptools-80.10.2/setuptools/tests/test_setuptools.py:101: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
<frozen importlib._bootstrap>:1336: in _handle_fromlist
    ???
/usr/lib64/python3.15/json/__init__.py:371: in __getattr__
    _deprecated("__version__", remove=(3, 20))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = '__version__'
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 tuple (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)
>           _wm.warn(msg, DeprecationWarning, stacklevel=3)
E           DeprecationWarning: '__version__' is deprecated and slated for removal in Python 3.20

/usr/lib64/python3.15/_py_warnings.py:889: DeprecationWarning
=========================== short test summary info ============================
FAILED setuptools/tests/test_setuptools.py::TestDepends::testModuleExtract - ...
FAILED setuptools/tests/test_setuptools.py::TestDepends::testRequire - Deprec...

Reproducible: Always

Comment 1 Miro Hrončok 2026-02-18 12:37:49 UTC
Reported to upstream: https://github.com/pypa/setuptools/issues/5186

While at it, we might as well send a fixer.

Comment 2 Miro Hrončok 2026-02-18 13:05:33 UTC
A fox won't be trivial. See my comment in https://github.com/pypa/setuptools/issues/5186#issuecomment-3920663105

Comment 3 Miro Hrončok 2026-03-09 14:03:02 UTC
Fix in https://github.com/pypa/setuptools/pull/5194

Comment 5 Fedora Update System 2026-03-10 09:00:24 UTC
FEDORA-2026-817706e683 (python-setuptools-80.10.2-2.fc45) has been submitted as an update to Fedora 45.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-817706e683

Comment 6 Fedora Update System 2026-03-10 13:24:56 UTC
FEDORA-2026-817706e683 (python-setuptools-80.10.2-2.fc45) has been pushed to the Fedora 45 stable repository.
If problem still persists, please make note of it in this bug report.