I'm trying to come up with a workaround for this problem.
I'm deploying an application with Chef, and currently there is no PYTHONPATH set. This is fine for Django, which sets its own paths:
$ cat bin/django
#!/usr/bin/python
import sys
sys.path[0:0] = [
'/opt/mytardis/releases/2737f42a91cd1b5d0a4b4c4609550fc586e351ab/eggs/nose-1.1.2-py2.7.egg',
'/opt/mytardis/releases/2737f42a91cd1b5d0a4b4c4609550fc586e351ab/eggs/coverage-3.4-py2.7-linux-x86_64.egg',
'/opt/mytardis/releases/2737f42a91cd1b5d0a4b4c4609550fc586e351ab/eggs/django_nose-1.1-py2.7.egg',
...
However, Celery launches 'python' processes directly, and fails because it can't find modules. In summary:
$ python -c from billiard.forking import main
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named billiard.forking
$ bin/django shell
>>> from billiard.forking import main
>>>
So I need to convert the list of paths set up in the Django script into a PYTHONPATH available to Python. And this conversion needs to be scriptable (because it's Chef).
So far I can only think of using Awk to munge the script into a giant "export PYTHONPATH=..." statement and put that in a .bashrc. There must be a better way?
Python 2.7.3, Django 1.4.1.