py2exe windows apps path question
vincent wehren
vincent at visualtrans.de
Tue Aug 2 16:07:19 EDT 2005
"Gregory Piñero" <gregpinero at gmail.com> schrieb im Newsbeitrag
news:mailman.2635.1123008925.10512.python-list at python.org...
> If you need something that works both on a frozen app as well as an
> (unfrozen) python
> script, you'd be better off using something like:
>
>> def getAppPrefix():
>> """Return the location the app is running from
>> """
>> isFrozen = False
>> try:
>> isFrozen = sys.frozen
>> except AttributeError:
>> pass
>> if isFrozen:
>> appPrefix = os.path.split(sys.executable)[0]
>> else:
>> appPrefix = os.path.split(os.path.abspath(sys.argv[0]))[0]
>> return appPrefix
>>
>
>Vincent,
>
>This sounds interesting. A few questions for you:
>Why don't I see sys.frozen in interpreter?
>Does it only appear when it is frozen?
Yes. The sys.frozen attribute is added by py2exe.
>What do you mean by frozen, how does python know?
Python doesn't know - it is just told so ;)
>What does sys.executable do?
sys.executable gives you the path of the executing binary. Normally, this
will be something like
"c:\\python24\\python.exe" - since the interpreter is the executing binary.
Once you have frozen your python application, it will return the path to
your app.
--
Vincent
>
>Thanks,
>
>Greg
More information about the Python-list
mailing list