I do need to keep the data files out where a user could edit them, not in the bundle. I don't want to fiddle with special locations for the data files; I won't be doing any kind of real installation, just giving out an archive file that unpacks into the two data files and the app. My goal is to let a user unpack it and double-click the app, and (in the normal case, if nothing's been moved) have it find the data files in its same directory and come up clean without dialogs. (And the user can scrap the whole thing without any elaborate uninstall.)
When I run my app from the terminal, while coding and debugging, data files in the same directory as my module files are loaded without any fuss. The problem comes when I build the app (with py2app). Then, when I do this
myname = sys.argv[0].split('/')[-1]
mybasedir = os.sep.join(sys.argv[0].split('/')[:-1])
print "I am %s and am located at %s" % (myname, mybasedir)
what I get is
I am __boot__.py and am located at /Users/cohar/Documents/Python/PyProse/dist/PyProse.app/Contents/Resources
-- which is not helpful for finding data files outside the application's own bundle. I don't see quite why it does this, and I'm not sure I can *count* on it doing this; if I could, I could just do an os.chdir() to go up two levels, and be pretty sure of finding what I need. But won't it be completely different in a Windows environment?
Charles Hartman
Professor of English, Poet in Residence
http://cherry.conncoll.edu/cohar
http://villex.blogspot.com