From 07c73b0384146f6d79956e68fe67749c5dba15ed Mon Sep 17 00:00:00 2001 From: ziafazal Date: Fri, 28 Jun 2024 15:01:07 +0500 Subject: [PATCH] fix: importlib_resources used from library --- h5pxblock/h5pxblock.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/h5pxblock/h5pxblock.py b/h5pxblock/h5pxblock.py index cabb9a70..22c868b5 100644 --- a/h5pxblock/h5pxblock.py +++ b/h5pxblock/h5pxblock.py @@ -4,7 +4,6 @@ import logging import os -import importlib_resources from enum import Enum from datetime import datetime @@ -30,6 +29,14 @@ from xblock.utils.resources import ResourceLoader except ModuleNotFoundError: # For backward compatibility with releases older than Quince. from xblockutils.resources import ResourceLoader +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 from h5pxblock.utils import ( get_h5p_storage,