openedx / XBlock

Framework for building custom learning components that run in the Open edX LMS!
https://edx.readthedocs.io/projects/xblock-tutorial/en/latest/overview/introduction.html
Apache License 2.0
450 stars 216 forks source link

Switch off of deprecated `pkg_resources` library #676

Open kdmccormick opened 1 year ago

kdmccormick commented 1 year ago

Background

The pkg_resources library, used by XBlock to load static assets, is deprecated. The removal timeline is unknown.

xblock-utils uses pkg_resources in a couple places.

To do

First, choose a new resource loading interface. Options:

Then:

Related

farhan commented 5 months ago

After reading the related docs/blogs shared below I think we should choose importlib_resources library which is developed and maintained by Python developers and fixes the architecture issues related to importlib.resources module which is going to be deprecated in Python 3.11 as discussed here

Docs/Blogs https://discuss.python.org/t/deprecating-importlib-resources-legacy-api/11386 https://importlib-resources.readthedocs.io/en/latest/using.html https://docs.python.org/3/library/importlib.resources.html https://www.geeksforgeeks.org/importlib-package-in-python/ https://dev.to/bowmanjd/easily-load-non-python-data-files-from-a-python-package-2e8g

FYI @kdmccormick @feanil

kdmccormick commented 5 months ago

@farhan , thanks for the research. I took a look at the Python forum post and came to the conclusion that:

So, it sounds like we could wait until edx-platform is upgraded to Python 3.11, and then just switch directly to the new, official importlib.resources package. Does that sound good?

feanil commented 5 months ago

As an additional note, it looks like pkg_resources is still around in 3.12 so it will be safe to jump to that as well so I think we can de-prioritize this until after the python upgrade which we'll hopefully kick-off soon.

farhan commented 3 weeks ago

PR is blocked as we are waiting for drop of Python v3.8 support from edx-platform