Skip to content

Commit 4d7da20

Browse files
committed
Review conf_extlibs.py: fix docstring, Darwin libffi check, and UUID save_env.
- Expand module docstring to list all covered areas (was missing UUID, readline, compression, and curses). - Fix Darwin libffi detection: replace path_is_file() with save_env() + check_header("ffi.h") + check_lib("ffi", "ffi_call"), matching the WITH_SAVE_ENV + AC_CHECK_HEADER + AC_CHECK_LIB pattern in configure.ac. The old code skipped the link test entirely. - Fix detect_uuid pkg-config fallback: replace manual save_CPPFLAGS/save_LIBS pattern with with pyconf.save_env() for consistency. Assisted-by: Claude
1 parent 8554bf8 commit 4d7da20

File tree

1 file changed

+30
-32
lines changed

1 file changed

+30
-32
lines changed

Tools/configure/conf_extlibs.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
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.
79
"""
810

911
from __future__ import annotations
@@ -61,18 +63,17 @@ def detect_libffi(v):
6163

6264
if v.ac_sys_system == "Darwin":
6365
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"
6868
)
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"
7677

7778
if v.have_libffi == "missing":
7879
# Try pkg-config
@@ -397,21 +398,18 @@ def detect_uuid(v):
397398
LIBUUID_CFLAGS = pkg.cflags
398399
LIBUUID_LIBS = pkg.libs
399400
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"
415413

416414
if have_uuid == "missing":
417415
if pyconf.check_headers("uuid/uuid.h"):

0 commit comments

Comments
 (0)