[Pythonmac-SIG] py2app and Django

Rob Hudson rhudson at orcasinc.com
Wed Aug 2 22:43:37 CEST 2006


Hello,

I'm trying to bundle up a Django built website.  Using SQLite and  
Django's built-in WSGI webserver, my thinking was that this would be  
100% Python and would be straight forward to use py2app or py2exe on it.

I'm not familiar enough with py2app to know whether the error I'm  
getting is related to py2app or related to Django.  So I thought I'd  
post what I've done so far here for the list's guidance...

I've followed the guide located here:
http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html

My directory is basically a straight download of Django-0.95 with the  
addition of 2 files.  "run.py" which is my wrapper script to add  
Django to the Python path and kickstart the Django webserver.   
"py2app-setup.py" is named this way because Django already has a  
setup.py.  This may change once I figure out the details but for now  
this is what I've done.

=======
run.py:
=======
#!/usr/bin/env python
import sys, os
sys.path.append(os.getcwd())

from Quotes.manage import *
# We can also pass in host:port info to start server on.
# Possibly add checks to see if port is open already and increment to  
next one
# for the case of >1 app running simultaneously.
execute_manager(settings, ['','runserver'])

# NOTE: execute_manager takes over script control.  If we want to  
fire up a
# browser window we need to do that in another thread.
# Now that server is running, open web browser?
#import webbrowser
#webbrowser.open_new('http://localhost:8000')

================
py2app-setup.py:
================
#!/usr/bin/env python
from setuptools import setup
setup(
         app=["run.py"],
         setup_requires=["py2app"],
)

Also, "Quotes" is my dummy Django project and is a subdirectory under  
the Django-0.95 distribution.

I run this command and include a few Django modules:
python py2app-setup.py py2app -- 
includes=django.contrib.auth,django.contrib.sessions,django.contrib.site 
s

When I run the resulting "run.app" from the command line, this is the  
error I get:
# ./dist/run.app/Contents/MacOS/run
Validating models...
Unhandled exception in thread started by <function inner_run at  
0x279ab0>
Traceback (most recent call last):
   File "django/core/management.pyc", line 1039, in inner_run
   File "django/core/management.pyc", line 1003, in validate
   File "django/core/management.pyc", line 815, in get_validation_errors
   File "django/db/__init__.pyc", line 18, in ?
OSError: [Errno 20] Not a directory: '/Users/rhudson/Desktop/ 
Django-0.95/dist/run.app/Contents/Resources/lib/python2.3/site- 
packages.zip/django/db/backends'


As an aside, you may be asking why do I want to make a website an  
application.  I work for a company that builds health based education  
websites.  Since some projects are funded by grant money, the phase  
one project needs to be reviewed to determine if the project is  
worthy of phase two money.  The reviewers need to remain anonymous  
and we need to assume the reviewers do not have an internet  
connection.  Therefore, we have to take our product (a website) and  
bundle it on a CD.  This has led to many problems.  We currently have  
a working solution for PHP based websites.  Now, we are investigating  
Django as a new platform and I'm doing the initial testing on whether  
we can ship a Django website.

Thanks,
Rob
--
Rob Hudson <rhudson at orcasinc.com>
Senior Programmer
Oregon Center for Applied Science
http://www.orcasinc.com





More information about the Pythonmac-SIG mailing list