Problems running hgweb.wsgi under apache on Windows

Didly didlybom at gmail.com
Wed Jul 20 07:41:54 UTC 2011


Hi,

I am trying to setup an apache-based mercurial server on a WindowsXP
machine. As you may guess from this email I am having trouble setting
this up :-/

When I try to access the server I get the following error:

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.


These are the contents of the Apache error.log:

[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203] mod_wsgi
(pid=3304): Target WSGI script 'C:/wsgi_app/wsgi_handler.wsgi' cannot
be loaded as Python module.
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203] mod_wsgi
(pid=3304): Exception occurred processing WSGI script
'C:/wsgi_app/wsgi_handler.wsgi'.
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203] Traceback
(most recent call last):
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:/wsgi_app/wsgi_handler.wsgi", line 24, in <module>
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]
application = hgweb(config)
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\hgweb\\__init__.py",
line 26, in hgweb
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     return
hgwebdir_mod.hgwebdir(config, baseui=baseui)
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\hgweb\\hgwebdir_mod.py",
line 62, in __init__
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     self.refresh()
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\hgweb\\hgwebdir_mod.py",
line 71, in refresh
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     u = ui.ui()
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\ui.py", line 43, in
__init__
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     for f
in scmutil.rcpath():
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
75, in __getattribute__
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     self._load()
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
47, in _load
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     mod =
_origimport(head, globals, locals)
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\scmutil.py", line 164,
in <module>
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     class
opener(abstractopener):
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\scmutil.py", line 180,
in opener
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]
@util.propertycache
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
75, in __getattribute__
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     self._load()
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
47, in _load
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     mod =
_origimport(head, globals, locals)
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\util.py", line 503, in
<module>
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     from
windows import *
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
85, in _demandimport
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     return
_origimport(name, globals, locals, fromlist)
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\windows.py", line 21, in
<module>
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]
posixfile.__doc__ = osutil.posixfile.__doc__
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
75, in __getattribute__
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     self._load()
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]   File
"C:\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line
47, in _load
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]     mod =
_origimport(head, globals, locals)
[Wed Jul 20 09:34:31 2011] [error] [client 192.168.15.203]
ImportError: DLL load failed: No se puede encontrar el m\xf3dulo
especificado.

This last line means: "Cannot find the specified module"

So it seems that the server was able to try calling hgweb, but for
some reason it failed.


To setup the server I followed the steps described in:

http://mercurial.selenic.com/wiki/HgWebDirStepByStep#Configuring_Apache_with_mod_wsgi
http://mercurial.selenic.com/wiki/modwsgi

On the server machine I have python 2.6 installed, as well as
TortoiseHg 2.1.1. I have also installed the
mercurial-1.9.win32-py2.6.exe package as well as
mercurial-1.9-x86.msi. I think that I probably only needed the source
package, but I was not sure so I installed the binary package as well.

I have installed the latest Apache version, as well as mod_wsgi, which
I have enabled. I am able to run wsgi scripts. Although that seems
clear from the error.log file, I verified it by adding the following
configuration to the apache httpd.conf file:

WSGIScriptAlias /wsgi "C:/wsgi_app/wsgi_handler.wsgi"

<Directory "C:/wsgi_app">
	AllowOverride None
	Options None
	Order deny,allow
	Allow from all
	
	AddHandler wsgi-script .wsgi
</Directory>

I then created a folder c:\wsgi_app, in which I placed the following
wsgi_handler.wsgi python script:

def my_app(environ, start_response):
	from mercurial import demandimport; demandimport.enable()

	from mercurial.hgweb import hgweb
	from os import path

	status = '200 OK'
	config = "c:/wsgi_app/hgweb.config"
	f = open(config)
	output = str(hgweb) + '\n'
	output += '\n'.join(f.readlines())
	f.close()


	response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
	start_response(status, response_headers)

	return [output]

	
application = my_app

I also placed an hgweb.config file in c:\wsgi_app.

When I access the server with a web browser I get:

<function hgweb at 0x009CA370>

[web]
style = coal

[paths]
/ = c:/wsgi_app/repos/**


Thus I am sure that the server is running, that it can execute wsgi
scripts, that the WSGI script is able to import hgweb from the
mercurial.hgweb package and that the WSGI script can access the
hgweb.config file.

To make sure that the hgweb.config file is valid, I ran hg serve on
port 8000, using that hgweb.config file. When doing so I was able to
access the repos in c:\wsgi_app\repos. Thus I am sure that the config
file is valid.

So, to sum up, I think that Apache is properly configured to run WSGI
scripts and that WSGI scripts can import hgweb and access my
hgweb.config file, which I believe is valid. Yet I get an error when I
try to access hgweb.

Do you have any advice to help me fix this issue?

Thank you in advance,

Angel



More information about the Mercurial mailing list