|
27 | 27 | _BUILDDIR_COOKIE = "pybuilddir.txt" |
28 | 28 |
|
29 | 29 | def add_dir_to_list(dirlist, dir): |
30 | | - """Add the directory 'dir' to the list 'dirlist' (at the front) if |
| 30 | + """Add the directory 'dir' to the list 'dirlist' (after any relative |
| 31 | + directories) if: |
| 32 | +
|
31 | 33 | 1) 'dir' is not already in 'dirlist' |
32 | | - 2) 'dir' actually exists, and is a directory.""" |
33 | | - if dir is not None and os.path.isdir(dir) and dir not in dirlist: |
34 | | - dirlist.insert(0, dir) |
| 34 | + 2) 'dir' actually exists, and is a directory. |
| 35 | + """ |
| 36 | + if dir is None or not os.path.isdir(dir) or dir in dirlist: |
| 37 | + return |
| 38 | + for i, path in enumerate(dirlist): |
| 39 | + if not os.path.isabs(path): |
| 40 | + dirlist.insert(i + 1, dir) |
| 41 | + break |
35 | 42 |
|
36 | 43 | def macosx_sdk_root(): |
37 | 44 | """ |
@@ -362,7 +369,9 @@ def get_platform(self): |
362 | 369 | return sys.platform |
363 | 370 |
|
364 | 371 | def detect_modules(self): |
365 | | - # Ensure that /usr/local is always used |
| 372 | + # Ensure that /usr/local is always used, but the local build |
| 373 | + # directories (i.e. '.' and 'Include') must be first. See issue |
| 374 | + # 10520. |
366 | 375 | add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
367 | 376 | add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
368 | 377 |
|
@@ -437,9 +446,10 @@ def detect_modules(self): |
437 | 446 | # This should work on any unixy platform ;-) |
438 | 447 | # If the user has bothered specifying additional -I and -L flags |
439 | 448 | # in OPT and LDFLAGS we might as well use them here. |
440 | | - # NOTE: using shlex.split would technically be more correct, but |
441 | | - # also gives a bootstrap problem. Let's hope nobody uses directories |
442 | | - # with whitespace in the name to store libraries. |
| 449 | + # |
| 450 | + # NOTE: using shlex.split would technically be more correct, but |
| 451 | + # also gives a bootstrap problem. Let's hope nobody uses |
| 452 | + # directories with whitespace in the name to store libraries. |
443 | 453 | cflags, ldflags = sysconfig.get_config_vars( |
444 | 454 | 'CFLAGS', 'LDFLAGS') |
445 | 455 | for item in cflags.split(): |
|
0 commit comments