views:

117

answers:

2

when i deploy my apps that worked fine using the django test server I usually get errors for every package I installed using pip install -e ....#egg=foo. I usually do this using virtualenv, which placed the files into env/src/foo and places another file into python/site-packages (this is an example of django-css):

django-css.egg-link, which contains the following lines:

/home/pinax-0.7.1/src/django-css
.

how do i tell wsgi that it should follow those links, or am I doing something wrong altogether.

thanks, Philipp Wassibauer

A: 

The modwsgi documentation has notes on how to use virtualenv. It is usually as simple as modifying your django.wsgi (or whatever you call it) file so that it adds the virtualenv environment to modwsgi's path.

This link has some additional, distilled, notes on using pip/virtualenv/modwsgi.

John Paulett
+2  A: 

This is what my WSGI script for Django in a virtualenv looks like:

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

import site
site.addsitedir('/path/to/virtualenv/lib/python2.6/site-packages')

from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

The key bit is site.addsitedir(...), which adds the contents of any *.pth files in the specified directory to sys.path. In this case, it's the easy-install.pth file that Python needs help finding.

jpwatts
thanks...that worked. i knew it was just something small and easy i was missing.
Philipp Wassibauer
+1. The .egg-link files are not related to importing, they are just metadata for setuptools to remember where the code is located. The import-related magic happens in easy-install.pth.
Carl Meyer