summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorAnthony Ramine <123095+nox@users.noreply.github.com>2019-09-30 05:05:28 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2019-09-30 11:05:28 +0800
commitff1bc8cdb2e585f717d121ef61dc7f0931a64dd8 (patch)
tree2e91f4958b38868dec67008f21b37c268dec67e4 /setup.py
parent2963b5f264b451a67dd26e19d38ab890a5bafa41 (diff)
downloadpsutil-ff1bc8cdb2e585f717d121ef61dc7f0931a64dd8.tar.gz
Don't pollute tree with temporary configure test files (#1597)
The docs for CCompiler.compile say: > If output_dir is given, object files will be put under it, while retaining their > original path component. That is, foo/bar.c normally compiles to foo/bar.o (for a > Unix implementation); if output_dir is build, then it would compile to build/foo/bar.o. What they forget to say is that path components are also retained if output_dir is not specified, it just means it will do so in the current directory. So if you compile a temporary C file /tmp/foo.c, it will produce a ./tmp/foo.o file relative to the current directory. This commit fixes that issue by passing an explicit output_dir itself located in a temporary directory.
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 693bd89d..9f664293 100755
--- a/setup.py
+++ b/setup.py
@@ -205,11 +205,13 @@ elif LINUX:
suffix='.c', delete=False, mode="wt") as f:
f.write("#include <linux/ethtool.h>")
+ output_dir = tempfile.mkdtemp()
+
try:
compiler = UnixCCompiler()
with silenced_output('stderr'):
with silenced_output('stdout'):
- compiler.compile([f.name])
+ compiler.compile([f.name], output_dir)
except CompileError:
return ("PSUTIL_ETHTOOL_MISSING_TYPES", 1)
else: