How to find subsidiary files?

Ulrich Petri ulope at gmx.de
Fri Mar 21 21:29:06 CET 2003


"Michael Saavedra" <pymts at will-o-wisp.org> schrieb im Newsbeitrag
news:pan.2003.03.20.23.19.44.482994.2378 at will-o-wisp.org...
> 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?

Create a config file during the installation which will be located in the
same dir on windows and in an standard path on linux (e.g.
/etc/your_progs_name.conf). If someone wants to have the config file in
another location he has to tell the app via commandline.

Ciao Ulrich






More information about the Python-list mailing list