[Pythonmac-SIG] py2app and command line options
Tobias Rodäbel
tobias.rodaebel at mac.com
Wed Jan 30 20:27:08 CET 2008
Hi Chris,
On 30.01.2008, at 00:33, Christopher Barker wrote:
> Hey all,
>
> I've got a py2app bundle working nicely, and it works fine when I fire
> ti up from the command line, but when I double click on it, I get a
> sys.argv that looks like:
>
> sys.argv is:
> ['/Users/cbarker/HAZMAT/hazweb/trunk/cameo/StandAlone/dist/
> cameo_standalone.app/Contents/Resources/cameo_standalone.py',
> '-psn_0_21364737']
>
> Where is that "-psn_0_21364737"
>
> coming from, and how to I get rid of it?
The -psn argument is a bit of an historical leftover. It stands for
carbon process serial number. Every time you start an application from
within the finder/desktop by double clicking it, this option will be
attached automatically as the first command line option (sys.argv[1])
after the script name. Set argv_emulation=True (in your setup.py in
OPTIONS) or delete it within your application (__main__):
if len(sys.argv) > 1: del sys.argv[1]
Here is a little sample setup:
setup.py file:
from setuptools import setup
OPTIONS = {'argv_emulation': False}
setup(
app=['foo.py'],
description="A foo.",
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
foo.py file in same directory:
import sys
if "__main__" == __name__:
if len(sys.argv) > 1: del sys.argv[1]
print sys.argv
Greetings,
Tobias
More information about the Pythonmac-SIG
mailing list