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

ConceptXBlock | Drop py3.8 support | replace pkg_resource with importlib.resources #161

Merged
merged 5 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
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions concept/concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@

import json

import pkg_resources
import importlib.resources
from xblock.core import XBlock
from xblock.fields import Integer, Scope, String
from xblock.fields import Scope, String
from xblock.fragment import Fragment

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

import requests


loader = ResourceLoader(__name__)


class ConceptXBlock(XBlock):
"""
This XBlock allows concept tagging in a course.
Expand Down Expand Up @@ -43,8 +51,7 @@ def relay_handler(self, request, suffix):

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

def student_view(self, context=None):
"""
Expand Down Expand Up @@ -79,8 +86,8 @@ def student_view(self, context=None):

def studio_view(self, context=None):
frag = Fragment(self.resource_string("static/html/studio_hack.html"))
frag.add_javascript(pkg_resources.resource_string(__name__, "static/js/oa_server.js"))
frag.add_javascript(pkg_resources.resource_string(__name__, "static/js/oa_edit.js"))
frag.add_javascript(importlib.resources.files(__package__).joinpath("static/js/oa_server.js"))
frag.add_javascript(importlib.resources.files(__package__).joinpath("static/js/oa_edit.js"))
return frag

# TO-DO: change this to create the scenarios you'd like to see in the
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 @@ -8,9 +8,9 @@ appdirs==1.4.4
# via fs
fs==2.4.16
# via xblock
lxml==5.1.0
lxml==5.3.0
# via xblock
mako==1.3.2
mako==1.3.5
# via xblock
markupsafe==2.1.5
# via
Expand All @@ -20,19 +20,19 @@ python-dateutil==2.9.0.post0
# via xblock
pytz==2024.1
# 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.1.0
web-fragments==2.2.0
# via xblock
webob==1.8.7
webob==1.8.8
# via xblock
xblock==2.0.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.42.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.1.1
setuptools==74.1.2
# via -r requirements/pip.in
21 changes: 6 additions & 15 deletions requirements/pip_tools.txt
Original file line number Diff line number Diff line change
@@ -1,32 +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.1.1
build==1.2.2
# via pip-tools
click==8.1.7
# via pip-tools
importlib-metadata==7.0.1
packaging==24.1
# via build
packaging==23.2
# via build
pip-tools==7.4.0
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.42.0
wheel==0.44.0
# via pip-tools
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def is_requirement(line):

setup(
name='concept-xblock',
version='0.3.2',
version='0.4.0',
description='concept XBlock', # TODO: write a better description.
long_description=open('README.md', encoding='utf-8').read(), # pylint: disable=consider-using-with
long_description_content_type='text/markdown',
Expand Down