diff --git a/changelog.d/3820.misc.rst b/changelog.d/3820.misc.rst new file mode 100644 index 0000000000..26d9d05dae --- /dev/null +++ b/changelog.d/3820.misc.rst @@ -0,0 +1 @@ +Restore quoted ``#include`` argument to ``has_function``. diff --git a/setuptools/_distutils/ccompiler.py b/setuptools/_distutils/ccompiler.py index f4a8a89760..1818fce901 100644 --- a/setuptools/_distutils/ccompiler.py +++ b/setuptools/_distutils/ccompiler.py @@ -860,7 +860,7 @@ def has_function( # noqa: C901 f = os.fdopen(fd, "w") try: for incl in includes: - f.write("""#include %s\n""" % incl) + f.write("""#include "%s"\n""" % incl) if not includes: # Use "char func(void);" as the prototype to follow # what autoconf does. This prototype does not match diff --git a/setuptools/_distutils/tests/test_ccompiler.py b/setuptools/_distutils/tests/test_ccompiler.py index 88497d252b..49691d4b9b 100644 --- a/setuptools/_distutils/tests/test_ccompiler.py +++ b/setuptools/_distutils/tests/test_ccompiler.py @@ -66,15 +66,15 @@ def test_has_function_prototype(): assert compiler.has_function('exit') with pytest.deprecated_call(match='includes is deprecated'): # abort() is a valid expression with the prototype. - assert compiler.has_function('abort', includes=['']) + assert compiler.has_function('abort', includes=['stdlib.h']) with pytest.deprecated_call(match='includes is deprecated'): # But exit() is not valid with the actual prototype in scope. - assert not compiler.has_function('exit', includes=['']) + assert not compiler.has_function('exit', includes=['stdlib.h']) # And setuptools_does_not_exist is not declared or defined at all. assert not compiler.has_function('setuptools_does_not_exist') with pytest.deprecated_call(match='includes is deprecated'): assert not compiler.has_function( - 'setuptools_does_not_exist', includes=[''] + 'setuptools_does_not_exist', includes=['stdio.h'] )