Google Groups

Re: DLL load failed?


Mark Rees Jun 9, 2010 4:27 PM
Posted in group: isapi_wsgi-dev
Hi,

Can you confirm that the python c extension osutil.pyd is in the
mercurial directory? There have been instances when users have tried
to get mercurial running under Windows as an apache cgi script where
they get the same message import fail and it appears to be related to
how they installed mercurial. See:

http://stackoverflow.com/questions/644322/how-do-i-get-mercurials-hgwebdir-working-on-windows

Mark

On Jun 10, 6:28 am, Nicholas Riley <njri...@illinois.edu> wrote:
> I'm trying to configure IIS on Windows Server 2008 R2 to serve
> Mercurial repositories out of the site root.  For some reason, the
> instructions I found did not cause Mercurial to be served; instead, it
> just served the sample WSGI handler.  When I updated hgwebdir_wsgi.py
> with some of the sample code, I think it worked, but now I get this
> error:
>
> Internal Extension Error: Failed to import callback module
> 'hgwebdir_wsgi'
> Last Windows error: The specified module could not be
> found.
> Traceback (most recent call
> last):
>   File "C:\Python26\lib\site-packages\mercurial\demandimport.py", line
> 106, in _demandimport
>     return _origimport(name, globals, locals, fromlist, level)
>   File "C:\repositories\hgwebdir_wsgi.py", line 32, in
> <module>
>     application =
> hgwebdir(hgweb_config)
>   File "C:\Python26\lib\site-packages\mercurial\hgweb
> \hgwebdir_mod.py", line 52, in
> __init__
>
> self.refresh()
>   File "C:\Python26\lib\site-packages\mercurial\hgweb
> \hgwebdir_mod.py", line 61,
>  in
> refresh
>     u =
> ui.ui()
>   File "C:\Python26\lib\site-packages\mercurial\ui.py", line 38, in
> __init__
>     for f in
> util.rcpath():
>   File "C:\Python26\lib\site-packages\mercurial\demandimport.py", line
> 77, in
> __getattribute__
>
> self._load()
>   File "C:\Python26\lib\site-packages\mercurial\demandimport.py", line
> 49, in
> _load
>     mod = _origimport(head, globals,
> locals)
>   File "C:\Python26\lib\site-packages\mercurial\util.py", line 562, in
> <module>
>     from windows import
> *
>   File "C:\Python26\lib\site-packages\mercurial\demandimport.py", line
> 87, in
> _demandimport
>     return _origimport(name, globals, locals,
> fromlist)
>   File "C:\Python26\lib\site-packages\mercurial\windows.py", line 21,
> in
> <module>
>     posixfile.__doc__ =
> osutil.posixfile.__doc__
>   File "C:\Python26\lib\site-packages\mercurial\demandimport.py", line
> 77, in
> __getattribute__
>
> self._load()
>   File "C:\Python26\lib\site-packages\mercurial\demandimport.py", line
> 49, in
> _load
>     mod = _origimport(head, globals,
> locals)
> ImportError: DLL load failed: The specified module could not be
> found.
>
> The DLL it's trying to import is osutil.pyd, which is in C:
> \Python26\Lib\site-packages\mercurial\osutil.pyd.
>
> Any ideas why it can't find this directory?
>
> It would also be useful if the need to install the IIS 6 compatibility
> role (not just WMI but Metabase compatibility) for IIS 7 would be
> mentioned in the docs, and perhaps the exception caught and a better
> message displayed - I found it on this mailing list but nowhere else.
>
> In case it helps, here's my complete hgwebdir_wsgi.py, which is
> installed in c:\repositories next to _hgwebdir_wsgi.dll.
>
> # Configuration file location
> hgweb_config = r'c:\repositories\hgweb.config'
>
> # Global settings for IIS path translation
> path_strip = 0   # Strip this many path elements off (when using url
> rewrite)
> path_prefix = 0  # This many path elements are prefixes (depends on
> the
>                  # virtual path of the IIS application).
>
> import sys
>
> # Enable tracing. Run 'python -m win32traceutil' to debug
> if hasattr(sys, 'isapidllhandle'):
>     import win32traceutil
>
> # To serve pages in local charset instead of UTF-8, remove the two
> lines below
> import os
> os.environ['HGENCODING'] = 'UTF-8'
>
> import isapi_wsgi
> from mercurial import demandimport; demandimport.enable()
> from mercurial.hgweb.hgwebdir_mod import hgwebdir
>
> # Example tweak: Replace isapi_wsgi's handler to provide better error
> message
> # Other stuff could also be done here, like logging errors etc.
> class WsgiHandler(isapi_wsgi.IsapiWsgiHandler):
>     error_status = '500 Internal Server Error' # less silly error
> message
>
> isapi_wsgi.IsapiWsgiHandler = WsgiHandler
>
> # Only create the hgwebdir instance once
> application = hgwebdir(hgweb_config)
>
> def handler(environ, start_response):
>
>     # Translate IIS's weird URLs
>     url = environ['SCRIPT_NAME'] + environ['PATH_INFO']
>     paths = url[1:].split('/')[path_strip:]
>     script_name = '/' + '/'.join(paths[:path_prefix])
>     path_info = '/'.join(paths[path_prefix:])
>     if path_info:
>         path_info = '/' + path_info
>     environ['SCRIPT_NAME'] = script_name
>     environ['PATH_INFO'] = path_info
>
>     return application(environ, start_response)
>
> def __ExtensionFactory__():
>     return isapi_wsgi.ISAPISimpleHandler(handler)
>
> if __name__=='__main__':
>     from isapi.install import *
>     params = ISAPIParameters()
>     sm = [ScriptMapParams(Extension='*', Flags=0)]
>     vd = VirtualDirParameters(Name='/', Description='Mercurial',
>                               ScriptMaps=sm,
> ScriptMapUpdate='replace')
>     params.VirtualDirs = [vd]
>     HandleCommandLine(params)
>
> Thanks.