Reputation: 2949
I am trying to deploy my existing django project via buildout, following loosely the instructions here.
my buildout.cfg file is:
[buildout]
parts = django python
develop = .
eggs = myproject
[django]
recipe = djangorecipe
version = 1.2.3
project = myproject
projectegg = myproject
settings = settings
wsgi = true
eggs = ${buildout:eggs}
[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}
There are two problems:
[Sun Oct 03 11:57:37 2010] [error] [client ::1] mod_wsgi (pid=5045): Target WSGI script '/usr/src/django/myproject/bin/django.wsgi' cannot be loaded as Python module. [Sun Oct 03 11:57:37 2010] [error] [client ::1] mod_wsgi (pid=5045): SystemExit exception raised by WSGI script '/usr/src/django/myproject/bin/django.wsgi' ignored. [Sun Oct 03 11:57:37 2010] [error] [client ::1] Traceback (most recent call last): [Sun Oct 03 11:57:37 2010] [error] [client ::1] File "/usr/src/django/myproject/bin/django.wsgi", line 20, in [Sun Oct 03 11:57:37 2010] [error] [client ::1] application = djangorecipe.wsgi.main('myproject.settings', logfile='') [Sun Oct 03 11:57:37 2010] [error] [client ::1] File "/usr/src/django/myproject/eggs/djangorecipe-0.20-py2.6.egg/djangorecipe/wsgi.py", line 15, in main [Sun Oct 03 11:57:37 2010] [error] [client ::1] sys.exit(1)
My django.wsgi file is (updated as per suggested changes):
#!/usr/bin/python import sys sys.path[0:0] = [ '/usr/src/django/myproject/src', '/usr/src/django/myproject/eggs/djangorecipe-0.20-py2.6.egg', '/usr/src/django/myproject/eggs/zc.recipe.egg-1.3.2-py2.6.egg', '/usr/src/django/myproject/eggs/zc.buildout-1.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages', '/usr/src/django/myproject/parts/django', '/usr/src/django/myproject/eggs/setuptools-0.6c12dev_r85190-py2.6.egg', '/usr/src/django/myproject/parts/django', '/usr/src/django/myproject', '/usr/src/django/myproject/src(/usr/src/django/myproject)', '/usr/src/django/myproject', ] import djangorecipe.wsgi application = djangorecipe.wsgi.main('myproject.settings', logfile='')
my bin/django file is:
#!/usr/bin/python import sys sys.path[0:0] = [ '/usr/src/django/myproject/src', '/usr/src/django/myproject/eggs/djangorecipe-0.20-py2.6.egg', '/usr/src/django/myproject/eggs/zc.recipe.egg-1.3.2-py2.6.egg', '/usr/src/django/myproject/eggs/zc.buildout-1.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages', '/usr/src/django/myproject/parts/django', '/usr/src/django/myproject/eggs/setuptools-0.6c12dev_r85190-py2.6.egg', '/usr/src/django/myproject/parts/django', '/usr/src/django/myproject', '/usr/src/django/myproject/src(/usr/src/django/myproject)', '/usr/src/django/myproject', ] import djangorecipe.manage if __name__ == '__main__': djangorecipe.manage.main('myproject.settings')
Neither the import or the apache server seem to be working
Upvotes: 2
Views: 2334
Reputation: 38217
What worked for me was just not touching the buildout itself at all, and simply making sure all the eggs were in PYTHONPATH
when the .wsgi
script is executed. The .wsgi
script itself looked like the following:
import os
import sys
PREFIX = '/path/to/my/app' # the buildout is here
BUILDOUT_EGGS = [
'Django-1.3-py2.6.egg',
'South-0.7.6-py2.6.egg',
'django_haystack-1.2.7-py2.6.egg',
'djangopypi-0.4.4-py2.6.egg',
'docutils-0.9.1-py2.6.egg',
'setuptools-0.6c12dev_r88846-py2.6.egg',
'zc.recipe.egg-1.3.2-py2.6.egg',
'Whoosh-2.4.1-py2.6.egg',
'django_registration-0.8_alpha_1-py2.6.egg',
'djangorecipe-1.2.1-py2.6.egg',
# 'pkginfo-0.9-py2.6.egg',
# 'zc.buildout-1.6.0-py2.6.egg',
]
sys.path[0:0] = [PREFIX] + ['%s/eggs/%s' % (PREFIX, egg) for egg in BUILDOUT_EGGS]
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
import djangorecipe.wsgi
application = djangorecipe.wsgi.main('myapp.settings', logfile='myapp.log')
Upvotes: 0
Reputation: 290
your problem is that you are setting wrong your egg dependancies in your recipe
in the buildout part the line
eggs = myproject
you are setting your own myproject django project as a dependancy
in this settings, you need to set all the python eggs (packages) that are dependencies for your django project
for example
eggs =
psycopg2
south
django-debug-toolbar
django-extensions
if your project are using postgresql psycopg2 connector, south for database migrations and django-debug-toolbar and django-extensions
you can except from this list any package that you have in your python system install.
remove your project from the eggs setting, this one confuse your buildout.
Upvotes: 4
Reputation: 13624
The one thing that looks really strange: '/usr/src/django/myproject/src(/usr/src/django/myproject)'
in both your bin/django and bin/django.wsgi file.
I've never seen that () stuff. It looks like it might break things.
Best bet: just run
$> bin/python
>>> import sys
>>> print sys.path
and see what python itself thinks its path is. Buildout sets it up OK, but you've got something I've never seen before in your script.
Another alternative: are you sure your actual code doesn't include import errors that are ending up as import errors of your application (this can sometimes happen if you depend on c-level libraries like PIL or cx_oracle).
Upvotes: 0
Reputation: 1919
Probably you need to set extra path to your project so it would be put on python path. Could you paste your django.wsgi and django files ?
Try this config:
[buildout]
parts = django python
develop = .
eggs = myproject
extra_paths =
src(path_to your_project_source)
${buildout:directory}
[django]
recipe = djangorecipe
version = 1.2.3
project = myproject
projectegg = myproject
settings = settings
wsgi = true
eggs = ${buildout:eggs}
extra-paths = ${buildout:extra_paths}
[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}
extra-paths = ${buildout:extra_paths}
You can also make sure that django.wsgi has executable rights
chmod +x django.wsgi
Upvotes: 1