diff options
| -rw-r--r-- | distutils/ccompiler.py | 2 | ||||
| -rw-r--r-- | distutils/tests/test_unixccompiler.py | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/distutils/ccompiler.py b/distutils/ccompiler.py index b38cf261..c9eb709b 100644 --- a/distutils/ccompiler.py +++ b/distutils/ccompiler.py @@ -802,7 +802,7 @@ int main (int argc, char **argv) { except (LinkError, TypeError): return False else: - os.remove("a.out") + os.remove(os.path.join(self.output_dir or '', "a.out")) finally: for fn in objects: os.remove(fn) diff --git a/distutils/tests/test_unixccompiler.py b/distutils/tests/test_unixccompiler.py index ee2fe99c..63c7dd37 100644 --- a/distutils/tests/test_unixccompiler.py +++ b/distutils/tests/test_unixccompiler.py @@ -232,6 +232,13 @@ class UnixCCompilerTestCase(unittest.TestCase): sysconfig.customize_compiler(self.cc) self.assertEqual(self.cc.linker_so[0], 'my_ld') + def test_has_function(self): + # Issue https://github.com/pypa/distutils/issues/64: + # ensure that setting output_dir does not raise + # FileNotFoundError: [Errno 2] No such file or directory: 'a.out' + self.cc.output_dir = 'scratch' + self.cc.has_function('abort', includes=['stdlib.h']) + def test_suite(): return unittest.makeSuite(UnixCCompilerTestCase) |
