Skip to content

3.0.1 switched to a deprecated importlib.metadata API that's removed in Python 3.12 #545

@mgorny

Description

@mgorny

The 3.0.1 version switches from pkg_resources to importlib.metadata. However, it uses the deprecate pre-3.10 API that doesn't work with Python 3.12 anymore:

$ tox -e py312
.pkg: _optional_hooks> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: prepare_metadata_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
py312: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/pygal/.tox/.tmp/package/5/pygal-3.0.1.tar.gz
py312: commands[0]> coverage run --source=pygal /tmp/pygal/.tox/py312/bin/py.test pygal/test --junitxml=junit-py312.xml --flake8
ImportError while loading conftest '/tmp/pygal/pygal/test/conftest.py'.
pygal/__init__.py:64: in <module>
    for entry in entry_points().get('pygal.maps', ()):
E   AttributeError: 'EntryPoints' object has no attribute 'get'
py312: exit 4 (0.93 seconds) /tmp/pygal> coverage run --source=pygal /tmp/pygal/.tox/py312/bin/py.test pygal/test --junitxml=junit-py312.xml --flake8 pid=149296
.pkg: _exit> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
  py312: FAIL code 4 (7.79=setup[6.86]+cmd[0.93] seconds)
  evaluation failed :( (7.91 seconds)

See "compatibility note" at the bottom of:
https://docs.python.org/3.11/library/importlib.metadata.html#entry-points

For compatibility, if no parameters are passed to entry_points, a SelectableGroups object is returned, implementing that dict interface. In the future, calling entry_points with no parameters will return an EntryPoints object. Users should rely on the selection interface to retrieve entry points by group.

This is what happens in 3.12, so .get() is no longer valid.

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