From d4a990bd4cfc6770b93298ea0c51f8a72dcd947c Mon Sep 17 00:00:00 2001 From: Faisal Date: Mon, 9 Sep 2024 13:15:17 +0500 Subject: [PATCH 1/6] chore: updated python to 3.11 and replaced pkg_resources to importlib --- .github/workflows/ci.yml | 2 +- .github/workflows/pypi-publish.yml | 2 +- recommender/recommender.py | 10 +++++----- requirements/base.txt | 2 +- requirements/ci.txt | 4 ++-- requirements/pip.txt | 2 +- requirements/pip_tools.txt | 2 +- requirements/test.txt | 2 +- setup.py | 1 - 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cffcdee..7429a7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: matrix: os: - ubuntu-latest - python-version: ['3.8', '3.11'] + python-version: ['3.11'] steps: - uses: actions/checkout@v1 - name: setup python diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 17eb5fd..355716e 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -15,7 +15,7 @@ jobs: - name: setup python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.11 - name: Install pip run: pip install -r requirements/pip.txt diff --git a/recommender/recommender.py b/recommender/recommender.py index 3ad6101..af69a11 100644 --- a/recommender/recommender.py +++ b/recommender/recommender.py @@ -8,7 +8,7 @@ import hashlib import simplejson as json import lxml.etree as etree -import pkg_resources +import importlib.resources import re from copy import deepcopy @@ -55,8 +55,8 @@ def emit(param1, param2): def load(path): """Handy helper for getting resources from our kit.""" - data = pkg_resources.resource_string(__name__, path) - return data.decode("utf8") + data = importlib.resources.files(__package__).joinpath(path) + return data.read_text(encoding="utf-8") def stem_url(url): @@ -123,8 +123,8 @@ def resource_string(self, path): """ Handy helper for getting static file resources from our Python package. """ - data = pkg_resources.resource_string(__name__, path) - return data.decode("utf8") + data = importlib.resources.files(__package__).joinpath(path) + return data.read_text(encoding="utf-8") @XBlock.needs('fs') diff --git a/requirements/base.txt b/requirements/base.txt index ea40e4d..819457a 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -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 diff --git a/requirements/ci.txt b/requirements/ci.txt index 28a82f2..2143b6a 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -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 @@ -12,7 +12,7 @@ asgiref==3.8.1 # via # -r requirements/test.txt # django -backports-zoneinfo==0.2.1 ; python_version < "3.9" +backports-zoneinfo==0.2.1 ; python_version < "3.12" # via # -c requirements/constraints.txt # -r requirements/test.txt diff --git a/requirements/pip.txt b/requirements/pip.txt index cf44902..218ba66 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -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 diff --git a/requirements/pip_tools.txt b/requirements/pip_tools.txt index 3db2d4c..a61abc5 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -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 diff --git a/requirements/test.txt b/requirements/test.txt index 28d048c..20eb7e2 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -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 diff --git a/setup.py b/setup.py index ef169a3..6c8d008 100644 --- a/setup.py +++ b/setup.py @@ -92,7 +92,6 @@ def get_version(file_path): "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Natural Language :: English", "Programming Language :: Python :: 3", - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.11', ], ) From 490ae84ab0f7885d6b40660fd9b194779042857e Mon Sep 17 00:00:00 2001 From: Faisal Date: Tue, 10 Sep 2024 14:49:51 +0500 Subject: [PATCH 2/6] chore: updated packages based on python 3.11 --- requirements/base.txt | 32 +++++++++++++++----------------- requirements/ci.txt | 36 ++++++++++++++++-------------------- requirements/pip.txt | 6 +++--- requirements/pip_tools.txt | 19 ++++--------------- requirements/test.txt | 36 ++++++++++++++++-------------------- 5 files changed, 54 insertions(+), 75 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 819457a..50815f4 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -8,47 +8,45 @@ appdirs==1.4.4 # via fs asgiref==3.8.1 # via django -backports-zoneinfo==0.2.1 ; python_version < "3.9" - # via - # -c requirements/constraints.txt - # django bleach==6.1.0 # via -r requirements/base.in -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # edx-i18n-tools -edx-i18n-tools==1.3.0 +edx-i18n-tools==1.6.3 # via -r requirements/base.in fs==2.4.16 # via -r requirements/base.in -lxml==5.1.0 - # via edx-i18n-tools -mako==1.3.2 +lxml[html-clean,html_clean]==5.3.0 + # via + # edx-i18n-tools + # lxml-html-clean +lxml-html-clean==0.2.2 + # via lxml +mako==1.3.5 # via -r requirements/base.in markupsafe==2.1.5 # via mako -path==16.10.0 +path==16.16.0 # via edx-i18n-tools polib==1.2.0 # via edx-i18n-tools -pyyaml==6.0.1 +pyyaml==6.0.2 # via edx-i18n-tools -simplejson==3.19.2 +simplejson==3.19.3 # via -r requirements/base.in six==1.16.0 # via # bleach # fs -sqlparse==0.4.4 +sqlparse==0.5.1 # via django -typing-extensions==4.10.0 - # via asgiref -web-fragments==2.1.0 +web-fragments==2.2.0 # via -r requirements/base.in webencodings==0.5.1 # via bleach -webob==1.8.7 +webob==1.8.8 # via -r requirements/base.in # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/ci.txt b/requirements/ci.txt index 2143b6a..86e0e08 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -12,33 +12,33 @@ asgiref==3.8.1 # via # -r requirements/test.txt # django -backports-zoneinfo==0.2.1 ; python_version < "3.12" - # via - # -c requirements/constraints.txt - # -r requirements/test.txt - # django bleach==6.1.0 # via -r requirements/test.txt -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # -r requirements/test.txt # edx-i18n-tools -edx-i18n-tools==1.3.0 +edx-i18n-tools==1.6.3 # via -r requirements/test.txt fs==2.4.16 # via -r requirements/test.txt -lxml==5.1.0 +lxml[html-clean]==5.3.0 # via # -r requirements/test.txt # edx-i18n-tools -mako==1.3.2 + # lxml-html-clean +lxml-html-clean==0.2.2 + # via + # -r requirements/test.txt + # lxml +mako==1.3.5 # via -r requirements/test.txt markupsafe==2.1.5 # via # -r requirements/test.txt # mako -path==16.10.0 +path==16.16.0 # via # -r requirements/test.txt # edx-i18n-tools @@ -46,34 +46,30 @@ polib==1.2.0 # via # -r requirements/test.txt # edx-i18n-tools -pycodestyle==2.11.1 +pycodestyle==2.12.1 # via -r requirements/test.txt -pyyaml==6.0.1 +pyyaml==6.0.2 # via # -r requirements/test.txt # edx-i18n-tools -simplejson==3.19.2 +simplejson==3.19.3 # via -r requirements/test.txt six==1.16.0 # via # -r requirements/test.txt # bleach # fs -sqlparse==0.4.4 +sqlparse==0.5.1 # via # -r requirements/test.txt # django -typing-extensions==4.10.0 - # via - # -r requirements/test.txt - # asgiref -web-fragments==2.1.0 +web-fragments==2.2.0 # via -r requirements/test.txt webencodings==0.5.1 # via # -r requirements/test.txt # bleach -webob==1.8.7 +webob==1.8.8 # via -r requirements/test.txt # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/pip.txt b/requirements/pip.txt index 218ba66..f313a9c 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -4,11 +4,11 @@ # # make upgrade # -wheel==0.43.0 +wheel==0.44.0 # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==24.0 +pip==24.2 # via -r requirements/pip.in -setuptools==69.2.0 +setuptools==74.1.2 # via -r requirements/pip.in diff --git a/requirements/pip_tools.txt b/requirements/pip_tools.txt index a61abc5..77d81ad 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -4,31 +4,20 @@ # # make upgrade # -build==1.1.1 +build==1.2.2 # via pip-tools click==8.1.7 # via pip-tools -importlib-metadata==6.11.0 - # via - # -c requirements/common_constraints.txt - # build -packaging==24.0 +packaging==24.1 # via build pip-tools==7.4.1 # via -r requirements/pip_tools.in -pyproject-hooks==1.0.0 - # via - # build - # pip-tools -tomli==2.0.1 +pyproject-hooks==1.1.0 # via # build # pip-tools - # pyproject-hooks -wheel==0.43.0 +wheel==0.44.0 # via pip-tools -zipp==3.18.1 - # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/requirements/test.txt b/requirements/test.txt index 20eb7e2..6498184 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -12,33 +12,33 @@ asgiref==3.8.1 # via # -r requirements/base.txt # django -backports-zoneinfo==0.2.1 ; python_version < "3.9" - # via - # -c requirements/constraints.txt - # -r requirements/base.txt - # django bleach==6.1.0 # via -r requirements/base.txt -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # -r requirements/base.txt # edx-i18n-tools -edx-i18n-tools==1.3.0 +edx-i18n-tools==1.6.3 # via -r requirements/base.txt fs==2.4.16 # via -r requirements/base.txt -lxml==5.1.0 +lxml[html-clean]==5.3.0 # via # -r requirements/base.txt # edx-i18n-tools -mako==1.3.2 + # lxml-html-clean +lxml-html-clean==0.2.2 + # via + # -r requirements/base.txt + # lxml +mako==1.3.5 # via -r requirements/base.txt markupsafe==2.1.5 # via # -r requirements/base.txt # mako -path==16.10.0 +path==16.16.0 # via # -r requirements/base.txt # edx-i18n-tools @@ -46,34 +46,30 @@ polib==1.2.0 # via # -r requirements/base.txt # edx-i18n-tools -pycodestyle==2.11.1 +pycodestyle==2.12.1 # via -r requirements/test.in -pyyaml==6.0.1 +pyyaml==6.0.2 # via # -r requirements/base.txt # edx-i18n-tools -simplejson==3.19.2 +simplejson==3.19.3 # via -r requirements/base.txt six==1.16.0 # via # -r requirements/base.txt # bleach # fs -sqlparse==0.4.4 +sqlparse==0.5.1 # via # -r requirements/base.txt # django -typing-extensions==4.10.0 - # via - # -r requirements/base.txt - # asgiref -web-fragments==2.1.0 +web-fragments==2.2.0 # via -r requirements/base.txt webencodings==0.5.1 # via # -r requirements/base.txt # bleach -webob==1.8.7 +webob==1.8.8 # via -r requirements/base.txt # The following packages are considered to be unsafe in a requirements file: From fe89d6635b2df6e110b4e301a6b945c3c5945c42 Mon Sep 17 00:00:00 2001 From: Faisal Date: Tue, 10 Sep 2024 14:57:25 +0500 Subject: [PATCH 3/6] chore: used resource loader of xblock instead of directly using importlib --- recommender/recommender.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/recommender/recommender.py b/recommender/recommender.py index af69a11..4615962 100644 --- a/recommender/recommender.py +++ b/recommender/recommender.py @@ -8,7 +8,6 @@ import hashlib import simplejson as json import lxml.etree as etree -import importlib.resources import re from copy import deepcopy @@ -55,8 +54,7 @@ def emit(param1, param2): def load(path): """Handy helper for getting resources from our kit.""" - data = importlib.resources.files(__package__).joinpath(path) - return data.read_text(encoding="utf-8") + return resource_loader.load_unicode(path) def stem_url(url): @@ -123,8 +121,7 @@ def resource_string(self, path): """ Handy helper for getting static file resources from our Python package. """ - data = importlib.resources.files(__package__).joinpath(path) - return data.read_text(encoding="utf-8") + return resource_loader.load_unicode(path) @XBlock.needs('fs') From 98b9851dbfc97999cf0c1d1c428a43469bb4a950 Mon Sep 17 00:00:00 2001 From: Faisal Date: Wed, 25 Sep 2024 11:05:49 +0500 Subject: [PATCH 4/6] chore: added support for python 3.12 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 6c8d008..cd2e05e 100644 --- a/setup.py +++ b/setup.py @@ -93,5 +93,6 @@ def get_version(file_path): "Natural Language :: English", "Programming Language :: Python :: 3", 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], ) From dd0499b8e7c675e3c67abf88147759a2190492e6 Mon Sep 17 00:00:00 2001 From: Faisal Date: Mon, 30 Sep 2024 16:44:15 +0500 Subject: [PATCH 5/6] chore: updated xblock version and added support python 3.12 in ci --- .github/workflows/ci.yml | 2 +- recommender/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7429a7c..e432a0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: matrix: os: - ubuntu-latest - python-version: ['3.11'] + python-version: ['3.11', '3.12'] steps: - uses: actions/checkout@v1 - name: setup python diff --git a/recommender/__init__.py b/recommender/__init__.py index 4e38f26..2bd9748 100644 --- a/recommender/__init__.py +++ b/recommender/__init__.py @@ -6,4 +6,4 @@ # which is not loaded when running `manage.py` commands (which is used by `make compile_translations`) # from .recommender import RecommenderXBlock -__version__ = '2.2.1' +__version__ = '2.2.2' From f54512af41e48b1aa8a857215984777294b7cdd0 Mon Sep 17 00:00:00 2001 From: Faisal Date: Thu, 3 Oct 2024 12:09:30 +0500 Subject: [PATCH 6/6] chore: upgraded version of xblock after python support update --- recommender/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recommender/__init__.py b/recommender/__init__.py index 2bd9748..486953d 100644 --- a/recommender/__init__.py +++ b/recommender/__init__.py @@ -6,4 +6,4 @@ # which is not loaded when running `manage.py` commands (which is used by `make compile_translations`) # from .recommender import RecommenderXBlock -__version__ = '2.2.2' +__version__ = '3.0.0'