IIS 7.5上的Mercurial和hgweb - python错误

tho*_*kia 9 python iis mercurial hgweb

我试图让Mercurial在IIS 7.5(Win 7 x64)上托管并继续遇到我似乎无法解决的错误.

我在这里关注了Jeremy Skinners教程:IIS7上的Mercurial

而不是hgwebdir,我使用hgweb,因为我正在使用Mercurial 1.7.2

我安装了python并正在工作.我在目录c:\ inetpub\wwwroot\hg中的http:// localhost/hg - >上为Mercurial设置了一个IIS应用程序

我将templates目录放入c:\ inetpub\wwwroot\hg我将library.zip文件解压缩到c:\ inetpub\wwwroot\hg

当我访问该网站时,我收到一个错误 - >文件"C:\ inetpub\wwwroot\hg\hgweb.cgi",第15行,来自mercurial import demandimport; demandimport.enable()ImportError:没有名为mercurial的模块".

在搜索此错误时,我找到了以下答案:https://stackoverflow.com/questions/2123798/

根据接受的答案,我改变了我的hgweb.cgi,看起来像这样:

#!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)
Run Code Online (Sandbox Code Playgroud)

这样做之后,我仍然得到同样的错误.我不知道还能做什么.任何帮助将不胜感激.

Edi 1:根据请求c:\ inetpub\wwwroot\hg的屏幕截图: 我的Hg目录

Bro*_*ook 15

在过去一周左右的时间里,我一直在努力解决这个问题.

在我看来,他们最近对于如何在IIS中使用mercurial进行了一些重大更改,因此上面关于Jeremy Skinners教程的链接对于1.7.2会有问题

这是一个最近的链接, 我发现我不得不做一些不同的事情.

这些说明适用于1.7.x,如果您使用的是1.8.x,请务必阅读下面的Ethan评论!

我按照/contrib/win32/hgwebdir_wsgi.py的评论中的说明进行操作.

  • 安装Python 2.6.6

  • 将Python添加到系统PATH(以使生活更轻松)

  • 安装pywin32 v214(使用Python安装程序,重要!)(注意,这是针对python 2.6构建的)

  • 安装isapi_wsgi

  • 下载mercurial源包
    Extract,然后运行

    python setup.py --pure build_py -c -d . build_ext -i build_mo --force
    python setup.py --pure install --force
    
  • 将/ contrib/win32中的hgwebdir_wsgi.py复制到要从中托管的文件夹.

  • 在要承载的文件夹中创建文件hgweb.config.添加内容

    [paths]
    yourRepoName = c:\yourRepoLocation
    
  • 编辑hgwebdir_wsgi.py以指向hgweb.config.如果hg是网站的根,则path_prefix为0.如果你把它放在vdir 1深,那么它是1,等等.

  • 运行python hgwebdir_wsgi.py以创建isapi dll _hgwebdir_wsgi.dll.控制台应打印出"安装完成"

  • 在IIS中创建您的应用程序池(没有托管代码)

  • 创建您的网站,将文件夹设置为与hgwebdir_wsgi.py相同的文件夹

  • 添加Module类型的Handler,使用"*"作为映射,选择_hgwebdir_wsgi.dll作为可执行文件,选择isapimodule作为类型,选择Mercurial-ISAPI作为名称(尽管名称并不重要)

  • 编辑模块的功能权限以允许执行.

web.config(前两个步骤):

<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>
Run Code Online (Sandbox Code Playgroud)

毕竟,我能够让它运作起来.

最后一件事,我确实将MFC71.dll复制到了windows/system32,虽然我不确定它是否必要 http://python.net/crew/skippy/win32/

我认为我在这里和上面的链接之间的主要区别在于我做了"纯python"mercurial安装,虽然我是一个完整的python新手,所以我不确定.我也为pywin和isapi_wsgi做了"python安装",而不是普通的windows msis.

  • 仅供参考 - 从1.8开始,http://mercurial.selenic.com/wiki/WindowsInstall中描述的'纯'版本不再适用于我.我必须安装MinGw,将c:\ mingw\bin添加到系统路径,然后用[build] compiler = mingw32创建一个文件C:\ Python26\Lib\distutils\distutils.cfg之后,你可以执行'easy_install ctypes'从1.8开始使用ctypes而不是PyWin32来进行Win32 api调用.然后,您可以按照上面的mercurial链接中概述的"标准"程序,而不是"纯"变体. (5认同)
  • 我花了6个小时试图找到一组有效的指令.为什么我必须最后找到这个?做得好! (2认同)