Kozea / Kozea/pygal

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

Open
#545 7 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
2.8k
Forks
419
PR merge metrics
No merged PRs in 30d

Description

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:

```pytb
$ 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
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.

Contributor guide

Open the contributing guide

Research direction

Start in pygal/__init__.py, where entry_points() is used while loading map plugins, and review the compatibility note for importlib.metadata. Run tox -e py312 and the tests under pygal/test first. Done means the Python 3.12 test run no longer raises the EntryPoints.get() error and the existing tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.