|
14 | 14 | # This global variable is used to hold the list of modules to be disabled. |
15 | 15 | disabled_module_list = [] |
16 | 16 |
|
| 17 | +def add_dir_to_list(dirlist, dir): |
| 18 | + """Add the directory 'dir' to the list 'dirlist' (at the front) if |
| 19 | + 1) 'dir' is not already in 'dirlist' |
| 20 | + 2) 'dir' actually exists, and is a directory.""" |
| 21 | + if os.path.isdir(dir) and dir not in dirlist: |
| 22 | + dirlist.insert(0, dir) |
| 23 | + |
17 | 24 | def find_file(filename, std_dirs, paths): |
18 | 25 | """Searches for the directory where a given file is located, |
19 | 26 | and returns a possibly-empty list of additional directories, or None |
@@ -193,10 +200,13 @@ def get_platform (self): |
193 | 200 |
|
194 | 201 | def detect_modules(self): |
195 | 202 | # Ensure that /usr/local is always used |
196 | | - if '/usr/local/lib' not in self.compiler.library_dirs: |
197 | | - self.compiler.library_dirs.insert(0, '/usr/local/lib') |
198 | | - if '/usr/local/include' not in self.compiler.include_dirs: |
199 | | - self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
| 203 | + add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
| 204 | + add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
| 205 | + |
| 206 | + add_dir_to_list(self.compiler.library_dirs, |
| 207 | + sysconfig.get_config_var("LIBDIR")) |
| 208 | + add_dir_to_list(self.compiler.include_dirs, |
| 209 | + sysconfig.get_config_var("INCLUDEDIR")) |
200 | 210 |
|
201 | 211 | try: |
202 | 212 | have_unicode = unicode |
|
0 commit comments