[Pythonmac-SIG] py2app and Django

Bob Ippolito bob at redivi.com
Fri Aug 4 20:08:01 CEST 2006


On Aug 3, 2006, at 8:47 PM, Rob Hudson wrote:

> (My apologies if this starts a new thread -- I'm posting from a
> different mailing address and don't have the original email to  
> reply to)
>
>> Django can not be packaged normally because it has in-package data
>> files. It won't work with either py2exe or py2app without tweaking.
>
> Can you point me to or help me understand what in-package data  
> files are
> and why this affects it?

Python code is organized in packages. When on the filesystem  
normally, packages are a folder with an __init__.py file. In-package  
data files are files that live in one of those folders that isn't  
Python code.

When applications are packaged the normal thing to do is to stuff all  
Python code into a single zip file. Programs that naively do things  
to package directories and files inside of them as if they were on  
the filesystem will not operate like that. There are ways to still  
work even in a zip file, but django clearly does not do that.

>> It may Just Work (or come close to that) with the --packages option.
>> It will definitely not work using any number of --includes options,
>> because that's not the issue.
>
> OK.  I'll start experimenting with the --packages option.

There really isn't much experimenting you need to do, you probably  
just need to specify --packages=django and everything might start  
working (if django is laid out the way I think it is).

You can also add that to your setup.py, as documented, so you don't  
have to remember to specify it as a command line option every time. A  
working setup script for py2app probably looks like this:

from setuptools import setup
setup(
     app=['run.py'],
     setup_requires=['py2app'],
     options=dict(py2app=dict(
         packages=['django'],
     )),
)

-bob



More information about the Pythonmac-SIG mailing list