Message 60324 - Python tracker (original) (raw)

Under Tru64 (version 5.1a, and probably others), when a Python script is structured like so:

#!/something/bin/python
import sys
print sys.prefix

the calculation of prefix in getpath.c won't work correctly. The reason is that argv[0] will be 'python' rather than '/something/bin/python' (as it would be under, say, Linux).

The code happens to work correctly in some simple scenarios, but fails in a pretty mysterious way if one has a different python in one's PATH than the one in the #! line. So, for example, if my PATH=/usr/bin and there is a /usr/bin/python, then if I run the script above, sys.prefix will be set to '/usr' instead of '/something' and the wrong module path will be set up, etc.

It would be much better to simply obey the compiled PREFIX instead, at least in the case where argv[0] has no slashes.