diff --git a/Misc/NEWS.d/next/Build/2022-06-30-09-57-39.gh-issue-90005.9-pQyR.rst b/Misc/NEWS.d/next/Build/2022-06-30-09-57-39.gh-issue-90005.9-pQyR.rst new file mode 100644 index 00000000000000..9b14f767847dad --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-06-30-09-57-39.gh-issue-90005.9-pQyR.rst @@ -0,0 +1 @@ +``_dbm`` module dependencies are now detected by configure. diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index a199aefc510114..ad34f85e254514 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -68,7 +68,7 @@ # dbm/gdbm # dbm needs either libndbm, libgdbm_compat, or libdb 5.x -#@MODULE__DBM_TRUE@_dbm _dbmmodule.c +@MODULE__DBM_TRUE@_dbm _dbmmodule.c # gdbm module needs -lgdbm @MODULE__GDBM_TRUE@_gdbm _gdbmmodule.c diff --git a/configure b/configure index 9144ee19036178..8d0ba9740b8eaf 100755 --- a/configure +++ b/configure @@ -664,6 +664,8 @@ MODULE_NIS_FALSE MODULE_NIS_TRUE MODULE__GDBM_FALSE MODULE__GDBM_TRUE +MODULE__DBM_FALSE +MODULE__DBM_TRUE MODULE__DECIMAL_FALSE MODULE__DECIMAL_TRUE MODULE__CTYPES_FALSE @@ -14040,7 +14042,6 @@ LIBS=$save_LIBS -# check for _dbmmodule.c dependencies for ac_header in ndbm.h do : ac_fn_c_check_header_mongrel "$LINENO" "ndbm.h" "ac_cv_header_ndbm_h" "$ac_includes_default" @@ -14049,14 +14050,18 @@ if test "x$ac_cv_header_ndbm_h" = xyes; then : #define HAVE_NDBM_H 1 _ACEOF - LIBS_SAVE="$LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbm_open in -lndbm" >&5 -$as_echo_n "checking for dbm_open in -lndbm... " >&6; } -if ${ac_cv_lib_ndbm_dbm_open+:} false; then : + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dbm_open" >&5 +$as_echo_n "checking for library containing dbm_open... " >&6; } +if ${ac_cv_search_dbm_open+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lndbm $LIBS" + ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -14075,81 +14080,73 @@ return dbm_open (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ndbm_dbm_open=yes -else - ac_cv_lib_ndbm_dbm_open=no +for ac_lib in '' ndbm gdbm_compat; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dbm_open=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ndbm_dbm_open" >&5 -$as_echo "$ac_cv_lib_ndbm_dbm_open" >&6; } -if test "x$ac_cv_lib_ndbm_dbm_open" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBNDBM 1 -_ACEOF - - LIBS="-lndbm $LIBS" - + conftest$ac_exeext + if ${ac_cv_search_dbm_open+:} false; then : + break fi +done +if ${ac_cv_search_dbm_open+:} false; then : - LIBS="$LIBS_SAVE" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbm_open in -lgdbm_compat" >&5 -$as_echo_n "checking for dbm_open in -lgdbm_compat... " >&6; } -if ${ac_cv_lib_gdbm_compat_dbm_open+:} false; then : - $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgdbm_compat $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char dbm_open (); -int -main () -{ -return dbm_open (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_gdbm_compat_dbm_open=yes -else - ac_cv_lib_gdbm_compat_dbm_open=no + ac_cv_search_dbm_open=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_compat_dbm_open" >&5 -$as_echo "$ac_cv_lib_gdbm_compat_dbm_open" >&6; } -if test "x$ac_cv_lib_gdbm_compat_dbm_open" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBGDBM_COMPAT 1 -_ACEOF - - LIBS="-lgdbm_compat $LIBS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dbm_open" >&5 +$as_echo "$ac_cv_search_dbm_open" >&6; } +ac_res=$ac_cv_search_dbm_open +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi - LIBS="$LIBS_SAVE" + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + fi done -# "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h" -# unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ndbm presence and linker args" >&5 +$as_echo_n "checking for ndbm presence and linker args... " >&6; } +case $ac_cv_search_dbm_open in #( + *ndbm*|*gdbm_compat*) : + + dbm_ndbm="$ac_cv_search_dbm_open" + have_ndbm=yes + ;; #( + none*) : + + dbm_ndbm="" + have_ndbm=yes + ;; #( + no) : + have_ndbm=no + ;; #( + *) : + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_ndbm ($dbm_ndbm)" >&5 +$as_echo "$have_ndbm ($dbm_ndbm)" >&6; } + { ac_cv_header_gdbm_ndbm_h=; unset ac_cv_header_gdbm_ndbm_h;} if ${ac_cv_header_gdbm_slash_ndbm_h+:} false; then : $as_echo_n "(cached) " >&6 @@ -14202,14 +14199,18 @@ fi { ac_cv_header_gdbm_ndbm_h=; unset ac_cv_header_gdbm_ndbm_h;} if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o "$ac_cv_header_gdbm_dash_ndbm_h" = yes; then - LIBS_SAVE="$LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbm_open in -lgdbm_compat" >&5 -$as_echo_n "checking for dbm_open in -lgdbm_compat... " >&6; } -if ${ac_cv_lib_gdbm_compat_dbm_open+:} false; then : + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dbm_open" >&5 +$as_echo_n "checking for library containing dbm_open... " >&6; } +if ${ac_cv_search_dbm_open+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgdbm_compat $LIBS" + ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -14228,27 +14229,45 @@ return dbm_open (); return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_gdbm_compat_dbm_open=yes -else - ac_cv_lib_gdbm_compat_dbm_open=no +for ac_lib in '' gdbm_compat; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dbm_open=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + conftest$ac_exeext + if ${ac_cv_search_dbm_open+:} false; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gdbm_compat_dbm_open" >&5 -$as_echo "$ac_cv_lib_gdbm_compat_dbm_open" >&6; } -if test "x$ac_cv_lib_gdbm_compat_dbm_open" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBGDBM_COMPAT 1 -_ACEOF +done +if ${ac_cv_search_dbm_open+:} false; then : - LIBS="-lgdbm_compat $LIBS" +else + ac_cv_search_dbm_open=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dbm_open" >&5 +$as_echo "$ac_cv_search_dbm_open" >&6; } +ac_res=$ac_cv_search_dbm_open +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi - LIBS="$LIBS_SAVE" + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + fi # Check for libdb >= 5 with dbm_open() @@ -14267,16 +14286,21 @@ if ${ac_cv_have_libdb+:} false; then : $as_echo_n "(cached) " >&6 else - LIBS_SAVE="$LIBS" - LIBS="$LIBS -ldb" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + LIBS="$LIBS -ldb" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #define DB_DBM_HSEARCH 1 - #include - #if DB_VERSION_MAJOR < 5 - #error "dh.h: DB_VERSION_MAJOR < 5 is not supported." - #endif + #define DB_DBM_HSEARCH 1 + #include + #if DB_VERSION_MAJOR < 5 + #error "dh.h: DB_VERSION_MAJOR < 5 is not supported." + #endif int main () @@ -14294,7 +14318,13 @@ else fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LIBS="$LIBS_SAVE" + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_libdb" >&5 @@ -14349,6 +14379,43 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_dbmliborder" >&5 $as_echo "$with_dbmliborder" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _dbm module CFLAGS and LIBS" >&5 +$as_echo_n "checking for _dbm module CFLAGS and LIBS... " >&6; } +have_dbm=no +as_save_IFS=$IFS +IFS=: +for db in $with_dbmliborder; do + case "$db" in + ndbm) + if test "$have_ndbm" = yes; then + DBM_CFLAGS="-DUSE_NDBM" + DBM_LIBS="$dbm_ndbm" + have_dbm=yes + break + fi + ;; + gdbm) + if test "$have_gdbm_compat" = yes; then + DBM_CFLAGS="-DUSE_GDBM_COMPAT" + DBM_LIBS="-lgdbm_compat" + have_dbm=yes + break + fi + ;; + bdb) + if test "$ac_cv_have_libdb" = yes; then + DBM_CFLAGS="-DUSE_BERKDB" + DBM_LIBS="-ldb" + have_dbm=yes + break + fi + ;; + esac +done +IFS=$as_save_IFS +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DBM_CFLAGS $DBM_LIBS" >&5 +$as_echo "$DBM_CFLAGS $DBM_LIBS" >&6; } + # Templates for things AC_DEFINEd more than once. # For a single AC_DEFINE, no template is needed. @@ -24604,6 +24671,40 @@ fi $as_echo "$py_cv_module__decimal" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _dbm" >&5 +$as_echo_n "checking for stdlib extension module _dbm... " >&6; } + if test "$py_cv_module__dbm" != "n/a"; then : + + if test -n "$with_dbmliborder"; then : + if test "$have_dbm" != "no"; then : + py_cv_module__dbm=yes +else + py_cv_module__dbm=missing +fi +else + py_cv_module__dbm=disabled +fi + +fi + as_fn_append MODULE_BLOCK "MODULE__DBM_STATE=$py_cv_module__dbm$as_nl" + if test "x$py_cv_module__dbm" = xyes; then : + + as_fn_append MODULE_BLOCK "MODULE__DBM_CFLAGS=$DBM_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__DBM_LDFLAGS=$DBM_LIBS$as_nl" + +fi + if test "$py_cv_module__dbm" = yes; then + MODULE__DBM_TRUE= + MODULE__DBM_FALSE='#' +else + MODULE__DBM_TRUE='#' + MODULE__DBM_FALSE= +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__dbm" >&5 +$as_echo "$py_cv_module__dbm" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _gdbm" >&5 $as_echo_n "checking for stdlib extension module _gdbm... " >&6; } if test "$py_cv_module__gdbm" != "n/a"; then : @@ -25622,6 +25723,10 @@ if test -z "${MODULE__DECIMAL_TRUE}" && test -z "${MODULE__DECIMAL_FALSE}"; then as_fn_error $? "conditional \"MODULE__DECIMAL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE__DBM_TRUE}" && test -z "${MODULE__DBM_FALSE}"; then + as_fn_error $? "conditional \"MODULE__DBM\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MODULE__GDBM_TRUE}" && test -z "${MODULE__GDBM_FALSE}"; then as_fn_error $? "conditional \"MODULE__GDBM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 12ae2ae8d87eb3..b03ead3bdefa04 100644 --- a/configure.ac +++ b/configure.ac @@ -3956,17 +3956,30 @@ WITH_SAVE_ENV([ ], [have_gdbm=no]) ]) -# check for _dbmmodule.c dependencies +dnl check for _dbmmodule.c dependencies +dnl ndbm, gdbm_compat, libdb AC_CHECK_HEADERS([ndbm.h], [ - LIBS_SAVE="$LIBS" - AC_CHECK_LIB([ndbm], [dbm_open]) - LIBS="$LIBS_SAVE" - AC_CHECK_LIB([gdbm_compat], [dbm_open]) - LIBS="$LIBS_SAVE" + WITH_SAVE_ENV([ + AC_SEARCH_LIBS([dbm_open], [ndbm gdbm_compat]) + ]) ]) -# "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h" -# unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits. +AC_MSG_CHECKING([for ndbm presence and linker args]) +AS_CASE([$ac_cv_search_dbm_open], + [*ndbm*|*gdbm_compat*], [ + dbm_ndbm="$ac_cv_search_dbm_open" + have_ndbm=yes + ], + [none*], [ + dbm_ndbm="" + have_ndbm=yes + ], + [no], [have_ndbm=no] +) +AC_MSG_RESULT([$have_ndbm ($dbm_ndbm)]) + +dnl "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h" +dnl unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits. AS_UNSET([ac_cv_header_gdbm_ndbm_h]) AC_CACHE_VAL([ac_cv_header_gdbm_slash_ndbm_h], [ AC_CHECK_HEADER( @@ -3991,26 +4004,26 @@ AS_VAR_IF([ac_cv_header_gdbm_dash_ndbm_h], [yes], [ AS_UNSET([ac_cv_header_gdbm_ndbm_h]) if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o "$ac_cv_header_gdbm_dash_ndbm_h" = yes; then - LIBS_SAVE="$LIBS" - AC_CHECK_LIB([gdbm_compat], [dbm_open]) - LIBS="$LIBS_SAVE" + WITH_SAVE_ENV([ + AC_SEARCH_LIBS([dbm_open], [gdbm_compat]) + ]) fi # Check for libdb >= 5 with dbm_open() # db.h re-defines the name of the function AC_CHECK_HEADERS([db.h], [ AC_CACHE_CHECK([for libdb], [ac_cv_have_libdb], [ - LIBS_SAVE="$LIBS" - LIBS="$LIBS -ldb" - AC_LINK_IFELSE([AC_LANG_PROGRAM([ - #define DB_DBM_HSEARCH 1 - #include - #if DB_VERSION_MAJOR < 5 - #error "dh.h: DB_VERSION_MAJOR < 5 is not supported." - #endif - ], [DBM *dbm = dbm_open(NULL, 0, 0)]) - ], [ac_cv_have_libdb=yes], [ac_cv_have_libdb=no]) - LIBS="$LIBS_SAVE" + WITH_SAVE_ENV([ + LIBS="$LIBS -ldb" + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + #define DB_DBM_HSEARCH 1 + #include + #if DB_VERSION_MAJOR < 5 + #error "dh.h: DB_VERSION_MAJOR < 5 is not supported." + #endif + ], [DBM *dbm = dbm_open(NULL, 0, 0)]) + ], [ac_cv_have_libdb=yes], [ac_cv_have_libdb=no]) + ]) ]) AS_VAR_IF([ac_cv_have_libdb], [yes], [ AC_DEFINE([HAVE_LIBDB], [1], [Define to 1 if you have the `db' library (-ldb).]) @@ -4018,7 +4031,7 @@ AC_CHECK_HEADERS([db.h], [ ]) # Check for --with-dbmliborder -AC_MSG_CHECKING(for --with-dbmliborder) +AC_MSG_CHECKING([for --with-dbmliborder]) AC_ARG_WITH(dbmliborder, AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [override order to check db backends for dbm; a valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), [], [with_dbmliborder=gdbm:ndbm:bdb]) @@ -4038,7 +4051,42 @@ IFS=$as_save_IFS AS_VAR_IF([with_dbmliborder], [error], [ AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:... (gdbm:ndbm:bdb)]) ]) -AC_MSG_RESULT($with_dbmliborder) +AC_MSG_RESULT([$with_dbmliborder]) + +AC_MSG_CHECKING([for _dbm module CFLAGS and LIBS]) +have_dbm=no +as_save_IFS=$IFS +IFS=: +for db in $with_dbmliborder; do + case "$db" in + ndbm) + if test "$have_ndbm" = yes; then + DBM_CFLAGS="-DUSE_NDBM" + DBM_LIBS="$dbm_ndbm" + have_dbm=yes + break + fi + ;; + gdbm) + if test "$have_gdbm_compat" = yes; then + DBM_CFLAGS="-DUSE_GDBM_COMPAT" + DBM_LIBS="-lgdbm_compat" + have_dbm=yes + break + fi + ;; + bdb) + if test "$ac_cv_have_libdb" = yes; then + DBM_CFLAGS="-DUSE_BERKDB" + DBM_LIBS="-ldb" + have_dbm=yes + break + fi + ;; + esac +done +IFS=$as_save_IFS +AC_MSG_RESULT([$DBM_CFLAGS $DBM_LIBS]) # Templates for things AC_DEFINEd more than once. # For a single AC_DEFINE, no template is needed. @@ -6940,7 +6988,9 @@ PY_STDLIB_MOD([_ctypes], dnl PY_STDLIB_MOD([_curses], [], [], [], []) dnl PY_STDLIB_MOD([_curses_panel], [], [], [], []) PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS]) -dnl PY_STDLIB_MOD([_dbm], [], [], [], []) +PY_STDLIB_MOD([_dbm], + [test -n "$with_dbmliborder"], [test "$have_dbm" != "no"], + [$DBM_CFLAGS], [$DBM_LIBS]) PY_STDLIB_MOD([_gdbm], [test "$have_gdbm_dbmliborder" = yes], [test "$have_gdbm" = yes], [$GDBM_CFLAGS], [$GDBM_LIBS]) diff --git a/pyconfig.h.in b/pyconfig.h.in index 15933e75b1b079..b05ddd41c2bba3 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -640,18 +640,12 @@ /* Define to 1 if you have the `dld' library (-ldld). */ #undef HAVE_LIBDLD -/* Define to 1 if you have the `gdbm_compat' library (-lgdbm_compat). */ -#undef HAVE_LIBGDBM_COMPAT - /* Define to 1 if you have the `ieee' library (-lieee). */ #undef HAVE_LIBIEEE /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H -/* Define to 1 if you have the `ndbm' library (-lndbm). */ -#undef HAVE_LIBNDBM - /* Define to build the readline module. */ #undef HAVE_LIBREADLINE diff --git a/setup.py b/setup.py index 843ec35effe109..cc11dedee1b2e2 100644 --- a/setup.py +++ b/setup.py @@ -1163,77 +1163,7 @@ def detect_crypt(self): self.addext(Extension('_crypt', ['_cryptmodule.c'])) def detect_dbm_gdbm(self): - # Modules that provide persistent dictionary-like semantics. You will - # probably want to arrange for at least one of them to be available on - # your machine, though none are defined by default because of library - # dependencies. The Python module dbm/__init__.py provides an - # implementation independent wrapper for these; dbm/dumb.py provides - # similar functionality (but slower of course) implemented in Python. - - dbm_setup_debug = False # verbose debug prints from this script? - dbm_order = ['gdbm'] - - # libdb, gdbm and ndbm headers and libraries - have_ndbm_h = sysconfig.get_config_var("HAVE_NDBM_H") - have_gdbm_ndbm_h = sysconfig.get_config_var("HAVE_GDBM_NDBM_H") - have_gdbm_dash_ndbm_h = sysconfig.get_config_var("HAVE_GDBM_DASH_NDBM_H") - have_libndbm = sysconfig.get_config_var("HAVE_LIBNDBM") - have_libgdbm_compat = sysconfig.get_config_var("HAVE_LIBGDBM_COMPAT") - have_libdb = sysconfig.get_config_var("HAVE_LIBDB") - - # The standard Unix dbm module: - if not CYGWIN: - config_args = [arg.strip("'") - for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] - dbm_args = [arg for arg in config_args - if arg.startswith('--with-dbmliborder=')] - if dbm_args: - dbm_order = [arg.split('=')[-1] for arg in dbm_args][-1].split(":") - else: - dbm_order = "gdbm:ndbm:bdb".split(":") - dbmext = None - for cand in dbm_order: - if cand == "ndbm": - if have_ndbm_h: - # Some systems have -lndbm, others have -lgdbm_compat, - # others don't have either - if have_libndbm: - ndbm_libs = ['ndbm'] - elif have_libgdbm_compat: - ndbm_libs = ['gdbm_compat'] - else: - ndbm_libs = [] - if dbm_setup_debug: print("building dbm using ndbm") - dbmext = Extension( - '_dbm', ['_dbmmodule.c'], - define_macros=[('USE_NDBM', None)], - libraries=ndbm_libs - ) - break - elif cand == "gdbm": - # dbm_open() is provided by libgdbm_compat, which wraps libgdbm - if have_libgdbm_compat and (have_gdbm_ndbm_h or have_gdbm_dash_ndbm_h): - if dbm_setup_debug: print("building dbm using gdbm") - dbmext = Extension( - '_dbm', ['_dbmmodule.c'], - define_macros=[('USE_GDBM_COMPAT', None)], - libraries=['gdbm_compat'] - ) - break - elif cand == "bdb": - if have_libdb: - if dbm_setup_debug: print("building dbm using bdb") - dbmext = Extension( - '_dbm', ['_dbmmodule.c'], - define_macros=[('USE_BERKDB', None)], - libraries=['db'] - ) - break - if dbmext is not None: - self.add(dbmext) - else: - self.missing.append('_dbm') - + self.addext(Extension('_dbm', ['_dbmmodule.c'])) # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: self.addext(Extension('_gdbm', ['_gdbmmodule.c']))