py2exe 0.5.0 and data_files

Ulrich Goertz u at g0ertz.de
Fri Mar 19 18:46:21 EST 2004


Hello,

I am trying to understand how py2exe 0.5.0 deals with data files. 
My application tries to access certain data files via sys.path[0]
(e.g. the file 'menus.def' which lies in the same path as the
python script (or the .exe which py2exe produces, respectively)
is accessed via os.path.join(sys.path[0],'menus.def').

Now I have the data files which I need in the data_files list given
as an argument to the setup method, and py2exe does copy them to
the dist subdirectory all right. However, sys.path[0] is not the 
path where the program resides, but the path + 'library.zip'.

Is there an elegant way to proceed? Of course, I could remove the
'library.zip' to find the actual path, but that somehow does not 
look like the 'right thing'. I would prefer a solution which works
for the genuine Python script (not packaged by py2exe) as well as 
for the .exe.

Thanks in advance for any comments,

Ulrich



More information about the Python-list mailing list