Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acid-block | Replace pkg_resources to importlib_resources | Drop support for python 3.8 #187

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ jobs:
push:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.11, 3.12]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}

- name: Install pip
run: pip install -r requirements/pip.txt
Expand Down
2 changes: 1 addition & 1 deletion acid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .acid import AcidBlock, AcidParentBlock, AcidAside

__version__ = '0.3.1'
__version__ = '0.4.1'
15 changes: 11 additions & 4 deletions acid/acid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import random

import pkg_resources
import importlib.resources
import webob
from lazy import lazy
from mako.lookup import TemplateLookup
Expand All @@ -15,6 +15,12 @@
except:
from xblock.fragment import Fragment # For backward compatibility with quince and earlier.

try:
from xblock.utils.resources import ResourceLoader
except:
from xblockutils.resources import ResourceLoader



def generate_fields(cls):
"""
Expand Down Expand Up @@ -74,10 +80,12 @@ class AcidSharedMixin:
}
)

loader = ResourceLoader(__name__)

@lazy
def template_lookup(self):
return TemplateLookup(
directories=[pkg_resources.resource_filename(__name__, 'static')],
directories=[importlib.resources.files('acid') / 'static'],
)

def render_template(self, path, **kwargs):
Expand All @@ -88,8 +96,7 @@ def render_template(self, path, **kwargs):

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 self.loader.load_unicode(path)

def setup_storage(self, scope):
"""
Expand Down
16 changes: 8 additions & 8 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 @@ -10,9 +10,9 @@ fs==2.4.16
# via xblock
lazy==1.6
# via -r requirements/base.in
lxml==5.2.1
lxml==5.3.0
# via xblock
mako==1.3.2
mako==1.3.5
# via
# -r requirements/base.in
# xblock
Expand All @@ -22,21 +22,21 @@ 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
# fs
# python-dateutil
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:
Expand Down
8 changes: 4 additions & 4 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
@@ -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==75.1.0
# via -r requirements/pip.in
21 changes: 5 additions & 16 deletions requirements/pip_tools.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
41 changes: 15 additions & 26 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -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
#
astroid==3.1.0
astroid==3.3.4
# via
# pylint
# pylint-celery
Expand All @@ -15,35 +15,33 @@ click==8.1.7
# edx-lint
click-log==0.4.0
# via edx-lint
code-annotations==1.7.0
code-annotations==1.8.0
# via edx-lint
coverage[toml]==7.4.4
coverage[toml]==7.6.1
# via pytest-cov
dill==0.3.8
# via pylint
edx-lint==5.3.6
edx-lint==5.4.0
# via -r requirements/test.in
exceptiongroup==1.2.0
# via pytest
iniconfig==2.0.0
# via pytest
isort==5.13.2
# via pylint
jinja2==3.1.3
jinja2==3.1.4
# via code-annotations
markupsafe==2.1.5
# via jinja2
mccabe==0.7.0
# via pylint
packaging==24.0
packaging==24.1
# via pytest
pbr==6.0.0
pbr==6.1.0
# via stevedore
platformdirs==4.2.0
platformdirs==4.3.6
# via pylint
pluggy==1.4.0
pluggy==1.5.0
# via pytest
pylint==3.1.0
pylint==3.3.0
# via
# edx-lint
# pylint-celery
Expand All @@ -57,28 +55,19 @@ pylint-plugin-utils==0.8.2
# via
# pylint-celery
# pylint-django
pytest==8.1.1
pytest==8.3.3
# via pytest-cov
pytest-cov==5.0.0
# via -r requirements/test.in
python-slugify==8.0.4
# via code-annotations
pyyaml==6.0.1
pyyaml==6.0.2
# via code-annotations
six==1.16.0
# via edx-lint
stevedore==5.2.0
stevedore==5.3.0
# via code-annotations
text-unidecode==1.3
# via python-slugify
tomli==2.0.1
# via
# coverage
# pylint
# pytest
tomlkit==0.12.4
tomlkit==0.13.2
# via pylint
typing-extensions==4.10.0
# via
# astroid
# pylint
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def is_requirement(line):
'License :: OSI Approved :: GNU Affero General Public License v3',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]
)