Skip to content

Commit

Permalink
fix: No module named 'importlib_resources' (#80)
Browse files Browse the repository at this point in the history
1. importlib_resources is a backport of....
2. importlib.resources, a standard library package

Redwood and earlier installed (1).
Starting with the [py3.11 upgrade] we dropped (1) in favor of (2).
To maintain compatibility with both, we use a try-except.

Fixes the error on Tutor Nightly:
ModuleNotFoundError: No module named 'importlib_resources'

[py3.11 upgrade] openedx/edx-platform#34788
  • Loading branch information
kdmccormick authored Jun 27, 2024
1 parent 96fff13 commit 3572f67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/20240625_104737_kyle_patch_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Bugfix] Fix a bug where the scorm block would fail to load with an error message `No module named 'importlib_resources'` (by @kdmccormick)
2 changes: 1 addition & 1 deletion openedxscorm/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "18.0.1"
__version__ = "18.0.2"
11 changes: 9 additions & 2 deletions openedxscorm/scormxblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@
from django.utils import timezone
from django.utils.module_loading import import_string
from webob import Response
import importlib_resources
from six import string_types

from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.completable import CompletableXBlockMixin
from xblock.exceptions import JsonHandlerError
from xblock.fields import Scope, String, Float, Boolean, Dict, DateTime, Integer

try:
# Older Open edX releases (Redwood and earlier) install a backported version of
# importlib.resources: https://pypi.org/project/importlib-resources/
import importlib_resources
except ModuleNotFoundError:
# Starting with Sumac, Open edX drops importlib-resources in favor of the standard library:
# https://docs.python.org/3/library/importlib.resources.html#module-importlib.resources
from importlib import resources as importlib_resources

try:
try:
from common.djangoapps.student.models import CourseEnrollment
Expand Down

0 comments on commit 3572f67

Please sign in to comment.