From 148d1f56701df24721586ecb385f1b0090f9d8b3 Mon Sep 17 00:00:00 2001 From: "Panagiotis H.M. Issaris" Date: Tue, 3 Oct 2023 15:34:37 +0200 Subject: [PATCH 1/4] Remove Python 3.7 support due to EOL --- .github/workflows/tests.yml | 2 +- CHANGES.rst | 2 ++ django_countries/fields.py | 10 ++-------- setup.cfg | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b1f06674..154dea37 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.10", "3.11"] + python-version: ["3.8", "3.10", "3.11"] steps: - name: Set up Python ${{ matrix.python-version }} diff --git a/CHANGES.rst b/CHANGES.rst index 681f4d63..cf0e879d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -12,6 +12,8 @@ release, and any new translations added. - Replace deprecated ``pkg_resources.iter_entry_points`` with ``importlib_metadata``. +- Drop Python 3.7 support. + 7.5.1 (1 February 2023) ======================= diff --git a/django_countries/fields.py b/django_countries/fields.py index 1351d7f5..66122232 100644 --- a/django_countries/fields.py +++ b/django_countries/fields.py @@ -1,3 +1,4 @@ +import importlib.metadata import re from typing import Any, Iterable, Optional, Tuple, Type, Union, cast from urllib import parse as urlparse @@ -15,16 +16,9 @@ from django_countries.conf import settings _entry_points: Iterable[Any] -try: - import importlib.metadata - _entry_points = importlib.metadata.entry_points().get( - "django_countries.Country", [] - ) -except ImportError: # Python <3.8 - import pkg_resources +_entry_points = importlib.metadata.entry_points().get("django_countries.Country", []) - _entry_points = pkg_resources.iter_entry_points("django_countries.Country") EXTENSIONS = {ep.name: ep.load() for ep in _entry_points} # type: ignore diff --git a/setup.cfg b/setup.cfg index 471a4f7c..c94290ab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,6 @@ classifiers = Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 From 9eb7cc3cf5a1e15a4dcabb6308bd0593ee16e2de Mon Sep 17 00:00:00 2001 From: "Panagiotis H.M. Issaris" Date: Tue, 3 Oct 2023 15:44:16 +0200 Subject: [PATCH 2/4] Add Python 3.12 support --- .github/workflows/tests.yml | 2 +- CHANGES.rst | 2 ++ django_countries/fields.py | 7 ++++++- setup.cfg | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 154dea37..1847463c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.10", "3.11"] + python-version: ["3.8", "3.10", "3.11", "3.12"] steps: - name: Set up Python ${{ matrix.python-version }} diff --git a/CHANGES.rst b/CHANGES.rst index cf0e879d..31d83e38 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,8 @@ release, and any new translations added. - Drop Python 3.7 support. +- Add Python 3.12 support. + 7.5.1 (1 February 2023) ======================= diff --git a/django_countries/fields.py b/django_countries/fields.py index 66122232..94740e43 100644 --- a/django_countries/fields.py +++ b/django_countries/fields.py @@ -1,5 +1,6 @@ import importlib.metadata import re +import sys from typing import Any, Iterable, Optional, Tuple, Type, Union, cast from urllib import parse as urlparse @@ -17,7 +18,11 @@ _entry_points: Iterable[Any] -_entry_points = importlib.metadata.entry_points().get("django_countries.Country", []) +_entry_points = importlib.metadata.entry_points() +if sys.version_info >= (3, 10): + _entry_points = _entry_points.select(group="django_countries.Country") +else: + _entry_points = _entry_points.get("django_countries.Country", []) EXTENSIONS = {ep.name: ep.load() for ep in _entry_points} # type: ignore diff --git a/setup.cfg b/setup.cfg index c94290ab..d79e5af7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,6 +20,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Framework :: Django Framework :: Django :: 3.2 Framework :: Django :: 4.0 From e40e897560341d1e016f1a9f29ea710911872190 Mon Sep 17 00:00:00 2001 From: "Panagiotis H.M. Issaris" Date: Tue, 3 Oct 2023 16:32:51 +0200 Subject: [PATCH 3/4] Update Python versions in tox --- tox.ini | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 67fbb9dc..5bbba576 100644 --- a/tox.ini +++ b/tox.ini @@ -3,11 +3,11 @@ distribute = False envlist = coverage_setup # Latest - py311-latest{-pyuca,-noi18n} + py312-latest{-pyuca,-noi18n} # Historical Python, Django and DRF versions - py310-previous + py311-previous # Legacy - py37-legacy + py38-legacy # Package checks readme bandit @@ -18,9 +18,10 @@ ignore_basepython_conflict = True [gh-actions] python = - 3.7: py37 + 3.8: py38 3.10: py310 - 3.11: py311, readme, bandit, mypy + 3.11: py311 + 3.12: py312, readme, bandit, mypy [testenv] basepython = python3 @@ -50,7 +51,7 @@ commands = rst2html.py --report=info --halt=warning README.rst /dev/null rst2html.py --report=info --halt=warning CHANGES.rst /dev/null -[py311-latest-noi18n] +[py312-latest-noi18n] setenv = DJANGO_SETTINGS_MODULE = django_countries.tests.settings_noi18n From ec3e8c3495b63aea1b668770dcf982f70b72ff22 Mon Sep 17 00:00:00 2001 From: "Panagiotis H.M. Issaris" Date: Tue, 3 Oct 2023 16:38:07 +0200 Subject: [PATCH 4/4] Update Python versions in tox for coverage --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 5bbba576..b6c07bad 100644 --- a/tox.ini +++ b/tox.ini @@ -74,11 +74,11 @@ commands = coverage erase skip_install = True parallel_show_output = True depends = - py310-latest{-pyuca} + py312-latest{-pyuca} noi18n - py36-django32-drf312 + py38-django32-drf312 py39-django{32,40}-drf313 - py36-legacy + py38-legacy commands = coverage combine coverage html