Skip to content

Commit

Permalink
Maintenance: Add support for Python 3.12
Browse files Browse the repository at this point in the history
The `pkg_resources` module became deprecated. `importlib.metadata` is
the right choice now to inquire package versions.

However, it is only there starting with Python 3.8. For Python 3.7,
there is the `importlib-metadata` backport package on PyPI.
  • Loading branch information
amotl committed Feb 10, 2024
1 parent a47358b commit fab673b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions cr8/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import pkg_resources
try:
from importlib.metadata import PackageNotFoundError, version
except ModuleNotFoundError: # pragma:nocover
from importlib_metadata import PackageNotFoundError, version

__version__ = pkg_resources.require('cr8')[0].version
try:
__version__ = version("cr8")
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
'Faker>=4.0,<5.0',
'aiohttp>=3.3,<4',
'toml;python_version<"3.11"',
'asyncpg'
'asyncpg',
'importlib-metadata;python_version<"3.8"',
],
extras_require={
'extra': ['uvloop', 'pysimdjson']
Expand All @@ -44,6 +45,7 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
],
use_scm_version=True,
setup_requires=['setuptools_scm']
Expand Down

0 comments on commit fab673b

Please sign in to comment.