[Pythonmac-SIG] Distribute command-line tools with py2app or similar?

Christopher Barker Chris.Barker at noaa.gov
Mon Jun 30 20:42:16 CEST 2008


Zachary Pincus wrote:
> Py2app seems optimized for creating OS X GUI 
> "app" bundles, not command-line programs.

That's correct, command-line programs really aren't what the Mac is 
about! (even though I use them all the time...)

> Ideally, I'd want this to work regardless of what the user has on their 
> computer -- so I don't just want to make an mpkg that blindly installs a 
> python and other module dependencies (e.g. numpy), because I wouldn't 
> want to clobber previous installs. And I don't want to burden the users 
> with some lengthy set of instructions about what to download depending 
> on what version of what else they have... (e.g. what if they have and 
> depend on numpy 1.0.6 and I require 1.1?)

> I'd just love a self-contained directory that contains the python 
> "runtime" and all dependencies in a that I could distribute in a 
> portable fashion.

I haven't tried this, but can you build python from source, specifying 
an alternate install directory? This could give you a custom build that 
you could make a mpkg out of.

you might try:

./configure --enable-framework=/Library/Frameworks/MyPython 
--enable-universalsdk

Then make sure that your scripts have your python in their #!lines. You 
could probably just built it as a regular old *nix build, too, rather 
than a Framework, if all you want to do is run command line tools. note 
that you'll probably need to build all the third party packages you need 
too.

I've just tried this, and it seems to work, but I haven't tried moving 
it to another machine or anything. It does try to overwrite the stuff in 
Applications/MacPython 2.5

You can't just copy the standard installed version, as the paths to all 
dependent libs are built in. There are tools to change that, which is 
what py2app does, but that brings us to:

> Can I 
> somehow grab the parts I need from a py2app bundle and just distribute 
> that?

Probably. You can run the executable that py2app builds be calling it 
directly from the command line, so if you put a symlink in to that 
somewhere, it might act just like a command line app.

If you have a number of command line tools that rely on the same 
packages, you could probably just copy the executable from one app 
bundle to another.

I haven't tried any of this, though.

-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list