Skip to content

tools/generate-pkginfo.py: Allow to use tomllib instead of tomli on Python >= 3.11

Timo Gurr requested to merge tgurr/dbus-python:tomllib into master

Fixes #54 (closed).

Tested on both python 3.12 (without tomli) and python 3.8 with and without tomli installed:

Python 3.8 without tomli:

$ python3.8 /var/tmp/paludis/build/dev-python-dbus-python-1.3.2/work/dbus-python-1.3.2/tools/generate-pkginfo.py 1.3.2 PKG-INFO-3.8
Traceback (most recent call last):
  File "/var/tmp/paludis/build/dev-python-dbus-python-1.3.2/work/dbus-python-1.3.2/tools/generate-pkginfo.py", line 14, in <module>
    import tomllib
ModuleNotFoundError: No module named 'tomllib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/paludis/build/dev-python-dbus-python-1.3.2/work/dbus-python-1.3.2/tools/generate-pkginfo.py", line 16, in <module>
    import tomli as tomllib
ModuleNotFoundError: No module named 'tomli'

Python 3.8 with tomli installed:

$ python3.8 /var/tmp/paludis/build/dev-python-dbus-python-1.3.2/work/dbus-python-1.3.2/tools/generate-pkginfo.py 1.3.2 PKG-INFO-3.8

Python 3.12 without tomli installed (tomllib):

$ python3.12 /var/tmp/paludis/build/dev-python-dbus-python-1.3.2/work/dbus-python-1.3.2/tools/generate-pkginfo.py 1.3.2 PKG-INFO-3.12

A diff shows no difference between the two:

$ diff -Naur PKG-INFO-3.8 PKG-INFO-3.12

(I refrained from adding something to pyproject.toml/setup.py/setup.cfg as tomli and pyproject_metadata were not already specified there.)

Merge request reports

Loading