[Distutils] py2app and eggs part deux

Phillip J. Eby pje at telecommunity.com
Wed Jul 13 06:59:27 CEST 2005

At 06:42 PM 7/12/2005 -1000, Bob Ippolito wrote:
>On Jul 12, 2005, at 6:28 PM, Phillip J. Eby wrote:
>>At 05:29 PM 7/12/2005 -1000, Bob Ippolito wrote:
>>>Well, just do the second suggestion then.  "Install" the eggs
>>>somewhere, unzipped, and make sure it's on sys.path during setup.py.
>>>Maybe you could crank the ez_setup wheels (or whatever module is
>>>appropriate, I haven't looked at eggs yet) at the top of your
>>>setup.py and automate this.
>>Well, if it just has to be on sys.path during setup.py, then it
>>should be working now, shouldn't it?  I mean, if he installed them
>>to Python's site-packages.  In the alternative, he could create a
>>wrapper command that calls require("project==version") to find all
>>the eggs and put them on sys.path.
>Like modulefinder, modulegraph doesn't know anything about fancy PEP
>302 stuff yet.

I meant, if he installed with --always-unzip to the system site-packages 
directory, such that EasyInstall put the needed paths in easy-install.pth.

>>So, I guess my suggestion to Kevin is to try installing to a
>>directory on sys.path, using the new --always-unzip option to force
>>the packages to be unzipped, and then try hacking py2app to do a
>>require() before looking for dependencies (consulting the
>>setuptools "test" command for an example).
>I'm not sure you'd really want to hack py2app anyway, just the
>setup.py before setup() is called.

Er, no, because then he'd have to change the setup script between building 
the package and making an app out of it.  It needs to be something that 
runs as a command, *not* something  in the setup script.

>>I suspect this means that the packages will get merged into one
>>another with no distinction at runtime, but whatever works, works.
>Yeah, I'm not sure why you would possibly care about this at runtime
>for an application that's "frozen", anyway.

If the application is composed of plugins, you'd want the plugins' metadata 
to be available, so there'd be additional work involved to get that put 
back together.

>Modulegraph should already know about all of the tricks in the stdlib
>(at least in 2.3, not sure if I updated it for 2.4) including the
>modules that are imported by the core behind your back (warnings,
>etc.)..  It doesn't contain anything py2app specific, it might as
>well be used as-is.
>(modulegraph depends on altgraph, the other stuff you can ignore)

Interesting.  For py2exe this stuff makes some sense to me, but for py2app 
I wonder if you really even care about finding stdlib dependencies anyway, 
if your target Mac OS version has the stdlib already installed.  It seems 
that in that case you could just use something like:

    setup.py easy_install --always-unzip --always-copy --install-dir=appdir .

to dump all the unzipped eggs and scripts needed by the current project 
into 'appdir', and then do whatever Mac OS magic is needed to turn the 
directory into an application.  Oh, and you'd also need to throw in a copy 
of pkg_resources, I suppose, since it's not part of Python...  yet.  :)

This approach isn't really an option for py2exe, since there's no version 
of Windows that bundles Python, but for the many Unix-y operating systems 
(including Mac OS) that provide Python as a standard feature, it's not a 
bad choice.

More information about the Distutils-SIG mailing list