Mercurial server setup on Windows with apache and hgweb.wsgi

1k views Asked by At

my first post here and looking for advice. For a couple of days now I have been trying to get a Mercurial server up and running at my work. But I am failing miserably with the same errors. For reasons beyond my control it has to be accessed through Apache.

I currently have:

  • Windows Server 2008 R2
  • Apache 2.2
  • Python 2.7
  • Mercurial 2.7.2
  • A locally held repository for testing (in C:\Repositories\repo1)
  • mod_wsgi

My hgweb.config and hgweb.wsgi are in C:\Repositories and, along with httpd.conf, look like this:

hgweb.config

[paths]
/ = C:/Repositories/*

[web]
style = coal
push_ssl = false

hgweb.wsgi

config = "C:\Repositories\hgweb.config"
#import sys; sys.path.insert(0, "C:\Program Files (x86)\Mercurial")
import sys; sys.path.insert(0, "C:\Python27\Lib\site-packages\mercurial")
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
application = hgweb(config)

httpd.conf

<VirtualHost *>
    ServerName hg.example.net
    ServerAdmin [email protected]
    DocumentRoot "C:/Repositories"
    LogLevel debug
    ErrorLog C:/Repositories/error_log
    CustomLog C:/Repositories/access_log common
    LogLevel debug

    WSGIScriptAlias  /hg  "C:/Repositories/hgweb.wsgi"
    #WSGIScriptAlias  /  "C:/Repositories/Hello World.wsgi"

    <Directory C:/Repositories>
        Order allow,deny
        Allow from all      
        AllowOverride All
        AddHandler wsgi-script .wsgi
    </Directory>
</VirtualHost>

The simple Hello World.wsgi works fine, which suggests to me that Apache, Python and mod_wsgi are all playing nicely together. But whenever I use hgweb.wsgi I get an internal server error... contact [email protected]... Which although not working does imply that it is at least reading and using the ServerAdmin in httpd.conf

The error.log states that hgweb.wsgi can't be loaded as a Python module (output below stripped of date, ip, etc.):

mod_wsgi (pid=4764): Target WSGI script 'C:/Repositories/hgweb.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=4764): Exception occurred processing WSGI script 'C:/Repositories/hgweb.wsgi'.
Traceback (most recent call last):
  File "C:/Repositories/hgweb.wsgi", line 19, in <module>
    application = hgweb(config)
  File "C:\\Python27\\lib\\site-packages\\mercurial\\hgweb\\__init__.py", line 26, in hgweb
    return hgwebdir_mod.hgwebdir(config, baseui=baseui)
  File "C:\\Python27\\lib\\site-packages\\mercurial\\hgweb\\hgwebdir_mod.py", line 89, in __init__
    self.refresh()
  File "C:\\Python27\\lib\\site-packages\\mercurial\\hgweb\\hgwebdir_mod.py", line 98, in refresh
    u = ui.ui()
  File "C:\\Python27\\lib\\site-packages\\mercurial\\ui.py", line 45, in __init__
    for f in scmutil.rcpath():
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 86, in __getattribute__
    self._load()
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "C:\\Python27\\lib\\site-packages\\mercurial\\scmutil.py", line 274, in <module>
    class vfs(abstractvfs):
  File "C:\\Python27\\lib\\site-packages\\mercurial\\scmutil.py", line 302, in vfs
    @util.propertycache
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 86, in __getattribute__
    self._load()
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "C:\\Python27\\lib\\site-packages\\mercurial\\util.py", line 27, in <module>
    cachestat = platform.cachestat
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 86, in __getattribute__
    self._load()
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "C:\\Python27\\lib\\site-packages\\mercurial\\windows.py", line 36, in <module>
    posixfile.__doc__ = osutil.posixfile.__doc__
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 86, in __getattribute__
    self._load()
  File "C:\\Python27\\lib\\site-packages\\mercurial\\demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
ImportError: DLL load failed: %1 is not a valid Win32 application.

Any help or ideas would be most welcome.

Thanks in advance.

0

There are 0 answers