diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2021-11-09 17:42:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 17:42:35 -0500 |
commit | f1b0a2bff47e4a26ca64b0c28d91b651709fa116 (patch) | |
tree | 0606e914d1768b2c888f0723c4507379421323a8 | |
parent | 9e98a85a2180d4301e7091c6173f919ddd3e6787 (diff) | |
parent | e59011a5f3eeac75b99a65c0144511c05bce30d9 (diff) | |
download | python-setuptools-git-f1b0a2bff47e4a26ca64b0c28d91b651709fa116.tar.gz |
Merge pull request #65 from mkoeppe/ccompiler__has_function__output_dir
CCompiler.has_function: Do not fail if self.outputdir is set
-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) |