Skip to content

Support Python 3.13 and above #4299

@FrankSommer-64

Description

@FrankSommer-64

Latest Linux distributions like Debian 13 use Python 3.13 as default.
A local Kiwi TCMS installation fails to run because package pkg_resources has been removed starting with Python 3.13.
Affected files are:
tcms/urls.py
tcms/core/templatetags/extra_filters.py
tcms/core/tests/test_plugin_discovery.py
tcms/settings/common.py
tcms/settings/test/__init__.py

Suggested solution:
New module tcms/utils/plugins.py with contents:

"""
Helper module to determine information about available Kiwi TCMS plugins.
"""

import sys
if sys.version_info >= (3, 13):
    from importlib.metadata import entry_points
else:
    import pkg_resources


def kiwi_tcms_plugins() -> list[dict]:
    """
    :return: Names and module names of all Kiwi TCMS plugins.
    """
    modules = []
    if sys.version_info >= (3, 13):
        for plugin in entry_points(group="kiwitcms.plugins"):
            modules.append({"name": plugin.name, "module": plugin.module})
    else:
        for plugin in pkg_resources.iter_entry_points("kiwitcms.plugins"):
            modules.append({"name": plugin.name, "module": plugin.module_name})
    return modules

Replace import statements in all files but tcms/settings/test/__init__.py
import pkg_resources
by
from tcms.utils.plugins import kiwi_tcms_plugins

Replace module imports in all files but tcms/settings/test/__init__.py

for plugin in pkg_resources.iter_entry_points("kiwitcms.plugins"):
   ...plugin.name resp. plugin.module_name

by

for plugin in kiwi_tcms_plugins():
   ...plugin['name'] resp. plugin['module']

Currently no idea how to cope with file tcms/settings/test/__init__.py.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions