I have tried to setup apache with hg, trac and web2py running on
Windows XP SP3 but failed. Below is a detailed list of components I
have installed.
hg, trac and web2py work fine standalone (tracd 8000, web2py -
a'<recycle>') but when I try to run them behind Apache with WSGI I see
ImportErrors when importing psycopg2 or mercurial specific modules.
The installation seems to be fine because using PostgreSQL works from
the command line (see below).
I have then setup a 'Hello World' WSGI to prove importing psycopg2 is
the problem. See below for sys.path and Apache log details.
-------------
Windows XP SP3
Python 2.6.5
psycopg 2.2.1
trac 0.12
mercurial 1.5.4
web2py 1.79.1
Apache 2.2.15
mod_wsgi 3.0 (win32 ap22py26)
PostgreSQL 8.4.3-1
-------------
-- console --
D:\Home\web\apache\conf>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2 as pg
>>> db = pg.connect(database='invest', user='invest', password='invest')
>>> db.close()
>>> quit()
Apache runs as special service user and not you. Thus that user needs to have appropriate access permissions to everything that is required. If the DLLs are readable to that user, it will not work.
Another issue that comes up is where packages are installed for a specific user and not for all users. This can result in registry settings only being set for user who installs it and will be missing in machine context and thus Apache user will not see them.
Graham
On 19 June 2010 22:57, baloan <balo...@googlemail.com> wrote:
> I have tried to setup apache with hg, trac and web2py running on > Windows XP SP3 but failed. Below is a detailed list of components I > have installed.
> hg, trac and web2py work fine standalone (tracd 8000, web2py - > a'<recycle>') but when I try to run them behind Apache with WSGI I see > ImportErrors when importing psycopg2 or mercurial specific modules. > The installation seems to be fine because using PostgreSQL works from > the command line (see below).
> I have then setup a 'Hello World' WSGI to prove importing psycopg2 is > the problem. See below for sys.path and Apache log details.
> # Now for the hello world application. > def application(environ, start_response): > status = '200 OK' > output = '\n'.join(sys.path) > response_headers = [('Content-type', 'text/plain'), ('Content- > Length', str(len(output)))] > start_response(status, response_headers) > return [output] > -------------
> -- Apache error log -- > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod_wsgi > (pid=2332): Exception occurred processing WSGI script 'D:/Home/web/ > apache/cgi-bin/hw.wsgi'. > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] Traceback > (most recent call last): > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "D:/ > Home/web/apache/cgi-bin/hw.wsgi", line 7, in application > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] db = > pg.connect(database = 'invest', user='invest', password='invest') > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ > \Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line > 75, in __getattribute__ > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] > self._load() > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ > \Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line > 47, in _load > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod = > _origimport(head, globals, locals) > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ > \Apps\\Python26\\lib\\site-packages\\psycopg2\\__init__.py", line 69, > in <module> > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] from > _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ > \Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line > 106, in _demandimport > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod = > _origimport(name, globals, locals) > [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] > ImportError: DLL load failed: The specified module could not be found. > -------------
> -- > You received this message because you are subscribed to the Google Groups "modwsgi" group. > To post to this group, send email to modwsgi@googlegroups.com. > To unsubscribe from this group, send email to modwsgi+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
One more thing. As I understand it, DLLs can also be searched on user exec executable search Path in Windows. If you are relying on that for user account, the Apache user account will not likely have it set up.
Graham
On 19 June 2010 23:06, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
> Apache runs as special service user and not you. Thus that user needs > to have appropriate access permissions to everything that is required. > If the DLLs are readable to that user, it will not work.
> Another issue that comes up is where packages are installed for a > specific user and not for all users. This can result in registry > settings only being set for user who installs it and will be missing > in machine context and thus Apache user will not see them.
> Graham
> On 19 June 2010 22:57, baloan <balo...@googlemail.com> wrote: >> Hello,
>> I have tried to setup apache with hg, trac and web2py running on >> Windows XP SP3 but failed. Below is a detailed list of components I >> have installed.
>> hg, trac and web2py work fine standalone (tracd 8000, web2py - >> a'<recycle>') but when I try to run them behind Apache with WSGI I see >> ImportErrors when importing psycopg2 or mercurial specific modules. >> The installation seems to be fine because using PostgreSQL works from >> the command line (see below).
>> I have then setup a 'Hello World' WSGI to prove importing psycopg2 is >> the problem. See below for sys.path and Apache log details.
>> # Now for the hello world application. >> def application(environ, start_response): >> status = '200 OK' >> output = '\n'.join(sys.path) >> response_headers = [('Content-type', 'text/plain'), ('Content- >> Length', str(len(output)))] >> start_response(status, response_headers) >> return [output] >> -------------
>> -- Apache error log -- >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod_wsgi >> (pid=2332): Exception occurred processing WSGI script 'D:/Home/web/ >> apache/cgi-bin/hw.wsgi'. >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] Traceback >> (most recent call last): >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "D:/ >> Home/web/apache/cgi-bin/hw.wsgi", line 7, in application >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] db = >> pg.connect(database = 'invest', user='invest', password='invest') >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ >> \Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line >> 75, in __getattribute__ >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] >> self._load() >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ >> \Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line >> 47, in _load >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod = >> _origimport(head, globals, locals) >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ >> \Apps\\Python26\\lib\\site-packages\\psycopg2\\__init__.py", line 69, >> in <module> >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] from >> _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] File "C:\ >> \Apps\\Python26\\lib\\site-packages\\mercurial\\demandimport.py", line >> 106, in _demandimport >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] mod = >> _origimport(name, globals, locals) >> [Sat Jun 19 14:37:06 2010] [error] [client 192.168.178.24] >> ImportError: DLL load failed: The specified module could not be found. >> -------------
>> -- >> You received this message because you are subscribed to the Google Groups "modwsgi" group. >> To post to this group, send email to modwsgi@googlegroups.com. >> To unsubscribe from this group, send email to modwsgi+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
thanks for the swift repsonse. Apache is run as user "web" which I can
confirm in task manager. The python console check which works was run
as user "web". Running Apache from an interactive prompt and trying
hw.wsgi with "import psycopg2" fails like when run as a service.
Both Apache from an interactive prompt and the python interpreter
(interactive console test) use the same
a) user
b) PATH
c) permission
with different results.
> One more thing. As I understand it, DLLs can also be searched on user
> exec executable search Path in Windows. If you are relying on that for
> user account, the Apache user account will not likely have it set up.
> Graham
> On 19 June 2010 23:06, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
> > Apache runs as special service user and not you. Thus that user needs
> > to have appropriate access permissions to everything that is required.
> > If the DLLs are readable to that user, it will not work.
> > Another issue that comes up is where packages are installed for a
> > specific user and not for all users. This can result in registry
> > settings only being set for user who installs it and will be missing
> > in machine context and thus Apache user will not see them.
> > Graham
> > On 19 June 2010 22:57, baloan <balo...@googlemail.com> wrote:
> >> Hello,
> >> I have tried to setup apache with hg, trac and web2py running on
> >> Windows XP SP3 but failed. Below is a detailed list of components I
> >> have installed.
> >> hg, trac and web2py work fine standalone (tracd 8000, web2py -
> >> a'<recycle>') but when I try to run them behind Apache with WSGI I see
> >> ImportErrors when importing psycopg2 or mercurial specific modules.
> >> The installation seems to be fine because using PostgreSQL works from
> >> the command line (see below).
> >> I have then setup a 'Hello World' WSGI to prove importing psycopg2 is
> >> the problem. See below for sys.path and Apache log details.
How to solve ImportError: DLL load failed: The specified module could
not be found.
To analyse the problem first download http://www.dependencywalker.com and check the unresolved DLL dependencies of your modules.
In my _psycopg.pyd (which can be opened with Dependency Walker) I can
see LIBPQ.DLL, LIBEAY32.DLL and MSVCR90.DLL being unresolved. I have
built/compiled psycopg2-2.2.1 on Windows XP SP3 with Visual Studio
2008.
The LIBPQ.DLL and LIBEAY32.DLL were easily resolved by adding ...
\PostgrSQL\8.4\bin and ...\PostgrSQL\8.4\lib to the PATH.
The MS VC runtime library MSVCR90.DLL is more difficult and I have not
solved the problem yet. The simple approach of copying MSVCR90.DLL to
C:\Windows\system32 leads to the following dialog box when requesting
a wsgi page that import additional modules:
R6034
An application has made an attempt to load the C runtime library
incorrectly.
Please contact the application's support team for more information.
--------------------------------------------------------------------------- ----
Python native modules like os, sys seem to work, though. Modules like
hg or psycopg2 which contain compiled DLLs (or pyd) seem to fail.
Looking how python.exe depend on the runtime library I find: c:\windows
\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_x-
ww_d495ac4e\MSVCR90.DLL. This long path seems to be related with
WinSXS (side-by-side) which allows to operate multiple versions of a
DLL in one Windows installation.
Potentially the incompatibility is created during module compilation
when the MSVCR90.DLL is not resolved properly. Importing psycopg2 or
starting hg from the interactive prompt works fine.
> thanks for the swift repsonse. Apache is run as user "web" which I can
> confirm in task manager. The python console check which works was run
> as user "web". Running Apache from an interactive prompt and trying
> hw.wsgi with "import psycopg2" fails like when run as a service.
> Both Apache from an interactive prompt and the python interpreter
> (interactive console test) use the same
> a) user
> b) PATH
> c) permission
> with different results.
> On Jun 19, 3:40 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> wrote:
> > One more thing. As I understand it, DLLs can also be searched on user
> > exec executable search Path in Windows. If you are relying on that for
> > user account, the Apache user account will not likely have it set up.
> > Graham
> > On 19 June 2010 23:06, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
> > > Apache runs as special service user and not you. Thus that user needs
> > > to have appropriate access permissions to everything that is required.
> > > If the DLLs are readable to that user, it will not work.
> > > Another issue that comes up is where packages are installed for a
> > > specific user and not for all users. This can result in registry
> > > settings only being set for user who installs it and will be missing
> > > in machine context and thus Apache user will not see them.
> > > Graham
> > > On 19 June 2010 22:57, baloan <balo...@googlemail.com> wrote:
> > >> Hello,
> > >> I have tried to setup apache with hg, trac and web2py running on
> > >> Windows XP SP3 but failed. Below is a detailed list of components I
> > >> have installed.
> > >> hg, trac and web2py work fine standalone (tracd 8000, web2py -
> > >> a'<recycle>') but when I try to run them behind Apache with WSGI I see
> > >> ImportErrors when importing psycopg2 or mercurial specific modules.
> > >> The installation seems to be fine because using PostgreSQL works from
> > >> the command line (see below).
> > >> I have then setup a 'Hello World' WSGI to prove importing psycopg2 is
> > >> the problem. See below for sys.path and Apache log details.
To whom it may concern: "ImportError: DLL load failed" solved.
I finally got the python modules involved working with Apache and
mod_wsgi.
I took the following steps:
1. uninstall Microsoft Visual C++ 2008
2. install MinGW
3. Reboot
Mercurial
3. recompile Mercurial with MSVCR90 using MinGW (setup.py build -c
mingw32)
4. then setup.py install --skip-build
(compiling and running linked against MSVCRT did not work; for that I
did setup.py build -c mingw32 >build.log and manually created a batch
with changed -lmsvcr* directives)
Psycopg2
5. On another box I had a compiled version linked against MSVCRT.DLL
which worked on my box as well.
6. then setup.py install --skip-build
In all cases I could run the modules standalone from the interactive
python prompt. They only failed when used with Apache mod_wsgi.
The components now are linked against runtime libs as follows:
python 2.6 -> c:\windows\winsxs
\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_x-
ww_d08d0375\MSVCR90.DLL
apache (httpd.exe) -> c:\windows\system32\MSVCRT.DLL
mod_wsgi -> c:\windows\winsxs
\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_x-
ww_d08d0375\MSVCR90.DLL
psycopg2 -> c:\windows\system32\MSVCRT.DLL
mercurial -> MSVCR90.DLL (base85.pyd, no path in the dll)
I suspect there is a problem with the binaries linked against
different runtime libraries.
> How to solve ImportError: DLL load failed: The specified module could
> not be found.
> To analyse the problem first downloadhttp://www.dependencywalker.com > and check the unresolved DLL dependencies of your modules.
> In my _psycopg.pyd (which can be opened with Dependency Walker) I can
> see LIBPQ.DLL, LIBEAY32.DLL and MSVCR90.DLL being unresolved. I have
> built/compiled psycopg2-2.2.1 on Windows XP SP3 with Visual Studio
> 2008.
> The LIBPQ.DLL and LIBEAY32.DLL were easily resolved by adding ...
> \PostgrSQL\8.4\bin and ...\PostgrSQL\8.4\lib to the PATH.
> The MS VC runtime library MSVCR90.DLL is more difficult and I have not
> solved the problem yet. The simple approach of copying MSVCR90.DLL to
> C:\Windows\system32 leads to the following dialog box when requesting
> a wsgi page that import additional modules:
> R6034
> An application has made an attempt to load the C runtime library
> incorrectly.
> Please contact the application's support team for more information.
> --------------------------------------------------------------------------- ----
> Python native modules like os, sys seem to work, though. Modules like
> hg or psycopg2 which contain compiled DLLs (or pyd) seem to fail.
> Looking how python.exe depend on the runtime library I find: c:\windows
> \winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_x-
> ww_d495ac4e\MSVCR90.DLL. This long path seems to be related with
> WinSXS (side-by-side) which allows to operate multiple versions of a
> DLL in one Windows installation.
> Potentially the incompatibility is created during module compilation
> when the MSVCR90.DLL is not resolved properly. Importing psycopg2 or
> starting hg from the interactive prompt works fine.
> On Jun 19, 7:21 pm, baloan <balo...@googlemail.com> wrote:
> > Hi Graham,
> > thanks for the swift repsonse. Apache is run as user "web" which I can
> > confirm in task manager. The python console check which works was run
> > as user "web". Running Apache from an interactive prompt and trying
> > hw.wsgi with "import psycopg2" fails like when run as a service.
> > Both Apache from an interactive prompt and the python interpreter
> > (interactive console test) use the same
> > a) user
> > b) PATH
> > c) permission
> > with different results.
> > On Jun 19, 3:40 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> > wrote:
> > > One more thing. As I understand it, DLLs can also be searched on user
> > > exec executable search Path in Windows. If you are relying on that for
> > > user account, the Apache user account will not likely have it set up.
> > > Graham
> > > On 19 June 2010 23:06, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
> > > > Apache runs as special service user and not you. Thus that user needs
> > > > to have appropriate access permissions to everything that is required.
> > > > If the DLLs are readable to that user, it will not work.
> > > > Another issue that comes up is where packages are installed for a
> > > > specific user and not for all users. This can result in registry
> > > > settings only being set for user who installs it and will be missing
> > > > in machine context and thus Apache user will not see them.
> > > > Graham
> > > > On 19 June 2010 22:57, baloan <balo...@googlemail.com> wrote:
> > > >> Hello,
> > > >> I have tried to setup apache with hg, trac and web2py running on
> > > >> Windows XP SP3 but failed. Below is a detailed list of components I
> > > >> have installed.
> > > >> hg, trac and web2py work fine standalone (tracd 8000, web2py -
> > > >> a'<recycle>') but when I try to run them behind Apache with WSGI I see
> > > >> ImportErrors when importing psycopg2 or mercurial specific modules.
> > > >> The installation seems to be fine because using PostgreSQL works from
> > > >> the command line (see below).
> > > >> I have then setup a 'Hello World' WSGI to prove importing psycopg2 is
> > > >> the problem. See below for sys.path and Apache log details.
> To whom it may concern: "ImportError: DLL load failed" solved.
> I finally got the python modules involved working with Apache and > mod_wsgi.
> I took the following steps: > 1. uninstall Microsoft Visual C++ 2008 > 2. install MinGW > 3. Reboot
> Mercurial > 3. recompile Mercurial with MSVCR90 using MinGW (setup.py build -c > mingw32) > 4. then setup.py install --skip-build > (compiling and running linked against MSVCRT did not work; for that I > did setup.py build -c mingw32 >build.log and manually created a batch > with changed -lmsvcr* directives)
> Psycopg2 > 5. On another box I had a compiled version linked against MSVCRT.DLL > which worked on my box as well. > 6. then setup.py install --skip-build
> In all cases I could run the modules standalone from the interactive > python prompt. They only failed when used with Apache mod_wsgi.
> The components now are linked against runtime libs as follows:
> I suspect there is a problem with the binaries linked against > different runtime libraries.
> Graham, should I log this as a bug with mod_wsgi?
Doesn't strictly sound like anything I can do anything about as relates to environment, in particular how code is compiled or what DLLs are installed on the system and not the code itself. Thus, not strictly a bug, albeit is something to be aware of.
As I am not a Windows person, if anyone, if above doesn't cover it already, can explain with reasonable certainty what the issue may have been, and the solution, in a way that people coming across this thread in the future can understand, would be appreciated. That way this can act as a record of it I can point people at.
> On Jun 21, 11:42 pm, baloan <balo...@googlemail.com> wrote: >> How to solve ImportError: DLL load failed: The specified module could >> not be found.
>> To analyse the problem first downloadhttp://www.dependencywalker.com >> and check the unresolved DLL dependencies of your modules.
>> In my _psycopg.pyd (which can be opened with Dependency Walker) I can >> see LIBPQ.DLL, LIBEAY32.DLL and MSVCR90.DLL being unresolved. I have >> built/compiled psycopg2-2.2.1 on Windows XP SP3 with Visual Studio >> 2008.
>> The LIBPQ.DLL and LIBEAY32.DLL were easily resolved by adding ... >> \PostgrSQL\8.4\bin and ...\PostgrSQL\8.4\lib to the PATH.
>> The MS VC runtime library MSVCR90.DLL is more difficult and I have not >> solved the problem yet. The simple approach of copying MSVCR90.DLL to >> C:\Windows\system32 leads to the following dialog box when requesting >> a wsgi page that import additional modules:
>> R6034 >> An application has made an attempt to load the C runtime library >> incorrectly. >> Please contact the application's support team for more information. >> --------------------------------------------------------------------------- ----
>> Python native modules like os, sys seem to work, though. Modules like >> hg or psycopg2 which contain compiled DLLs (or pyd) seem to fail.
>> Looking how python.exe depend on the runtime library I find: c:\windows >> \winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_x- >> ww_d495ac4e\MSVCR90.DLL. This long path seems to be related with >> WinSXS (side-by-side) which allows to operate multiple versions of a >> DLL in one Windows installation.
>> Potentially the incompatibility is created during module compilation >> when the MSVCR90.DLL is not resolved properly. Importing psycopg2 or >> starting hg from the interactive prompt works fine.
>> On Jun 19, 7:21 pm, baloan <balo...@googlemail.com> wrote:
>> > Hi Graham,
>> > thanks for the swift repsonse. Apache is run as user "web" which I can >> > confirm in task manager. The python console check which works was run >> > as user "web". Running Apache from an interactive prompt and trying >> > hw.wsgi with "import psycopg2" fails like when run as a service.
>> > Both Apache from an interactive prompt and the python interpreter >> > (interactive console test) use the same >> > a) user >> > b) PATH >> > c) permission >> > with different results.
>> > On Jun 19, 3:40 pm, Graham Dumpleton <graham.dumple...@gmail.com> >> > wrote:
>> > > One more thing. As I understand it, DLLs can also be searched on user >> > > exec executable search Path in Windows. If you are relying on that for >> > > user account, the Apache user account will not likely have it set up.
>> > > Graham
>> > > On 19 June 2010 23:06, Graham Dumpleton <graham.dumple...@gmail.com> wrote:
>> > > > Apache runs as special service user and not you. Thus that user needs >> > > > to have appropriate access permissions to everything that is required. >> > > > If the DLLs are readable to that user, it will not work.
>> > > > Another issue that comes up is where packages are installed for a >> > > > specific user and not for all users. This can result in registry >> > > > settings only being set for user who installs it and will be missing >> > > > in machine context and thus Apache user will not see them.
>> > > > Graham
>> > > > On 19 June 2010 22:57, baloan <balo...@googlemail.com> wrote: >> > > >> Hello,
>> > > >> I have tried to setup apache with hg, trac and web2py running on >> > > >> Windows XP SP3 but failed. Below is a detailed list of components I >> > > >> have installed.
>> > > >> hg, trac and web2py work fine standalone (tracd 8000, web2py - >> > > >> a'<recycle>') but when I try to run them behind Apache with WSGI I see >> > > >> ImportErrors when importing psycopg2 or mercurial specific modules. >> > > >> The installation seems to be fine because using PostgreSQL works from >> > > >> the command line (see below).
>> > > >> I have then setup a 'Hello World' WSGI to prove importing psycopg2 is >> > > >> the problem. See below for sys.path and Apache log details.
ImportError: DLL load failed - How to compile psycopg2 to make it
cooperate with mod_wsgi.
1. install mingw
2. download psycopg2
3. setup.py build -c mingw32
4. replace "-lmsvcr90" with "-lmsvcrt" in build link step (see below)
5. execute link step again manually
6. setup.py install --skip-build
7. works for me ;-)
I don't know how to tweak distutils to programmatically change the
msvc runtime lib. This is my poor man's fix.