Skip to content

Commit

Permalink
Fixed accumulating include dirs after compile
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbean-bremen committed Feb 6, 2023
1 parent c2bc813 commit 6324549
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion distutils/ccompiler.py
Expand Up @@ -389,7 +389,7 @@ def _fix_compile_args(self, output_dir, macros, include_dirs):
raise TypeError("'macros' (if supplied) must be a list of tuples")

if include_dirs is None:
include_dirs = self.include_dirs
include_dirs = list(self.include_dirs)
elif isinstance(include_dirs, (list, tuple)):
include_dirs = list(include_dirs) + (self.include_dirs or [])
else:
Expand Down
14 changes: 14 additions & 0 deletions distutils/tests/test_ccompiler.py
Expand Up @@ -76,3 +76,17 @@ def test_has_function_prototype():
assert not compiler.has_function(
'setuptools_does_not_exist', includes=['<stdio.h>']
)


def test_include_dirs_after_multiple_compile_calls(c_file):
"""
Calling compile multiple times should not change the include dirs
(regression test for setuptools issue #3591).
"""
compiler = ccompiler.new_compiler()
python = sysconfig.get_paths()['include']
compiler.set_include_dirs([python])
compiler.compile(_make_strs([c_file]))
assert compiler.include_dirs == [python]
compiler.compile(_make_strs([c_file]))
assert compiler.include_dirs == [python]

0 comments on commit 6324549

Please sign in to comment.