From 4a13f7483faf86f9a32682043321305b026e70a0 Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Wed, 25 Oct 2023 15:31:36 +0200 Subject: [PATCH 1/6] Prepare for Django 5.0 / Python3.12 compatibility --- .github/workflows/test.yml | 9 +++++++-- app_helper/utils.py | 19 ++++++++++++++----- changes/244.feature | 1 + setup.cfg | 2 +- tox.ini | 3 +++ 5 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 changes/244.feature diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d10d1b..a7cd540 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,10 +9,15 @@ jobs: continue-on-error: ${{ matrix.continue-on-error }} strategy: matrix: - python-version: ["3.11", "3.10", "3.9"] - django: [42, 32] + python-version: ["3.12", "3.11", "3.10", "3.9"] + django: [50, 42, 32] cms: [nocms, cms311, async] continue-on-error: [false] + exclude: + - django: 50 + cms: cms311 + - django: 50 + python-version: 3.9 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/app_helper/utils.py b/app_helper/utils.py index 7252629..9764c66 100644 --- a/app_helper/utils.py +++ b/app_helper/utils.py @@ -4,7 +4,6 @@ import shutil import string import sys -from distutils.version import LooseVersion from tempfile import mkdtemp from unittest.mock import patch @@ -16,6 +15,11 @@ from . import HELPER_FILE +try: + from distutils.version import LooseVersion +except ImportError: # pragma: no cover + from setuptools import LooseVersion + try: import cms # NOQA @@ -61,12 +65,17 @@ def load_from_file(module_path): Borrowed from django-cms """ - from imp import PY_SOURCE, load_module - imported = None if module_path: - with open(module_path) as openfile: - imported = load_module("mod", openfile, module_path, ("imported", "r", PY_SOURCE)) + try: + from imp import PY_SOURCE, load_module + + with open(module_path) as openfile: + imported = load_module("mod", openfile, module_path, ("imported", "r", PY_SOURCE)) + except ImportError: # pragma: no cover + from importlib.machinery import SourceFileLoader + + imported = SourceFileLoader("mod", module_path).load_module() return imported diff --git a/changes/244.feature b/changes/244.feature new file mode 100644 index 0000000..941eb31 --- /dev/null +++ b/changes/244.feature @@ -0,0 +1 @@ +Prepare for Django 5.0 / Python 3.12 compatibility diff --git a/setup.cfg b/setup.cfg index dc487f2..e6e6869 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ description = Helper for django applications development long_description = file: README.rst, HISTORY.rst long_description_content_type = text/x-rst license = GPLv2+ -license_file = LICENSE +license_files = LICENSE classifiers = License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) Development Status :: 5 - Production/Stable diff --git a/tox.ini b/tox.ini index 2f92d25..ce33715 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ envlist = ruff pypi-description towncrier + py{312}-django{42,50}-{nocms,async} py{311}-django{42,41,40,32}-{cms311,nocms,async} py{310}-django{42,41,40,32}-{cms311,nocms,async} py{39}-django{32}-{cms311,nocms,async} @@ -20,8 +21,10 @@ deps= django40: django~=4.0.0 django41: django~=4.1.0 django42: django~=4.2.0 + django50: django~=5.0b1 cms311: https://github.com/yakky/django-cms/archive/release/3.11.x.zip cms311: djangocms-text-ckeditor>=5.0,<6.0 + py312: setuptools -r{toxinidir}/requirements-test.txt async: channels[daphne]~=4.0.0 passenv = From 5afb386b38d33837ca953ebd9aa305595c4eff87 Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Thu, 26 Oct 2023 09:02:46 +0200 Subject: [PATCH 2/6] Try to fix ci --- .github/workflows/test.yml | 2 +- tox.ini | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7cd540..fc03e89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: python -m pip install --upgrade pip setuptools tox>4 - name: Test with tox env: - TOX_ENV: ${{ format('py-django{1}-{2}', matrix.python-version, matrix.django, matrix.cms) }} + TOX_ENV: ${{ format('py{0}-django{1}-{2}', matrix.python-version, matrix.django, matrix.cms) }} COMMAND: coverage run COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_SERVICE_NAME: github diff --git a/tox.ini b/tox.ini index ce33715..038bf42 100644 --- a/tox.ini +++ b/tox.ini @@ -8,10 +8,10 @@ envlist = ruff pypi-description towncrier - py{312}-django{42,50}-{nocms,async} - py{311}-django{42,41,40,32}-{cms311,nocms,async} - py{310}-django{42,41,40,32}-{cms311,nocms,async} - py{39}-django{32}-{cms311,nocms,async} + py{3.12}-django{42,50}-{nocms,async} + py{3.11}-django{42,41,40,32}-{cms311,nocms,async} + py{3.10}-django{42,41,40,32}-{cms311,nocms,async} + py{3.9}-django{32}-{cms311,nocms,async} minversion = 3.23 [testenv] @@ -24,7 +24,7 @@ deps= django50: django~=5.0b1 cms311: https://github.com/yakky/django-cms/archive/release/3.11.x.zip cms311: djangocms-text-ckeditor>=5.0,<6.0 - py312: setuptools + py3.12: setuptools -r{toxinidir}/requirements-test.txt async: channels[daphne]~=4.0.0 passenv = From c01f3783801441dceba89cc4507a63f54a48c86b Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Thu, 26 Oct 2023 09:28:37 +0200 Subject: [PATCH 3/6] Switch try-except for better readability --- app_helper/utils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app_helper/utils.py b/app_helper/utils.py index 9764c66..5cf02d5 100644 --- a/app_helper/utils.py +++ b/app_helper/utils.py @@ -16,9 +16,9 @@ from . import HELPER_FILE try: - from distutils.version import LooseVersion -except ImportError: # pragma: no cover from setuptools import LooseVersion +except ImportError: # pragma: no cover + from distutils.version import LooseVersion try: import cms # NOQA @@ -68,14 +68,14 @@ def load_from_file(module_path): imported = None if module_path: try: + from importlib.machinery import SourceFileLoader + + imported = SourceFileLoader("mod", module_path).load_module() + except ImportError: # pragma: no cover from imp import PY_SOURCE, load_module with open(module_path) as openfile: imported = load_module("mod", openfile, module_path, ("imported", "r", PY_SOURCE)) - except ImportError: # pragma: no cover - from importlib.machinery import SourceFileLoader - - imported = SourceFileLoader("mod", module_path).load_module() return imported From f0d2bc13e1431d1c60e8204b9c5376bf829a9e1f Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Tue, 31 Oct 2023 09:05:03 +0100 Subject: [PATCH 4/6] Better declaration for install_requires and test matrix --- .github/workflows/test.yml | 4 +++- README.rst | 4 ++-- setup.cfg | 4 +++- tox.ini | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc03e89..0c8db2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: continue-on-error: ${{ matrix.continue-on-error }} strategy: matrix: - python-version: ["3.12", "3.11", "3.10", "3.9"] + python-version: ["3.12", "3.11", "3.10", "3.9", "3.8"] django: [50, 42, 32] cms: [nocms, cms311, async] continue-on-error: [false] @@ -18,6 +18,8 @@ jobs: cms: cms311 - django: 50 python-version: 3.9 + - django: 50 + python-version: 3.8 steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} diff --git a/README.rst b/README.rst index cf22b05..bf9be53 100644 --- a/README.rst +++ b/README.rst @@ -28,9 +28,9 @@ It supports both tests writted using Django ``TestCase`` and pytest ones Supported versions ================== -Python: 3.9, 3.10, 3.11 +Python: 3.8, 3.9, 3.10, 3.11, 3.12 -Django: 3.2, 4.0, 4.1, 4.2 +Django: 3.2, 4.0, 4.1, 4.2, 5.0 django CMS: 3.11 diff --git a/setup.cfg b/setup.cfg index e6e6869..fe73327 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,13 +18,14 @@ classifiers = Framework :: Django :: 3.2 Framework :: Django :: 4.1 Framework :: Django :: 4.2 + Framework :: Django :: 5.0 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 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 [options] include_package_data = True @@ -32,6 +33,7 @@ install_requires = dj-database-url docopt six + setuptools; python_version>="3.12" setup_requires = setuptools packages = find: diff --git a/tox.ini b/tox.ini index 038bf42..a864d68 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ envlist = py{3.11}-django{42,41,40,32}-{cms311,nocms,async} py{3.10}-django{42,41,40,32}-{cms311,nocms,async} py{3.9}-django{32}-{cms311,nocms,async} + py{3.8}-django{32}-{cms311,nocms,async} minversion = 3.23 [testenv] @@ -24,7 +25,6 @@ deps= django50: django~=5.0b1 cms311: https://github.com/yakky/django-cms/archive/release/3.11.x.zip cms311: djangocms-text-ckeditor>=5.0,<6.0 - py3.12: setuptools -r{toxinidir}/requirements-test.txt async: channels[daphne]~=4.0.0 passenv = From d27d55eb8c7008ea099c337820c946f987d5a6e8 Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Mon, 27 Nov 2023 18:16:45 +0100 Subject: [PATCH 5/6] Pin correct Django 5.0 version --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index a864d68..000aa05 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ deps= django40: django~=4.0.0 django41: django~=4.1.0 django42: django~=4.2.0 - django50: django~=5.0b1 + django50: django~=5.0.0b1 cms311: https://github.com/yakky/django-cms/archive/release/3.11.x.zip cms311: djangocms-text-ckeditor>=5.0,<6.0 -r{toxinidir}/requirements-test.txt From 6ff15bc75779a74b0b0c8682de7d6205b90bce3d Mon Sep 17 00:00:00 2001 From: Leonardo Cavallucci Date: Tue, 28 Nov 2023 09:39:40 +0100 Subject: [PATCH 6/6] Add disclaimer for Django 5.0 support --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index bf9be53..5bd7a12 100644 --- a/README.rst +++ b/README.rst @@ -9,6 +9,8 @@ Django App helper Starting from 3 django-app-helper only supports Django 2.2+ and django CMS 3.7+. If you need support for older (unsupported) versions, use django-app-helper 2. + Django 5.0 support exclude django CMS 3.11 support, as django CMS 3.11 doesn't yet support Django 5.0. + ****************************************** Helper for django applications development ******************************************