Mercurial and hgweb on IIS 7.5 - python error

旧时模样 提交于 2019-11-26 19:32:18

问题


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:


回答1:


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.




回答2:


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




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




回答4:


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



来源:https://stackoverflow.com/questions/4355256/mercurial-and-hgweb-on-iis-7-5-python-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!