summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2015-08-31 18:41:24 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2015-08-31 18:41:24 +0200
commit8d66475bbeaa04aa6c4064ceadf0f4f176f5e03d (patch)
treea1c09bfb888dde3d5177421eca9bd5a9bd9449d3
parent98befb0bc43751219ccd5489eb37ae2aedb7266e (diff)
downloadpsutil-8d66475bbeaa04aa6c4064ceadf0f4f176f5e03d.tar.gz
linux / setup.py: do not print warnings
-rw-r--r--setup.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 1e3f7a54..e91dd58c 100644
--- a/setup.py
+++ b/setup.py
@@ -10,6 +10,8 @@ in Python.
"""
import atexit
+import contextlib
+import io
import os
import sys
import tempfile
@@ -42,6 +44,16 @@ def get_description():
return f.read()
+@contextlib.contextmanager
+def captured_output(stream_name):
+ orig = getattr(sys, stream_name)
+ setattr(sys, stream_name, io.StringIO())
+ try:
+ yield getattr(sys, stream_name)
+ finally:
+ setattr(sys, stream_name, orig)
+
+
VERSION = get_version()
VERSION_MACRO = ('PSUTIL_VERSION', int(VERSION.replace('.', '')))
@@ -132,7 +144,9 @@ elif sys.platform.startswith("linux"):
atexit.register(os.remove, f.name)
compiler = UnixCCompiler()
try:
- compiler.compile([f.name])
+ with captured_output('stderr'):
+ with captured_output('stdout'):
+ compiler.compile([f.name])
except CompileError:
return ("PSUTIL_ETHTOOL_MISSING_TYPES", 1)
else: