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 Jan 18, 2023
1 parent 3e9d47e commit d8cc49e
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 @@ -388,7 +388,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 @@ -53,3 +53,17 @@ def test_set_include_dirs(c_file):
# do it again, setting include dirs after any initialization
compiler.set_include_dirs([python])
compiler.compile(_make_strs([c_file]))


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 d8cc49e

Please sign in to comment.