9

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: My Hg directory

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
thorkia
  • 1,972
  • 1
  • 20
  • 26
  • Could you post a screenshot or whatnot of the contents of c:\inetpub\wwwroot\hg ? Perhaps the files have ended up in a sub-directory of what they're supposed to. – Lasse V. Karlsen Dec 05 '10 at 11:01
  • @Lasse Posted screen shot as per your request. – thorkia Dec 05 '10 at 13:01
  • I had the same error and researched the solution then created [comprehensive instructions to setup mercurial hgweb on iis7](http://www.firegarden.com/software/hosting-mercurial-repo-iis7-windows-server-2008r2-x64-python-isapi-cgi) – Firegarden Jun 28 '11 at 05:09
  • I know this post is old, but your link is behind a 403 now @Firegarden – akousmata Nov 21 '17 at 15:28

4 Answers4

15

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Brook
  • 5,949
  • 3
  • 31
  • 45
  • 1
    Everything works great until I get to this step: Run python hgwebdir_wsgy.py to create the isapi dll _hgwebdir_wsgy.dll. Console should print out "installation complete" I get the following error: Traceback (most recent call last): File "hgwebdir_wsgi.py", line 61, in import isapi_wsgi ImportError: No module named isapi_wsgi – thorkia Dec 08 '10 at 00:04
  • Followed all your directions, and when I visit http://localhost/hg/ I get the directory doesnt list files error... Is there something else I should be doing? – thorkia Dec 08 '10 at 00:14
  • Looks like I forgot a very important step, installing isapi_wsgi. I added it and added the link above. Very sorry about that. – Brook Dec 09 '10 at 01:12
  • If IIS is complaining about browsing directories then the Isapi module isn't set up right. I added the XML from the web.config to my answer above. – Brook Dec 09 '10 at 01:14
  • What a messy upgrade... on the other hand I managed to get 64-bit Hg as a result. – Colin Bowern Dec 20 '10 at 01:44
  • This didn't quite work for me... Even with the xml of the web.config file you posted. I will be posting an answer when I get home from vacation on the steps I took. I did a combo of this answer and Jeremy Skinners tutorial. – thorkia Dec 25 '10 at 17:58
  • I've been running Mercurial for a number of builds up to 1.7.1 under IIS using the eworldui.net blog post / wsgi isapi referenced. With 1.7.2 and 1.7.3, something broke with the Python source installer referenced in that post. IIS won't serve the content, with error Failed to import callback module 'hgwebdir_wsgi'. The solution is to grab the latest source from http://mercurial.selenic.com/release/ as referenced above, and to run the 2 line python setup.py --pure commands. At this point, everything worked properly. – Ethan J. Brown Jan 07 '11 at 22:40
  • In order to have this execute under 64bit WS2008R2 properly, I had to change the AppPool Setting to allow 32Bit Applications in IIS 7.5 It can be found under ApplicationPools->Edit Application Pool->Advanced Settings Pane. – Johannes Rudolph Jan 31 '11 at 23:53
  • 2
    ive literally spent 6 hours trying to find a set of instructions that works. why did I have to find this one last? good job! – Andrew Bullock Feb 04 '11 at 13:00
  • Took me quite some time to find this awesome guide! Thank you! – foxx1337 Feb 07 '11 at 19:56
  • @Brook, awesome job! Like Andrew, this was absolutlely *killing* me. Thank you! – Kirk Woll Feb 26 '11 at 20:06
  • 5
    FYI -- as of 1.8, the 'pure' version described at http://mercurial.selenic.com/wiki/WindowsInstall no longer works for me. I had to install MinGw, add c:\mingw\bin to the system path, then create a file C:\Python26\Lib\distutils\distutils.cfg with [build]compiler=mingw32 After that, you can perform an 'easy_install ctypes' since 1.8 uses ctypes and not PyWin32 to make Win32 api calls. Then you can follow the 'standard' procedure outlined at the mercurial link above instead of the 'pure' variation. – Ethan J. Brown Mar 02 '11 at 18:00
  • @Ethan J. Brown: Oh my god, thankyou. You ended a 4 hour search for answers! – Aren May 05 '11 at 00:16
  • 1
    I have written out [current instructions here](http://www.firegarden.com/software/hosting-mercurial-repo-iis7-windows-server-2008r2-x64-python-isapi-cgi) – Firegarden Jun 28 '11 at 05:17
  • I tried standard installation method and Brook's method, the only thing I did different from Brook's method is I didn't copy MFC71.dll as it seems not necessary, but I could be wrong. Anyway, if you are install Mercurial 1.9 with Python 2.6, download Mercurial from this link [Mezard.eu](http://mezard.eu/hgbuilds/) is the only way works for me. [Source](http://mercurial.selenic.com/bts/issue2582) – Paul L Jul 20 '11 at 04:20
  • 1
    I got this working with Mercurial 2.0.1 following these instructions and using MinGW 5.1.6 as described in Ethan's comment of Mar 2 above. – shamp00 Dec 20 '11 at 15:53
  • Any ideas how to fix "AttributeError: 'module' object has no attribute '__FilterFactory__' Internal Filter Error: Filter version function failed! RuntimeError: The handler failed to load" – David Hayes Jul 30 '14 at 20:12
3

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

Alf Kåre Lefdal
  • 643
  • 1
  • 6
  • 27
3

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 ;)).

Firegarden
  • 362
  • 2
  • 10
  • Finally a tutorial that works with 64-bit windows server 2008, IIS 7, Python 2.7 and Mercurial 1.7.2+. Thank you! – Jason Down Aug 05 '11 at 14:02
1

I did have a lot of errors before. Uninstalled all python, pywin32, isapi_wsgi an dinstalled it like above. It worked as a breeze. Luc

maazza
  • 7,016
  • 15
  • 63
  • 96
lvandenb
  • 11
  • 1