Skip to content

Commit f1b0a2b

Browse files
authored
Merge pull request #65 from mkoeppe/ccompiler__has_function__output_dir
CCompiler.has_function: Do not fail if self.outputdir is set
2 parents 9e98a85 + e59011a commit f1b0a2b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

distutils/ccompiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ def has_function(self, funcname, includes=None, include_dirs=None,
802802
except (LinkError, TypeError):
803803
return False
804804
else:
805-
os.remove("a.out")
805+
os.remove(os.path.join(self.output_dir or '', "a.out"))
806806
finally:
807807
for fn in objects:
808808
os.remove(fn)

distutils/tests/test_unixccompiler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def gcvs(*args, _orig=sysconfig.get_config_vars):
232232
sysconfig.customize_compiler(self.cc)
233233
self.assertEqual(self.cc.linker_so[0], 'my_ld')
234234

235+
def test_has_function(self):
236+
# Issue https://github.com/pypa/distutils/issues/64:
237+
# ensure that setting output_dir does not raise
238+
# FileNotFoundError: [Errno 2] No such file or directory: 'a.out'
239+
self.cc.output_dir = 'scratch'
240+
self.cc.has_function('abort', includes=['stdlib.h'])
241+
235242

236243
def test_suite():
237244
return unittest.makeSuite(UnixCCompilerTestCase)

0 commit comments

Comments
 (0)