BUG: Fix Python test failure in Debug build on Windows
This commit fixes a Python build problem on Windows when building in Debug
configuration. Running the built-in Python test 'test_os' suggests a problem by
displaying an assertion failure in the C Runtime library (CRT):
[...]
File: f:\dd\vctools\crt\crtw32\Iowio\dup.c
Line: 52
Expression: (_osfile(fh) & FOPEN)
[...]
This issue is that the Python library used multiple versions of the CRT. Because
Python is forced to build in Release configuration, the Python library always
uses the Multi-threaded CRT. Because the binascii and zlib Python modules
statically link to zlib, they pull in the CRT that zlib is built with, which, in
this case, is the Multi-threaded Debug CRT. When the binascii or zlib modules
are built into the Python library, the library uses both versions of the CRT,
which results in failures such as in test_os.
This commit fixes the problem by ensuring that, on Windows, the binascii and
zlib modules are not built into the Python library. Note that those two modules
might still show problems since they are built in Release configuration but pull
in the Debug CRT from zlib.
This problem was originally discovered because it prevented NumPy 1.9.2's setup
from completing in a Debug build:
[...]
File "C:\dev\SN\python-install\Lib\distutils\command\config.py", line 138, in _compile
self.compiler.compile([src], include_dirs=include_dirs)
File "C:\dev\SN\python-install\Lib\distutils\msvc9compiler.py", line 670, in compile
extra_postargs)
File "C:\dev\SN\NUMPY\numpy\distutils\ccompiler.py", line 59, in CCompiler_spawn
s, o = exec_command(cmd)
File "C:\dev\SN\NUMPY\numpy\distutils\exec_command.py", line 223, in exec_command
use_tee=use_tee,**env)
File "C:\dev\SN\NUMPY\numpy\distutils\exec_command.py", line 414, in _exec_command
os.dup2(se_dup, se_fileno)
OSError: [Errno 9] Bad file descriptor
From: Max Smolens <max.smolens@kitware.com>
git-svn-id: http://svn.slicer.org/Slicer4/trunk@24559 3bd1e089-480b-0410-8dfb-8563597acbee |