I am trying to get Mercurial to host on IIS 7.5 (Win 7 x64) and keep running into an error I cant seem to fix.
I have followed Jeremy Skinners tutorial here: Mercurial on IIS7
Instead of hgwebdir, I use hgweb as I am using Mercurial 1.7.2
I have python installed and working. I set up a IIS application for Mercurial at http://localhost/hg -> in directory c:\inetpub\wwwroot\hg
I placed the templates directory into c:\inetpub\wwwroot\hg I extracted the library.zip file into c:\inetpub\wwwroot\hg
When I visited the site, I get an error -> File "C:\inetpub\wwwroot\hg\hgweb.cgi", line 15, in from mercurial import demandimport; demandimport.enable() ImportError: No module named mercurial ".
When searching for this error, I found the following answers: https://stackoverflow.com/questions/2123798/
Following the accepted answer, I changed my hgweb.cgi to look like this:
#!c:/python/python26/python.exe
#
# An example hgweb CGI script, edit as necessary
# See also https://www.mercurial-scm.org/wiki/PublishingRepositories
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/path/to/repo/or/config"
# Uncomment and adjust if Mercurial is not installed system-wide:
import sys; sys.path.insert(0, "c:\inetpub\wwwroot\hg")
# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb('c:\inetpub\wwwroot\hg\hgweb.config')
wsgicgi.launch(application)
After doing that, I still get the same error. I have no idea what else to do. Any help would be greatly appreciated.
Edi 1: Screen shot of c:\inetpub\wwwroot\hg as per request:
I've been struggling with this same setup for the past week or so.
It looks to me like they have made some significant changes to how mercurial works in IIS recently, so the link above to Jeremy Skinners tutorial will be problematic for 1.7.2
This is a more recent link I found I had to do a couple things differently.
These instructions are for 1.7.x, if you're using 1.8.x, be sure to read Ethan's comment below!
I followed the instructions in the comments of /contrib/win32/hgwebdir_wsgi.py.
Install Python 2.6.6
Add Python to system PATH (to make life easier)
Install pywin32 v214 (using the Python installer, Important!) (Note that this is built against python 2.6)
Install isapi_wsgi
download the mercurial source package
Extract, Then Run
python setup.py --pure build_py -c -d . build_ext -i build_mo --force python setup.py --pure install --force
Copy hgwebdir_wsgi.py from /contrib/win32 to the folder you want to host it from.
Create a file hgweb.config in the folder you're going to host from. Add the contents
[paths] yourRepoName = c:\yourRepoLocation
Edit hgwebdir_wsgi.py to point the hgweb.config. path_prefix is 0 if hg is the root of the website. if you're putting it in a vdir 1 deep, then it's 1, etc.
Run python hgwebdir_wsgi.py to create the isapi dll _hgwebdir_wsgi.dll. Console should print out "installation complete"
Create your app pool in IIS (no managed code)
Create your website, with the folder set to the same folder as hgwebdir_wsgi.py
Add Handler of type Module, use "*" as the mapping, select _hgwebdir_wsgi.dll as the executable, select isapimodule as the type, Mercurial-ISAPI as the name (although name doesn't really matter)
Edit feature permissions of the module to allow execute.
web.config (for the previous 2 steps):
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<add name="Mercurial-Isapi" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\inetpub\hgweb\_hgwebdir_wsgi.dll" resourceType="Unspecified" />
</handlers>
</system.webServer>
After all this, I was able to get it working.
One last thing, I did copy MFC71.dll to windows/system32, although I'm not sure it was necessary http://python.net/crew/skippy/win32/
I think the main difference between what I've got here and what's on the above link is that I did the "pure python" mercurial install, Although I'm a complete python newbie so I'm not sure. Also I did the "python installs" for pywin and isapi_wsgi rather than the plain windows msis.
Adam Boddington has written an updated installation description that works now: http://stackingcode.com/blog/2011/02/24/running-a-mercurial-server-on-iis-7-5-windows-server-2008-r2
I wrote out up to date instructions on how to setup a mercurial repository on IIS7 using the current versions of Mercurial (1.8.x) as well the current version of Python (2.7).
This will work for you and I appreciate if you use it to vote the answer up (or down ;)).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With