|
1 | | -"""conf_extlibs — Expat, FFI, sqlite3, Tcl/Tk detection. |
2 | | -
|
3 | | -Handles --with-system-expat; detects libffi via pkg-config or manual |
4 | | -probing (including Apple-specific libffi); detects sqlite3 via pkg-config |
5 | | -or manual probing with --enable-loadable-sqlite-extensions; and detects |
6 | | -Tcl/Tk libraries and headers via pkg-config or manual search. |
| 1 | +"""conf_extlibs — external library detection for Expat, FFI, sqlite3, Tcl/Tk, |
| 2 | +UUID, readline/libedit, compression (zlib, bzip2, lzma, zstd), and curses. |
| 3 | +
|
| 4 | +Handles --with-system-expat; detects libffi via pkg-config or manual probing |
| 5 | +(including Apple SDK libffi); detects sqlite3 via pkg-config or manual probing |
| 6 | +with --enable-loadable-sqlite-extensions; detects Tcl/Tk via pkg-config or |
| 7 | +manual search; detects UUID libraries; checks readline/libedit; probes |
| 8 | +compression libraries (zlib, bzip2, lzma, zstd); and detects ncurses/panel. |
7 | 9 | """ |
8 | 10 |
|
9 | 11 | from __future__ import annotations |
@@ -61,18 +63,17 @@ def detect_libffi(v): |
61 | 63 |
|
62 | 64 | if v.ac_sys_system == "Darwin": |
63 | 65 | sdkroot = v.SDKROOT |
64 | | - ffi_h = ( |
65 | | - f"{sdkroot}/usr/include/ffi/ffi.h" |
66 | | - if sdkroot |
67 | | - else "/usr/include/ffi/ffi.h" |
| 66 | + ffi_inc = ( |
| 67 | + f"{sdkroot}/usr/include/ffi" if sdkroot else "/usr/include/ffi" |
68 | 68 | ) |
69 | | - if pyconf.path_is_file(ffi_h): |
70 | | - # use ffi from SDK root |
71 | | - v.have_libffi = True |
72 | | - v.LIBFFI_CFLAGS = ( |
73 | | - f"-I{sdkroot}/usr/include/ffi -DUSING_APPLE_OS_LIBFFI=1" |
74 | | - ) |
75 | | - v.LIBFFI_LIBS = "-lffi" |
| 69 | + with pyconf.save_env(): |
| 70 | + v.CFLAGS = f"-I{ffi_inc} {v.CFLAGS}".strip() |
| 71 | + if pyconf.check_header("ffi.h"): |
| 72 | + if pyconf.check_lib("ffi", "ffi_call"): |
| 73 | + # use ffi from SDK root |
| 74 | + v.have_libffi = True |
| 75 | + v.LIBFFI_CFLAGS = f"-I{ffi_inc} -DUSING_APPLE_OS_LIBFFI=1" |
| 76 | + v.LIBFFI_LIBS = "-lffi" |
76 | 77 |
|
77 | 78 | if v.have_libffi == "missing": |
78 | 79 | # Try pkg-config |
@@ -397,21 +398,18 @@ def detect_uuid(v): |
397 | 398 | LIBUUID_CFLAGS = pkg.cflags |
398 | 399 | LIBUUID_LIBS = pkg.libs |
399 | 400 | else: |
400 | | - save_CPPFLAGS = v.CPPFLAGS |
401 | | - save_LIBS = v.LIBS |
402 | | - v.CPPFLAGS = f"{v.CPPFLAGS} {LIBUUID_CFLAGS}".strip() |
403 | | - v.LIBS = f"{v.LIBS} {LIBUUID_LIBS}".strip() |
404 | | - if pyconf.check_headers("uuid/uuid.h"): |
405 | | - ac_cv_have_uuid_uuid_h = True |
406 | | - if pyconf.check_lib("uuid", "uuid_generate_time"): |
407 | | - have_uuid = True |
408 | | - if pyconf.check_lib("uuid", "uuid_generate_time_safe"): |
409 | | - have_uuid = True |
410 | | - ac_cv_have_uuid_generate_time_safe = True |
411 | | - if have_uuid is True: |
412 | | - LIBUUID_LIBS = LIBUUID_LIBS or "-luuid" |
413 | | - v.CPPFLAGS = save_CPPFLAGS |
414 | | - v.LIBS = save_LIBS |
| 401 | + with pyconf.save_env(): |
| 402 | + v.CPPFLAGS = f"{v.CPPFLAGS} {LIBUUID_CFLAGS}".strip() |
| 403 | + v.LIBS = f"{v.LIBS} {LIBUUID_LIBS}".strip() |
| 404 | + if pyconf.check_headers("uuid/uuid.h"): |
| 405 | + ac_cv_have_uuid_uuid_h = True |
| 406 | + if pyconf.check_lib("uuid", "uuid_generate_time"): |
| 407 | + have_uuid = True |
| 408 | + if pyconf.check_lib("uuid", "uuid_generate_time_safe"): |
| 409 | + have_uuid = True |
| 410 | + ac_cv_have_uuid_generate_time_safe = True |
| 411 | + if have_uuid is True: |
| 412 | + LIBUUID_LIBS = LIBUUID_LIBS or "-luuid" |
415 | 413 |
|
416 | 414 | if have_uuid == "missing": |
417 | 415 | if pyconf.check_headers("uuid/uuid.h"): |
|
0 commit comments