[Pythonmac-SIG] made app using py2app, can't pass arguments properly

Ned Deily nad at acm.org
Sun Jan 2 22:49:43 CET 2011


In article <1039C916-1AF4-4189-B2C7-C30149BF0D76 at auricom.com>,
 Ian McLean <ian at auricom.com> wrote:
> I'm new to python/py2app. My original python script accepts arguments as 
> such:
> 
> python merge.py -o outfile.txt - i infile1.txt infile2.txt
> 
> Once I create the .app from py2app using argv emulation this no longer works 
> and I get the following feedback:
> 
> new-host:dist Ian$ merge -o outfile.txt -i infile1.txt infile2.txt
> merge: unknown option: -o
> merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3
> merge: too many arguments

You are undoubtedly running the system-supplied merge command 
(/usr/bin/merge) rather than your app.  In general, OS X apps, including 
those created with py2app, are designed to be "launched", for example 
from the Finder by clicking on their icon, rather than run from a 
command line.  You *can* launch apps from the command line, for 
instance, with the open command (see man 1 open), or by "going under the 
covers" into the app bundle and executing the main executable file 
inside it.  But if your intent is to just produce a command-line 
callable utility, then you probably don't want to be using py2app.  The 
more conventional cross-platform approach using python's Distutils 
should be fine.  Or if it's just a one-file script, add a shebang line 
to the file and make it executable:

$ cat mymerge
#!/usr/bin/env python
#
import ...

$ chmod 755 mymerge
$ ./mymerge -o ...

-- 
 Ned Deily,
 nad at acm.org



More information about the Pythonmac-SIG mailing list