diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2015-09-03 16:50:57 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2015-09-03 16:50:57 +0200 |
commit | e538b2309d00e533dac9312cc11400862776556f (patch) | |
tree | 59cfff7b7c7c225b346528f0fcf2c8b302871ed8 | |
parent | 311287c30fceeeb7d4d381869763b191f7060ef1 (diff) | |
download | psutil-e538b2309d00e533dac9312cc11400862776556f.tar.gz |
#677: [Linux] can't install psutil due to bug in setup.py.
-rw-r--r-- | HISTORY.rst | 8 | ||||
-rw-r--r-- | setup.py | 24 |
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 ================== @@ -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) |