summaryrefslogtreecommitdiff
path: root/numpy/distutils/misc_util.py
diff options
context:
space:
mode:
authorAntony Lee <anntzer.lee@gmail.com>2018-10-18 12:15:27 +0200
committerAntony Lee <anntzer.lee@gmail.com>2018-10-18 12:15:27 +0200
commit8589e8d035bdd9a8f67ab2f30ea5cb63d9acf0ba (patch)
tree44eaf31d4bbed8d0457767078b5b1926cf8ab806 /numpy/distutils/misc_util.py
parentebcbd4f4d8c761ac758e7ae9da4bc0d202f80fff (diff)
downloadnumpy-8589e8d035bdd9a8f67ab2f30ea5cb63d9acf0ba.tar.gz
Delay import of distutils.msvccompiler to avoid warning on non-Windows.
*Importing* distutils.msvccompiler works on non-Windows systems, but triggers a pointless "warning" (using distutils' own logging system; "Can't read registry etc.") Delay the import so that other uses of distutils.misc_util are not affected. When running distutils commands, the verbosity is set by default to 1 (`self.verbose = 1` in distutils/dist.py) so the warning does get displayed. To trigger the warning, subclass e.g. build_ext, override its finalize_options method, import numpy.distutils.misc_util from there, and then pass the new build_ext as cmdclass to setuptools.setup(). Partially reverts 15f52f5.
Diffstat (limited to 'numpy/distutils/misc_util.py')
-rw-r--r--numpy/distutils/misc_util.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index 8305aeae5..af9a8df29 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -13,7 +13,6 @@ import multiprocessing
import distutils
from distutils.errors import DistutilsError
-from distutils.msvccompiler import get_build_architecture
try:
from threading import local as tlocal
except ImportError:
@@ -2336,3 +2335,9 @@ def msvc_version(compiler):
raise ValueError("Compiler instance is not msvc (%s)"\
% compiler.compiler_type)
return compiler._MSVCCompiler__version
+
+def get_build_architecture():
+ # Importing distutils.msvccompiler triggers a warning on non-Windows
+ # systems, so delay the import to here.
+ from distutils.msvccompiler import get_build_architecture
+ return get_build_architecture()