[Pythonmac-SIG] The where's-my-app problem

Charles Hartman charles.hartman at conncoll.edu
Thu Nov 18 15:17:02 CET 2004

Over on the wxPython-users list, there has been endless discussion of  
this problem (see

  I want to know the directory from which my app was launched, so as to  
locate a couple of data files that need to be editable and therefore  
separate from the bundle, painlessly and without dialog boxes in the  
normal case (the files haven't been moved, the app is started by  
double-clicking or whatever is most obvious to a casual user). It turns  
out to be strangely difficult to do this in a way that works for (a)  
apps launched from the Terminal and (b) apps frozen by py2app on Mac  
and (c) py2exe apps on Windows.

In several of the approaches proposed, the py2app "frozen" app seems to  
be the odd one out. IF I've got this straight, these are the two that  
work on Win2K running from Python and in a py2exe app, and on OS/X  
running from Python, but not from a bundlebuilder (or, I think, py2app)  

Method 1:

programDir, programName = os.path.split(sys.argv[0])
if programDir == '':
     programDir = os.getcwd()

Method 2:

programDir2 = os.path.abspath(sys.path[0])
if os.path.isfile(programDir2):
     programDir2 = os.path.dirname(programDir2)

So I guess the question people have been suggesting be asked is, is  
there any way for py2app to make either of those work? (I can't say I  
understand all this; I started the thread with what I thought was a  
foolishly simple question, and in 35 messages it's shown me all kinds  
of thngs I never saw before.)

Charles Hartman
Professor of English, Poet in Residence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1741 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20041118/d81fc87d/attachment.bin

More information about the Pythonmac-SIG mailing list