Repository: jazzband/djangorestframework-simplejwt (language: python)

Issue:
Reference to pkg_resources
Setuptools has deprecated `pkg_resources`, and recommends to `importlib` instead. 
This results in a deprecation warnings for `setuptools >= 67.3.0`. 
https://setuptools.pypa.io/en/latest/pkg_resources.html

Also the [python packaging docs](https://packaging.python.org/en/latest/guides/single-sourcing-package-version/) say the same, and recommend the following snippet. 
```python
import sys

if sys.version_info >= (3, 8):
    from importlib import metadata
else:
    import importlib_metadata as metadata

__version__ =  metadata.version("djangorestframework_simplejwt")
```
Note that this does include an additional depenceny for Python 3.7, `importlib-metadata`. With that, all seems to work fine for your supported python versions (3.7-3.10)
Fix #684
Fixes #684 

Attempts to fix using @nielsuit227's code

Note: This creates a dependency on `importlib-metadata` for Python 3.7

Also note:  I am not sure how to update setup to conditionally depend on `importlib-metadata`, please advise


Discussion / hints:
This might be a Jazzband-wide problem. CC @jezdez seeing if anyone else has a different method of doing the same.

But lgtm! Feel free to open a PR
what do you think about something like this ugly example:
```PYTHON
import sys


if sys.version_info >= (3, 8):
    from importlib import metadata
    try:
        __version__ = metadata.version("djangorestframework_simplejwt")
    except metadata.PackageNotFoundError:
        # package is not installed
        __version__ = None
else:
    from pkg_resources import DistributionNotFound, get_distribution

    try:
        __version__ = get_distribution("djangorestframework_simplejwt").version
    except DistributionNotFound:
        # package is not installed
        __version__ = None
```
[https://github.com/jazzband/djangorestframework-simplejwt/pull/702#issuecomment-1652919553](https://github.com/jazzband/djangorestframework-simplejwt/pull/702#issuecomment-1652919553)
If possible, to avoid the dependency, can you use the old code when Python < 3.8 in your if else statement? Thank you
> If possible, to avoid the dependency, can you use the old code when Python < 3.8 in your if else statement? Thank you

On python 3.7.11 it breaks with `NameError: name 'DistributionNotFound' is not defined`

I think I will have to keep dependency on importlib-metadata on python 3.7
why not hardcode the version in `__init__.py` and then change setup.py to read the version from it?
what do you think about something like this ugly example:
```PYTHON
import sys

if sys.version_info >= (3, 8):
    from importlib import metadata
    try:
        __version__ = metadata.version("djangorestframework_simplejwt")
    except metadata.PackageNotFoundError:
        # package is not installed
        __version__ = None
else:
    from pkg_resources import DistributionNotFound, get_distribution

    try:
        __version__ = get_distribution("djangorestframework_simplejwt").version
    except DistributionNotFound:
        # package is not installed
        __version__ = None
```

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2a2894302..864f1724a 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -51,7 +51,7 @@ repos:
   rev: 'v3.7.0'
   hooks:
   - id: pyupgrade
-    args: ['--py37-plus', '--keep-mock']
+    args: ['--py38-plus', '--keep-mock']
 
 - repo: https://github.com/Lucas-C/pre-commit-hooks-markup
   rev: v1.0.1
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index 42e646187..f7db9b7f1 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -7,8 +7,8 @@ Requirements
 ------------
 
 * Python (3.8, 3.9, 3.10, 3.11)
-* Django (3.2, 4.0, 4.1, 4.2)
-* Django REST Framework (3.10, 3.11, 3.12, 3.13, 3.14)
+* Django (3.2, 4.1, 4.2)
+* Django REST Framework (3.12, 3.13, 3.14)
 
 These are the officially supported python and package versions.  Other versions
 will probably work.  You're free to modify the tox config and see what is
diff --git a/rest_framework_simplejwt/__init__.py b/rest_framework_simplejwt/__init__.py
index 6929b410c..b001cf5d3 100644
--- a/rest_framework_simplejwt/__init__.py
+++ b/rest_framework_simplejwt/__init__.py
@@ -1,7 +1,7 @@
-from pkg_resources import DistributionNotFound, get_distribution
+from importlib.metadata import PackageNotFoundError, version
 
 try:
-    __version__ = get_distribution("djangorestframework_simplejwt").version
-except DistributionNotFound:
+    __version__ = version("djangorestframework_simplejwt")
+except PackageNotFoundError:
     # package is not installed
     __version__ = None
diff --git a/setup.py b/setup.py
index 4fd09303f..60327eeef 100755
--- a/setup.py
+++ b/setup.py
@@ -56,10 +56,10 @@
     author_email="davesque@gmail.com",
     install_requires=[
         "django>=3.2",
-        "djangorestframework>=3.10",
+        "djangorestframework>=3.12",
         "pyjwt>=1.7.1,<3",
     ],
-    python_requires=">=3.7",
+    python_requires=">=3.8",
     extras_require=extras_require,
     packages=find_packages(exclude=["tests", "tests.*", "licenses", "requirements"]),
     include_package_data=True,
@@ -69,7 +69,6 @@
         "Environment :: Web Environment",
         "Framework :: Django",
         "Framework :: Django :: 3.2",
-        "Framework :: Django :: 4.0",
         "Framework :: Django :: 4.1",
         "Framework :: Django :: 4.2",
         "Intended Audience :: Developers",
@@ -77,7 +76,6 @@
         "Operating System :: OS Independent",
         "Programming Language :: Python",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
diff --git a/tox.ini b/tox.ini
index 8fb68941b..e127b8b11 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,13 +1,12 @@
 [tox]
 envlist=
-    py{37,38,39,310}-dj{32}-drf{311,312,313}-pyjwt{171,2}-tests
-    py{38,39,310}-dj{40,41,42}-drf313-pyjwt{171,2}-tests
+    py{38,39,310}-dj{32}-drf{312,313}-pyjwt{171,2}-tests
+    py{38,39,310}-dj{41,42}-drf313-pyjwt{171,2}-tests
     py311-dj{41,42}-drf{313,314}-pyjwt{171,2}-tests
     docs
 
 [gh-actions]
 python=
-    3.7: py37
     3.8: py38, docs
     3.9: py39
     3.10: py310
@@ -16,12 +15,9 @@ python=
 [gh-actions:env]
 DJANGO=
     3.2: dj32
-    4.0: dj40
     4.1: dj41
     4.2: dj42
 DRF=
-    3.10: drf310
-    3.11: drf311
     3.12: drf312
     3.13: drf313
     3.14: drf314
@@ -35,11 +31,8 @@ setenv=
     PYTHONDONTWRITEBYTECODE=1
 deps=
     dj32: Django>=3.2,<3.3
-    dj40: Django>=4.0,<4.1
     dj41: Django>=4.1,<4.2
     dj42: Django>=4.2,<4.3
-    drf310: djangorestframework>=3.10,<3.11
-    drf311: djangorestframework>=3.11,<3.12
     drf312: djangorestframework>=3.12,<3.13
     drf313: djangorestframework>=3.13,<3.14
     drf314: djangorestframework>=3.14,<3.15


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b41516d59..7ce5e28aa 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -15,9 +15,9 @@ jobs:
       fail-fast: false
       max-parallel: 5
       matrix:
-        python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
-        django-version: ['3.2', '4.0', '4.1', '4.2']
-        drf-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
+        python-version: [ '3.8', '3.9', '3.10', '3.11']
+        django-version: ['3.2', '4.1', '4.2']
+        drf-version: ['3.12', '3.13', '3.14']
         exclude:
           # DRF 3.13 is not compatible with Django 4.2.
           - django-version: '4.2'