How to find subsidiary files?

Michael Saavedra pymts at will-o-wisp.org
Fri Mar 21 02:19:44 EST 2003


I am working on a gui app, and I'm having trouble figuring out how to find and
load subsidiary files such as toolbar images and the like. The app is written to
run on both windows and linux. It will be distributed as source code and in
binary form using py2exe. I will not have any control over where in the
directory tree the app will be installed.

Here's the problem: on linux, executables are usually put in /usr/bin,
/usr/local/bin, or somewhere in the /opt directory, with the other files in
another dir such as /usr/share. On windows, the app and the other files are
usually all stored in their own directory under C:\Program Files, though
sometimes people use other locations, such as on the D:\ drive. How can I get
the app to find the files at run-time in a cross-platform way?

Are the distutils sufficient for doing this sort of thing? I've been looking at
the documentation, and they seem to be more oriented toward distributing modules
rather than apps. For the source code, I suppose I could modify it on
installation to have a variable point to the proper directory, but this wouldn't
work for the .exe distribution. Also, I considered using sys.argv[0] on linux to
attempt to divine the base installation dir, but using symlinks to the
executable would break this. Anyone have any other ideas?

Thanks in advance,
Mike




More information about the Python-list mailing list