[Distutils] setuptools, PYTHONPATH and suExec
Phillip J. Eby
pje at telecommunity.com
Wed Apr 26 22:01:21 CEST 2006
At 03:39 PM 4/26/2006 -0400, Joe Gregorio wrote:
>The problem seems to be PYTHONPATH, or the lack-there-of.
>I have a PYTHONPATH in my shell and that seems to
>be the reason paste works from the shell. In the .CGI script
>I don't have PYTHONPATH and the import of paste fails.
>
>I tried manipulating sys.path at runtime from within the CGI,
>but I believe that is too late
>and by the time my script starts running the wrong (non-
>PYTHONPATH) site.py has already been read.
...
>Is there a way to get this to work or am I out of luck?
Try this:
#!/bin/sh
""":"
PYTHONPATH=whatever exec /path/to/python $0 ${1+"$@"}
"""
The trick here is that Python sees those three lines as a triple-quoted
docstring, but the shell sees the first line as a no-op, and then bails out
after the 'exec', so it doesn't read the rest of the file. The ${} magic
is shell quoting stuff to make sure that all arguments are properly
escaped; I don't pretend to understand how it works. :)
More information about the Distutils-SIG
mailing list