diff --git a/setup.py b/setup.py index c7c5929..d6a5866 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,16 @@ disabled_module_list = [] # when running from the build dir, see Modules/getpath.c) _BUILDDIR_COOKIE = "pybuilddir.txt" +def append_dir_to_list(dirlist, dir): + """Append the directory 'dir' to the list 'dirlist' if: + + 1) 'dir' actually exists, and is a directory. + 2) 'dir' is not already in 'dirlist' + """ + if dir is None or not os.path.isdir(dir) or dir in dirlist: + return + dirlist.append(dir) + def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (after any relative directories) if: @@ -423,10 +433,10 @@ class PyBuildExt(build_ext): for d in line.strip().split("=")[1].split(":"): d = os.path.normpath(d) if '/gcc/' not in d: - add_dir_to_list(self.compiler.library_dirs, + append_dir_to_list(self.compiler.library_dirs, d) elif is_gcc and in_incdirs and '/gcc/' not in line: - add_dir_to_list(self.compiler.include_dirs, + append_dir_to_list(self.compiler.include_dirs, line.strip()) finally: os.unlink(tmpfile) -- 1.6.4