Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55708cc

Browse files
committed
- Issue #4587: Add configure option --with-dbmliborder=db1:db2:... to specify
the order that backends for the dbm extension are checked.
1 parent 58a4224 commit 55708cc

4 files changed

Lines changed: 116 additions & 32 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,9 @@ Tools/Demos
880880
Build
881881
-----
882882

883+
- Issue #4587: Add configure option --with-dbmliborder=db1:db2:... to specify
884+
the order that backends for the dbm extension are checked.
885+
883886
- Link the shared python library with $(MODLIBS).
884887

885888
- Issue #5134: Silence compiler warnings when compiling sqlite with VC++.

configure

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# From configure.in Revision: 71723 .
2+
# From configure.in Revision: 71731 .
33
# Guess values for system-dependent variables and create Makefiles.
44
# Generated by GNU Autoconf 2.61 for python 3.1.
55
#
@@ -1340,6 +1340,10 @@ Optional Packages:
13401340
--with-pydebug build with Py_DEBUG defined
13411341
--with-libs='lib1 ...' link against additional libs
13421342
--with-system-ffi build _ctypes module using an installed ffi library
1343+
--with-dbmliborder=db1:db2:...
1344+
order to check db backends for dbm. Valid value is a
1345+
colon separated string with the backend names
1346+
`ndbm', `gdbm' and `bdb'.
13431347
--with-signal-module disable/enable signal module
13441348
--with-dec-threads use DEC Alpha/OSF1 thread-safe libraries
13451349
--with(out)-threads[=DIRECTORY]
@@ -14087,6 +14091,33 @@ fi
1408714091
{ echo "$as_me:$LINENO: result: $with_system_ffi" >&5
1408814092
echo "${ECHO_T}$with_system_ffi" >&6; }
1408914093

14094+
# Check for --with-dbmliborder
14095+
{ echo "$as_me:$LINENO: checking for --with-dbmliborder" >&5
14096+
echo $ECHO_N "checking for --with-dbmliborder... $ECHO_C" >&6; }
14097+
14098+
# Check whether --with-dbmliborder was given.
14099+
if test "${with_dbmliborder+set}" = set; then
14100+
withval=$with_dbmliborder;
14101+
if test x$with_dbmliborder = xyes
14102+
then
14103+
{ { echo "$as_me:$LINENO: error: proper usage is --with-dbmliborder=db1:db2:..." >&5
14104+
echo "$as_me: error: proper usage is --with-dbmliborder=db1:db2:..." >&2;}
14105+
{ (exit 1); exit 1; }; }
14106+
else
14107+
for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
14108+
if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
14109+
then
14110+
{ { echo "$as_me:$LINENO: error: proper usage is --with-dbmliborder=db1:db2:..." >&5
14111+
echo "$as_me: error: proper usage is --with-dbmliborder=db1:db2:..." >&2;}
14112+
{ (exit 1); exit 1; }; }
14113+
fi
14114+
done
14115+
fi
14116+
fi
14117+
14118+
{ echo "$as_me:$LINENO: result: $with_dbmliborder" >&5
14119+
echo "${ECHO_T}$with_dbmliborder" >&6; }
14120+
1409014121
# Determine if signalmodule should be used.
1409114122

1409214123

configure.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,24 @@ AC_ARG_WITH(system_ffi,
18371837

18381838
AC_MSG_RESULT($with_system_ffi)
18391839

1840+
# Check for --with-dbmliborder
1841+
AC_MSG_CHECKING(for --with-dbmliborder)
1842+
AC_ARG_WITH(dbmliborder,
1843+
AC_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
1844+
[
1845+
if test x$with_dbmliborder = xyes
1846+
then
1847+
AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1848+
else
1849+
for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1850+
if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1851+
then
1852+
AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1853+
fi
1854+
done
1855+
fi])
1856+
AC_MSG_RESULT($with_dbmliborder)
1857+
18401858
# Determine if signalmodule should be used.
18411859
AC_SUBST(USE_SIGNAL_MODULE)
18421860
AC_SUBST(SIGNAL_OBJS)

setup.py

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -913,37 +913,69 @@ class db_found(Exception): pass
913913

914914
# The standard Unix dbm module:
915915
if platform not in ['cygwin']:
916-
if find_file("ndbm.h", inc_dirs, []) is not None:
917-
# Some systems have -lndbm, others don't
918-
if self.compiler.find_library_file(lib_dirs, 'ndbm'):
919-
ndbm_libs = ['ndbm']
920-
else:
921-
ndbm_libs = []
922-
exts.append( Extension('_dbm', ['_dbmmodule.c'],
923-
define_macros=[('HAVE_NDBM_H',None)],
924-
libraries = ndbm_libs ) )
925-
elif self.compiler.find_library_file(lib_dirs, 'gdbm'):
926-
gdbm_libs = ['gdbm']
927-
if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
928-
gdbm_libs.append('gdbm_compat')
929-
if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
930-
exts.append( Extension(
931-
'_dbm', ['_dbmmodule.c'],
932-
define_macros=[('HAVE_GDBM_NDBM_H',None)],
933-
libraries = gdbm_libs ) )
934-
elif find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
935-
exts.append( Extension(
936-
'_dbm', ['_dbmmodule.c'],
937-
define_macros=[('HAVE_GDBM_DASH_NDBM_H',None)],
938-
libraries = gdbm_libs ) )
939-
elif db_incs is not None:
940-
exts.append( Extension('_dbm', ['_dbmmodule.c'],
941-
library_dirs=dblib_dir,
942-
runtime_library_dirs=dblib_dir,
943-
include_dirs=db_incs,
944-
define_macros=[('HAVE_BERKDB_H',None),
945-
('DB_DBM_HSEARCH',None)],
946-
libraries=dblibs))
916+
config_args = [arg.strip("'")
917+
for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
918+
dbm_args = [arg.split('=')[-1] for arg in config_args
919+
if arg.startswith('--with-dbmliborder=')]
920+
if dbm_args:
921+
dbm_order = dbm_args[-1].split(":")
922+
else:
923+
dbm_order = "ndbm:gdbm:bdb".split(":")
924+
dbmext = None
925+
for cand in dbm_order:
926+
if cand == "ndbm":
927+
if find_file("ndbm.h", inc_dirs, []) is not None:
928+
# Some systems have -lndbm, others don't
929+
if self.compiler.find_library_file(lib_dirs, 'ndbm'):
930+
ndbm_libs = ['ndbm']
931+
else:
932+
ndbm_libs = []
933+
print("building dbm using ndbm")
934+
dbmext = Extension('_dbm', ['_dbmmodule.c'],
935+
define_macros=[
936+
('HAVE_NDBM_H',None),
937+
],
938+
libraries=ndbm_libs)
939+
break
940+
941+
elif cand == "gdbm":
942+
if self.compiler.find_library_file(lib_dirs, 'gdbm'):
943+
gdbm_libs = ['gdbm']
944+
if self.compiler.find_library_file(lib_dirs, 'gdbm_compat'):
945+
gdbm_libs.append('gdbm_compat')
946+
if find_file("gdbm/ndbm.h", inc_dirs, []) is not None:
947+
print("building dbm using gdbm")
948+
dbmext = Extension(
949+
'_dbm', ['_dbmmodule.c'],
950+
define_macros=[
951+
('HAVE_GDBM_NDBM_H', None),
952+
],
953+
libraries = gdbm_libs)
954+
break
955+
if find_file("gdbm-ndbm.h", inc_dirs, []) is not None:
956+
print("building dbm using gdbm")
957+
dbmext = Extension(
958+
'_dbm', ['_dbmmodule.c'],
959+
define_macros=[
960+
('HAVE_GDBM_DASH_NDBM_H', None),
961+
],
962+
libraries = gdbm_libs)
963+
break
964+
elif cand == "bdb":
965+
if db_incs is not None:
966+
print("building dbm using bdb")
967+
dbmext = Extension('_dbm', ['_dbmmodule.c'],
968+
library_dirs=dblib_dir,
969+
runtime_library_dirs=dblib_dir,
970+
include_dirs=db_incs,
971+
define_macros=[
972+
('HAVE_BERKDB_H', None),
973+
('DB_DBM_HSEARCH', None),
974+
],
975+
libraries=dblibs)
976+
break
977+
if dbmext is not None:
978+
exts.append(dbmext)
947979
else:
948980
missing.append('_dbm')
949981

0 commit comments

Comments
 (0)