[Pythonmac-SIG] Py2App and third-party .egg dependencies

Ronald Oussoren ronaldoussoren at mac.com
Wed Aug 29 07:58:49 CEST 2007


On 28 Aug, 2007, at 22:49, Tobias Rodäbel wrote:

> On Tuesday, August 28, 2007, at 13:07 Ronald Oussoren wrote:
>
>> On Tuesday, August 28, 2007, at 09:58AM, "Tobias Rodäbel" <tobias.rodaebel at mac.com 
>> > wrote:
>>> Hi Owen,
>>>
>>> py2app (in particula modulegraph) cannot handle eggs in the right  
>>> way.
>>
>> ... yet.  I have a patch for py2app & friends that deals with  
>> zipped packages on sys.path (that is, zipped eggs), but haven't  
>> managed to merge that yet.
>
> I'm very interested in having a look at this patch. :-)

I want to merge that this week, but I've wanted to do that for several  
weeks now :-(

>
>
>> That is a partial fix for issues like this, I'd like to teach  
>> py2app about eggs, that is add an option to copy entire eggs into  
>> the application bundle (possibly rewriting some bits of those eggs  
>> to avoid creating .python-eggs turds in user home directories for  
>> extensions).
>
> Why do you see the need of rewriting some bits of those eggs? I  
> don't know if I really understand the problem. Maybe setting the  
> environment variable PYTHON_EGG_CACHE helps. Or  
> pkg_resources.set_extraction_path(path) as described here http://peak.telecommunity.com/DevCenter/PkgResources#resource-extraction

A zip-safe egg may contain extensions and those won't work when they  
are inside the zipfile. The setuptools "work-around" for this is to  
have a python module in the zipfile that will extract the extension  
into a ~/.python-eggs when someone tries to import the extension.

That works, but is IMHO not needed for .app bundles. What I intend to  
do is to do the extraction when building the .app bundle and replace  
the python file by one that knows where the exensions are stored in  
the .app bundle.  That keeps the end-users system nice and clean.

pkg_resources.set_extraction_path is usefull as well, py2app should  
probably detect that the application uses pkg_resources if so call  
pkg_sources.set_extract_path(os.path.expanduser("~/Library/Application  
Support/APPNAME/python-eggs")) to ensure that data files get extracted  
into an application-specific directory instead of a global one.

Ronald

>
>
> Cheers,
> Tobias
>



More information about the Pythonmac-SIG mailing list