Problem with py2exe-frozen CGIHttpServer-based script
vincent wehren
vincent at visualtrans.de
Thu Nov 27 12:46:48 EST 2003
"Thomas Heller" <theller at python.net> schrieb im Newsbeitrag
news:isl66xxj.fsf at python.net...
| "vincent wehren" <vincent at visualtrans.de> writes:
|
| > Hi,
| >
| > as a small capabilities demo I coded the piece below to show how to use
| > Python for cgi'ing on localhost and it more or less does the trick :-).
| > However, I when I freeze it with py2exe, starting the resulting exe
fires up
| > the server allright,
| > but fails execute cgi commands correctly (i.e. the expected output -
let's
| > say from cgi.test()) - is no longer emitted to the browser...).
| >
| > Is there some py2exe-magic I need to do that I don't know of? Something
in
| > the code that prevents the frozen version to work?
|
| That's an easy one!
| Look into CGIHTTPServer.py, near line 232:
| if self.is_python(scriptfile):
| => interp = sys.executable
| if interp.lower().endswith("w.exe"):
| # On Windows, use python.exe, not pythonw.exe
| interp = interp[:-5] + interp[-4:]
| cmdline = "%s -u %s" % (interp, cmdline)
|
| It tries to start 'sys.executable' with the python cgi script. Normally
| sys.executable is the Python interpreter, but for a py2exe'd script this
| is the running executable (which is no longer a usual Python
| interpreter).
|
| Changing this line to 'interp = r"c:\python23\python.exe"' makes the
| frozen script work (although then the Python installation is required
| again).
|
| (A few minutes later, looking at CGIHTTPServer.py again)
| It seems you have to hack this module so that the code block starting at
| line 270 is used, which says:
| else:
| # Other O.S. -- execute script in this process
| and then it works fine.
|
| Thomas
Hi Thomas,
I suspected something along those lines....
I'll give the hack a go!
Thanks!
Vincent
More information about the Python-list
mailing list