What is the best way to transition from imp to importlib for CloudLinux Passenger WSGI files?

Viewed 33

I am looking for the best way to transition from imp to importlib with my passenger_wsgi.py file using importlib as recommended by pylint.

My passenger file looks like this:

import imp
import os
import sys


sys.path.insert(0, os.path.dirname(__file__))

wsgi = imp.load_source('wsgi', 'core/wsgi.py')
application = wsgi.application

I have seen some examples using importlib.utils.find_spec(path) and some using importlib.machinery.SourceFileLoader('name','script')

Does anyone have an example for their passenger_wsgi.py file that uses the newer method with importlib that would be the new standard they could share?

0 Answers
Related