summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2015-09-03 16:50:57 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2015-09-03 16:50:57 +0200
commite538b2309d00e533dac9312cc11400862776556f (patch)
tree59cfff7b7c7c225b346528f0fcf2c8b302871ed8
parent311287c30fceeeb7d4d381869763b191f7060ef1 (diff)
downloadpsutil-e538b2309d00e533dac9312cc11400862776556f.tar.gz
#677: [Linux] can't install psutil due to bug in setup.py.
-rw-r--r--HISTORY.rst8
-rw-r--r--setup.py24
2 files changed, 26 insertions, 6 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 0f7d075e..27ec9d74 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,13 @@
Bug tracker at https://github.com/giampaolo/psutil/issues
+3.2.1 - XXXX-XX-XX
+==================
+
+**Bug fixes**
+
+- #677: [Linux] can't install psutil due to bug in setup.py.
+
+
3.2.0 - 2015-09-02
==================
diff --git a/setup.py b/setup.py
index 8922f0fc..b575db96 100644
--- a/setup.py
+++ b/setup.py
@@ -45,11 +45,15 @@ def get_description():
@contextlib.contextmanager
-def captured_output(stream_name):
+def silenced_output(stream_name):
+ class DummyFile(io.BytesIO):
+ def write(self, s):
+ pass
+
orig = getattr(sys, stream_name)
- setattr(sys, stream_name, io.StringIO())
try:
- yield getattr(sys, stream_name)
+ setattr(sys, stream_name, DummyFile())
+ yield
finally:
setattr(sys, stream_name, orig)
@@ -133,14 +137,22 @@ elif sys.platform.startswith("linux"):
# see: https://github.com/giampaolo/psutil/issues/659
from distutils.unixccompiler import UnixCCompiler
from distutils.errors import CompileError
+
with tempfile.NamedTemporaryFile(
suffix='.c', delete=False, mode="wt") as f:
f.write("#include <linux/ethtool.h>")
- atexit.register(os.remove, f.name)
+
+ @atexit.register
+ def on_exit():
+ try:
+ os.remove(f.name)
+ except OSError:
+ pass
+
compiler = UnixCCompiler()
try:
- with captured_output('stderr'):
- with captured_output('stdout'):
+ with silenced_output('stderr'):
+ with silenced_output('stdout'):
compiler.compile([f.name])
except CompileError:
return ("PSUTIL_ETHTOOL_MISSING_TYPES", 1)