py2exe 0.5.0 and data_files

Josiah Carlson jcarlson at
Sat Mar 20 10:38:13 CET 2004

> Thanks for your suggestion. I see that I can get around this 
> problem by analyzing sys.path[0] and proceeding case by case.
> However, my understanding is that it should not be necessary
> for the application to "know" that it will be packaged by
> py2exe later. In other words, why does py2exe "change"
> sys.path[0]? Or, if this change is justified (and it may well
> be), maybe my application shpuld not use sys.path[0] but a
> different way to find out the path where it resides?

sys.path[0] has different meanings depending on the context.  These are 
the two cases I've come across.  While there could be more,

> In addition, since this change in the behavior of py2exe forces
> me to change the Python application which I want to package
> itself, I am asking myself whether there are other changes that
> have to be made but which are not as obvious as this one.

It is possible, but doubtful.  I use this same method for PyPE 
(, and aside from people using paths with unicode 
characters in them, I've had few (if any) issues with source vs. 
executable compatibility.  There is one outstanding issue, but the bug 
reports haven't specified what are the conditions of the 'error', only 
that a certain set of related features don't work.

> (All this is not meant as criticism towards py2exe; it is a
> great program. But I would like to improve my understanding
> of its behavior, and of what is the right thing to do in my
> application.)

Special case the finding of the running path, and work from there.

  - Josiah

More information about the Python-list mailing list