Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6bbab81

Browse files
committed
BUG (#970): fix a python 2.6 bug in distutils which caused an unhelpful Error:None message when trying to build with no VS installed and without the -c mingw32 option.
1 parent 6cadd13 commit 6bbab81

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

numpy/distutils/command/config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
import os, signal
77
import warnings
8+
import sys
89

910
from distutils.command.config import config as old_config
1011
from distutils.command.config import LANG_EXT
1112
from distutils import log
1213
from distutils.file_util import copy_file
14+
import distutils
1315
from numpy.distutils.exec_command import exec_command
1416
from numpy.distutils.mingw32ccompiler import generate_manifest
1517

@@ -49,6 +51,25 @@ def _check_compiler (self):
4951
self.fcompiler.customize_cmd(self)
5052
self.fcompiler.show_customization()
5153

54+
if sys.platform == 'win32' and self.compiler.compiler_type == 'msvc':
55+
# XXX: hack to circumvent a python 2.6 bug with msvc9compiler:
56+
# initialize call query_vcvarsall, which throws an IOError, and
57+
# causes an error along the way without much information. We try to
58+
# catch it here, hoping it is early enough, and print an helpful
59+
# message instead of Error: None.
60+
if not self.compiler.initialized:
61+
try:
62+
self.compiler.initialize()
63+
except IOError, e:
64+
msg = """\
65+
Could not initialize %s instance: do you have Visual Studio installed ? If you
66+
are trying to build with mingw, please use python setup.py build -c mingw32
67+
instead (original caught exception was %s). If you have Visual Studio
68+
installed, check it is correctly installed, and the right version (VS 2008 for
69+
python 2.6, VS 2003 for 2.5, etc...)""" % \
70+
(self.compiler.__class__.__name__, e)
71+
raise distutils.errors.DistutilsPlatformError(msg)
72+
5273
def _wrap_method(self,mth,lang,args):
5374
from distutils.ccompiler import CompileError
5475
from distutils.errors import DistutilsExecError

0 commit comments

Comments
 (0)