FYI: Django Settings Issue when trying to run pip install with certain apps installed

4 views
Skip to first unread message

swainn

unread,
Mar 16, 2016, 12:56:04 PM3/16/16
to Tethys Platform

All:

This is more of an FYI, than a question. 

PROBLEM: We have encountered a fairly tricky bug that I thought I would share with you, in case anyone else has encoutered it. Essentially, we have an app that imports the app.py module in the app package __init__.py script (tethysapp/<app_name>/__init__.py) which produces an import chain that results in importing something from Django. This is fine and dandy, unless the Django settings have not been initialized, in which case it will throw an exception. One such case is when trying to run any pip commands. Pip imports all of the python packages it knows about with pretty much any operation it performs, including our app package. This initializes that import chain, and since I'm just running a pip command, Django settings have not been initialized, which results in an exception. This has the unfortuate effect of rendering pip unusable (even to uninstall the package causing the problem). 

SOLUTION: We are working on a possible solution for this in Tethys, but for now the way to avoid this is to not import the app.py or any Tethys or Django modules in the __init__.py of your app package (tethysapp/<app_name>/__init__.py) or the tethysapp package (tethysapp/__init__.py).

More details about this issue are on GitHub:

https://github.com/tethysplatform/tethys/issues/179

This is also semi related to bug 176:

Reply all
Reply to author
Forward
0 new messages