diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e59fed97..05b93f90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,8 @@ jobs: matrix: os: [ubuntu-20.04] python-version: - - '3.8' - '3.11' + - '3.12' toxenv: [django42, quality, csslint, eslint, translations_validate] steps: diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index a8e10c33..8c5be905 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@v3 with: - python-version: 3.8 + python-version: 3.12 - name: Install pip run: pip install -r requirements/pip.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 6613249f..e4fe07fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Version 5.0.0 +* Added python 3.12 support. Dropped python 3.8 support. + ## Version 4.1.0 * Added python 3.11 support. Dropped django32 support. diff --git a/freetextresponse/__init__.py b/freetextresponse/__init__.py index 653038d8..03994428 100644 --- a/freetextresponse/__init__.py +++ b/freetextresponse/__init__.py @@ -4,4 +4,4 @@ present in order for the student to receive credit. """ -__version__ = "4.1.0" +__version__ = "5.0.0" diff --git a/freetextresponse/mixins/fragment.py b/freetextresponse/mixins/fragment.py index 584ff847..06671a2f 100644 --- a/freetextresponse/mixins/fragment.py +++ b/freetextresponse/mixins/fragment.py @@ -4,11 +4,18 @@ Note: We should resume test coverage for all lines in this file once split into its own library. """ -import pkg_resources - from xblock.core import XBlock from web_fragments.fragment import Fragment +try: + from xblock.utils.resources import ResourceLoader +except ModuleNotFoundError: + # For backward compatibility with releases older than Quince. + from xblockutils.resources import ResourceLoader + + +loader = ResourceLoader(__name__) + class XBlockFragmentBuilderMixin(object): """ @@ -81,8 +88,7 @@ def build_fragment( fragment.add_css_url(url) else: item = '../public/' + item - data = pkg_resources.resource_string(__name__, item) - data = data.decode('utf8') + data = loader.load_unicode(item) fragment.add_css(data) for item in js: item = 'public/' + item diff --git a/freetextresponse/mixins/scenario.py b/freetextresponse/mixins/scenario.py index 1382cf29..59c28ef0 100644 --- a/freetextresponse/mixins/scenario.py +++ b/freetextresponse/mixins/scenario.py @@ -1,56 +1,13 @@ """ Mixin workbench behavior into XBlocks """ -from glob import glob -import pkg_resources +try: + from xblock.utils.resources import ResourceLoader +except ModuleNotFoundError: + from xblockutils.resources import ResourceLoader -def _read_file(file_path): - """ - Read in a file's contents - """ - with open(file_path) as file_input: - file_contents = file_input.read() - return file_contents - - -def _parse_title(file_path): - """ - Parse a title from a file name - """ - title = file_path - title = title.split('/')[-1] - title = '.'.join(title.split('.')[:-1]) - title = ' '.join(title.split('-')) - title = ' '.join([ - word.capitalize() - for word in title.split(' ') - ]) - return title - - -def _read_files(files): - """ - Read the contents of a list of files - """ - file_contents = [ - ( - _parse_title(file_path), - _read_file(file_path), - ) - for file_path in files - ] - return file_contents - - -def _find_files(directory): - """ - Find XML files in the directory - """ - pattern = f"{directory}/*.xml" - - files = glob(pattern) - return files +loader = ResourceLoader(__name__) class XBlockWorkbenchMixin(object): @@ -63,9 +20,4 @@ def workbench_scenarios(cls): """ Gather scenarios to be displayed in the workbench """ - module = cls.__module__ - module = module.split('.', maxsplit=1)[0] - directory = pkg_resources.resource_filename(module, 'scenarios') - files = _find_files(directory) - scenarios = _read_files(files) - return scenarios + return loader.load_scenarios_from_path("../scenarios") diff --git a/requirements/base.txt b/requirements/base.txt index fe392454..8e63fc09 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 @@ -8,11 +8,7 @@ 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 -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # -r requirements/base.in @@ -22,7 +18,7 @@ lxml==4.9.4 # via # -c requirements/constraints.txt # xblock -mako==1.3.2 +mako==1.3.5 # via xblock markupsafe==2.1.5 # via @@ -30,26 +26,24 @@ markupsafe==2.1.5 # xblock python-dateutil==2.9.0.post0 # via xblock -pytz==2024.1 +pytz==2024.2 # via xblock -pyyaml==6.0.1 +pyyaml==6.0.2 # via xblock -simplejson==3.19.2 +simplejson==3.19.3 # via xblock six==1.16.0 # via # -r requirements/base.in # fs # python-dateutil -sqlparse==0.4.4 +sqlparse==0.5.1 # via django -typing-extensions==4.10.0 - # via asgiref web-fragments==2.2.0 # via xblock -webob==1.8.7 +webob==1.8.8 # via xblock -xblock==3.1.0 +xblock==5.1.0 # 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 53fbcda7..41238bdc 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,14 +1,14 @@ # -# 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 # -cachetools==5.3.3 +cachetools==5.5.0 # via # -r requirements/tox.txt # tox -certifi==2024.2.2 +certifi==2024.8.30 # via requests chardet==5.2.0 # via @@ -20,9 +20,9 @@ colorama==0.4.6 # via # -r requirements/tox.txt # tox -coverage==6.5.0 +coverage[toml]==7.6.1 # via coveralls -coveralls==3.3.1 +coveralls==4.0.1 # via -r requirements/ci.in distlib==0.3.8 # via @@ -30,43 +30,38 @@ distlib==0.3.8 # virtualenv docopt==0.6.2 # via coveralls -filelock==3.13.3 +filelock==3.16.0 # via # -r requirements/tox.txt # tox # virtualenv -idna==3.6 +idna==3.8 # via requests -packaging==24.0 +packaging==24.1 # via # -r requirements/tox.txt # pyproject-api # tox -platformdirs==4.2.0 +platformdirs==4.3.2 # via # -r requirements/tox.txt # tox # virtualenv -pluggy==1.4.0 +pluggy==1.5.0 # via # -r requirements/tox.txt # tox -pyproject-api==1.6.1 +pyproject-api==1.7.1 # via # -r requirements/tox.txt # tox -requests==2.31.0 +requests==2.32.3 # via coveralls -tomli==2.0.1 - # via - # -r requirements/tox.txt - # pyproject-api - # tox -tox==4.14.2 +tox==4.18.1 # via -r requirements/tox.txt -urllib3==2.2.1 +urllib3==2.2.2 # via requests -virtualenv==20.25.1 +virtualenv==20.26.4 # via # -r requirements/tox.txt # tox diff --git a/requirements/pip.txt b/requirements/pip.txt index cf449024..f313a9c2 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -1,14 +1,14 @@ # -# 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 # -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 4e1105e9..77d81ad2 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -1,34 +1,23 @@ # -# 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 # -build==1.2.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/quality.txt b/requirements/quality.txt index 4918f026..1bf5cd07 100644 --- a/requirements/quality.txt +++ b/requirements/quality.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 @@ -18,28 +18,22 @@ asgiref==3.8.1 # -r requirements/base.txt # -r requirements/test.txt # django -astroid==3.1.0 +astroid==3.2.4 # via pylint -backports-zoneinfo==0.2.1 ; python_version < "3.9" - # via - # -c requirements/constraints.txt - # -r requirements/base.txt - # -r requirements/test.txt - # django binaryornot==0.4.4 # via # -r requirements/test.txt # cookiecutter -boto3==1.34.77 +boto3==1.35.16 # via # -r requirements/test.txt # fs-s3fs -botocore==1.34.77 +botocore==1.35.16 # via # -r requirements/test.txt # boto3 # s3transfer -certifi==2024.2.2 +certifi==2024.8.30 # via # -r requirements/test.txt # requests @@ -59,13 +53,13 @@ cookiecutter==2.6.0 # via # -r requirements/test.txt # xblock-sdk -coverage==7.4.4 +coverage==7.6.1 # via -r requirements/test.txt ddt==1.7.2 # via -r requirements/test.txt dill==0.3.8 # via pylint -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # -r requirements/base.txt @@ -74,7 +68,11 @@ django==4.2.11 # xblock-sdk django-pyfs==3.2.0 # via -r requirements/test.txt -edx-opaque-keys==2.5.1 +dnspython==2.6.1 + # via + # -r requirements/test.txt + # pymongo +edx-opaque-keys==2.11.0 # via -r requirements/test.txt fs==2.4.16 # via @@ -88,13 +86,13 @@ fs-s3fs==1.1.1 # -r requirements/test.txt # django-pyfs # xblock-sdk -idna==3.6 +idna==3.8 # via # -r requirements/test.txt # requests isort==5.13.2 # via pylint -jinja2==3.1.3 +jinja2==3.1.4 # via # -r requirements/test.txt # cookiecutter @@ -112,7 +110,7 @@ lxml==4.9.4 # -r requirements/test.txt # xblock # xblock-sdk -mako==1.3.2 +mako==1.3.5 # via # -r requirements/base.txt # -r requirements/test.txt @@ -136,21 +134,21 @@ mdurl==0.1.2 # markdown-it-py mock==5.1.0 # via -r requirements/test.txt -pbr==6.0.0 +pbr==6.1.0 # via # -r requirements/test.txt # stevedore -platformdirs==4.2.0 +platformdirs==4.3.2 # via pylint -pycodestyle==2.11.1 +pycodestyle==2.12.1 # via -r requirements/quality.in -pygments==2.17.2 +pygments==2.18.0 # via # -r requirements/test.txt # rich -pylint==3.1.0 +pylint==3.2.7 # via -r requirements/quality.in -pymongo==3.13.0 +pymongo==4.8.0 # via # -r requirements/test.txt # edx-opaque-keys @@ -169,31 +167,31 @@ python-slugify==8.0.4 # via # -r requirements/test.txt # cookiecutter -pytz==2024.1 +pytz==2024.2 # via # -r requirements/base.txt # -r requirements/test.txt # xblock -pyyaml==6.0.1 +pyyaml==6.0.2 # via # -r requirements/base.txt # -r requirements/test.txt # cookiecutter # xblock -requests==2.31.0 +requests==2.32.3 # via # -r requirements/test.txt # cookiecutter # xblock-sdk -rich==13.7.1 +rich==13.8.1 # via # -r requirements/test.txt # cookiecutter -s3transfer==0.10.1 +s3transfer==0.10.2 # via # -r requirements/test.txt # boto3 -simplejson==3.19.2 +simplejson==3.19.3 # via # -r requirements/base.txt # -r requirements/test.txt @@ -206,12 +204,12 @@ six==1.16.0 # fs # fs-s3fs # python-dateutil -sqlparse==0.4.4 +sqlparse==0.5.1 # via # -r requirements/base.txt # -r requirements/test.txt # django -stevedore==5.2.0 +stevedore==5.3.0 # via # -r requirements/test.txt # edx-opaque-keys @@ -219,24 +217,17 @@ text-unidecode==1.3 # via # -r requirements/test.txt # python-slugify -tomli==2.0.1 - # via pylint -tomlkit==0.12.4 +tomlkit==0.13.2 # via pylint -types-python-dateutil==2.9.0.20240316 +types-python-dateutil==2.9.0.20240906 # via # -r requirements/test.txt # arrow -typing-extensions==4.10.0 +typing-extensions==4.12.2 # via - # -r requirements/base.txt # -r requirements/test.txt - # asgiref - # astroid # edx-opaque-keys - # pylint - # rich -urllib3==1.26.18 +urllib3==2.2.2 # via # -r requirements/test.txt # botocore @@ -247,18 +238,18 @@ web-fragments==2.2.0 # -r requirements/test.txt # xblock # xblock-sdk -webob==1.8.7 +webob==1.8.8 # via # -r requirements/base.txt # -r requirements/test.txt # xblock # xblock-sdk -xblock==3.1.0 +xblock==5.1.0 # via # -r requirements/base.txt # -r requirements/test.txt # xblock-sdk -xblock-sdk==0.10.0 +xblock-sdk==0.12.0 # via -r requirements/test.txt # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.txt b/requirements/test.txt index 65ebe452..a6c9728c 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 @@ -10,19 +10,15 @@ arrow==1.3.0 # via cookiecutter asgiref==3.8.1 # via django -backports-zoneinfo==0.2.1 ; python_version < "3.9" - # via - # -c requirements/constraints.txt - # django binaryornot==0.4.4 # via cookiecutter -boto3==1.34.77 +boto3==1.35.16 # via fs-s3fs -botocore==1.34.77 +botocore==1.35.16 # via # boto3 # s3transfer -certifi==2024.2.2 +certifi==2024.8.30 # via requests chardet==5.2.0 # via binaryornot @@ -32,7 +28,7 @@ click==8.1.7 # via cookiecutter cookiecutter==2.6.0 # via xblock-sdk -coverage==7.4.4 +coverage==7.6.1 # via -r requirements/test.in ddt==1.7.2 # via -r requirements/test.in @@ -42,7 +38,9 @@ ddt==1.7.2 # xblock-sdk django-pyfs==3.2.0 # via -r requirements/test.in -edx-opaque-keys==2.5.1 +dnspython==2.6.1 + # via pymongo +edx-opaque-keys==2.11.0 # via -r requirements/test.in fs==2.4.16 # via @@ -53,9 +51,9 @@ fs-s3fs==1.1.1 # via # django-pyfs # xblock-sdk -idna==3.6 +idna==3.8 # via requests -jinja2==3.1.3 +jinja2==3.1.4 # via cookiecutter jmespath==1.0.1 # via @@ -68,7 +66,7 @@ lxml==4.9.4 # -c requirements/constraints.txt # xblock # xblock-sdk -mako==1.3.2 +mako==1.3.5 # via xblock markdown-it-py==3.0.0 # via rich @@ -81,11 +79,11 @@ mdurl==0.1.2 # via markdown-it-py mock==5.1.0 # via -r requirements/test.in -pbr==6.0.0 +pbr==6.1.0 # via stevedore -pygments==2.17.2 +pygments==2.18.0 # via rich -pymongo==3.13.0 +pymongo==4.8.0 # via edx-opaque-keys pypng==0.20220715.0 # via xblock-sdk @@ -96,21 +94,21 @@ python-dateutil==2.9.0.post0 # xblock python-slugify==8.0.4 # via cookiecutter -pytz==2024.1 +pytz==2024.2 # via xblock -pyyaml==6.0.1 +pyyaml==6.0.2 # via # cookiecutter # xblock -requests==2.31.0 +requests==2.32.3 # via # cookiecutter # xblock-sdk -rich==13.7.1 +rich==13.8.1 # via cookiecutter -s3transfer==0.10.1 +s3transfer==0.10.2 # via boto3 -simplejson==3.19.2 +simplejson==3.19.3 # via # xblock # xblock-sdk @@ -119,20 +117,17 @@ six==1.16.0 # fs # fs-s3fs # python-dateutil -sqlparse==0.4.4 +sqlparse==0.5.1 # via django -stevedore==5.2.0 +stevedore==5.3.0 # via edx-opaque-keys text-unidecode==1.3 # via python-slugify -types-python-dateutil==2.9.0.20240316 +types-python-dateutil==2.9.0.20240906 # via arrow -typing-extensions==4.10.0 - # via - # asgiref - # edx-opaque-keys - # rich -urllib3==1.26.18 +typing-extensions==4.12.2 + # via edx-opaque-keys +urllib3==2.2.2 # via # botocore # requests @@ -140,13 +135,13 @@ web-fragments==2.2.0 # via # xblock # xblock-sdk -webob==1.8.7 +webob==1.8.8 # via # xblock # xblock-sdk -xblock==3.1.0 +xblock==5.1.0 # via xblock-sdk -xblock-sdk==0.10.0 +xblock-sdk==0.12.0 # via -r requirements/test.in # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/tox.txt b/requirements/tox.txt index cc5293d6..c6769e27 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -1,10 +1,10 @@ # -# 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 # -cachetools==5.3.3 +cachetools==5.5.0 # via tox chardet==5.2.0 # via tox @@ -12,27 +12,23 @@ colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -filelock==3.13.3 +filelock==3.16.0 # via # tox # virtualenv -packaging==24.0 +packaging==24.1 # via # pyproject-api # tox -platformdirs==4.2.0 +platformdirs==4.3.2 # via # tox # virtualenv -pluggy==1.4.0 +pluggy==1.5.0 # via tox -pyproject-api==1.6.1 +pyproject-api==1.7.1 # via tox -tomli==2.0.1 - # via - # pyproject-api - # tox -tox==4.14.2 +tox==4.18.1 # via -r requirements/tox.in -virtualenv==20.25.1 +virtualenv==20.26.4 # via tox diff --git a/setup.py b/setup.py index cc0fc0fb..92dfb441 100644 --- a/setup.py +++ b/setup.py @@ -146,8 +146,8 @@ def is_requirement(line): 'Operating System :: OS Independent', 'Programming Language :: JavaScript', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Framework :: Django', 'Framework :: Django :: 4.2', 'Topic :: Education',