diff --git a/Misc/NEWS b/Misc/NEWS index b6d7dadfcef..582d1dfb140 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,9 @@ Core and Builtins Library ------- +- Issue #7652: Add --with-system-libmpdec option to configure for linking + the _decimal module against an installed libmpdec. + - Issue #14380: MIMEText now defaults to utf-8 when passed non-ASCII unicode with no charset specified. diff --git a/configure b/configure index 7c1113db437..d09d740206d 100755 --- a/configure +++ b/configure @@ -762,6 +762,7 @@ with_pydebug with_libs with_system_expat with_system_ffi +with_system_libmpdec enable_loadable_sqlite_extensions with_dbmliborder with_signal_module @@ -1434,6 +1435,8 @@ Optional Packages: --with-system-expat build pyexpat module using an installed expat library --with-system-ffi build _ctypes module using an installed ffi library + --with-system-libmpdec build _decimal module using an installed libmpdec + library --with-dbmliborder=db1:db2:... order to check db backends for dbm. Valid value is a colon separated string with the backend names @@ -8501,6 +8504,21 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_ffi" >&5 $as_echo "$with_system_ffi" >&6; } +# Check for use of the system libmpdec library +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-libmpdec" >&5 +$as_echo_n "checking for --with-system-libmpdec... " >&6; } + +# Check whether --with-system_libmpdec was given. +if test "${with_system_libmpdec+set}" = set; then : + withval=$with_system_libmpdec; +else + with_system_libmpdec="no" +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_libmpdec" >&5 +$as_echo "$with_system_libmpdec" >&6; } + # Check for support for loadable sqlite extensions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-loadable-sqlite-extensions" >&5 $as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; } diff --git a/configure.ac b/configure.ac index 78bcbe7af76..f1197b0503e 100644 --- a/configure.ac +++ b/configure.ac @@ -2048,6 +2048,15 @@ AC_SUBST(LIBFFI_INCLUDEDIR) AC_MSG_RESULT($with_system_ffi) +# Check for use of the system libmpdec library +AC_MSG_CHECKING(for --with-system-libmpdec) +AC_ARG_WITH(system_libmpdec, + AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library]), + [], + [with_system_libmpdec="no"]) + +AC_MSG_RESULT($with_system_libmpdec) + # Check for support for loadable sqlite extensions AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions) AC_ARG_ENABLE(loadable-sqlite-extensions, diff --git a/setup.py b/setup.py index 6c8d3780414..eae1b85ba6f 100644 --- a/setup.py +++ b/setup.py @@ -1796,42 +1796,53 @@ class PyBuildExt(build_ext): self.use_system_libffi = True def _decimal_ext(self): - sources = [ - '_decimal/_decimal.c', - '_decimal/libmpdec/basearith.c', - '_decimal/libmpdec/constants.c', - '_decimal/libmpdec/context.c', - '_decimal/libmpdec/convolute.c', - '_decimal/libmpdec/crt.c', - '_decimal/libmpdec/difradix2.c', - '_decimal/libmpdec/fnt.c', - '_decimal/libmpdec/fourstep.c', - '_decimal/libmpdec/io.c', - '_decimal/libmpdec/memory.c', - '_decimal/libmpdec/mpdecimal.c', - '_decimal/libmpdec/numbertheory.c', - '_decimal/libmpdec/sixstep.c', - '_decimal/libmpdec/transpose.c', - ] - depends = [ - '_decimal/docstrings.h', - '_decimal/libmpdec/basearith.h', - '_decimal/libmpdec/bits.h', - '_decimal/libmpdec/constants.h', - '_decimal/libmpdec/convolute.h', - '_decimal/libmpdec/crt.h', - '_decimal/libmpdec/difradix2.h', - '_decimal/libmpdec/fnt.h', - '_decimal/libmpdec/fourstep.h', - '_decimal/libmpdec/io.h', - '_decimal/libmpdec/memory.h', - '_decimal/libmpdec/mpdecimal.h', - '_decimal/libmpdec/numbertheory.h', - '_decimal/libmpdec/sixstep.h', - '_decimal/libmpdec/transpose.h', - '_decimal/libmpdec/typearith.h', - '_decimal/libmpdec/umodarith.h', - ] + extra_compile_args = [] + undef_macros=['NDEBUG'] + if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): + include_dirs = [] + libraries = ['mpdec'] + sources = ['_decimal/_decimal.c'] + depends = ['_decimal/docstrings.h'] + else: + include_dirs = ['./Modules/_decimal/libmpdec'] + libraries = [] + sources = [ + '_decimal/_decimal.c', + '_decimal/libmpdec/basearith.c', + '_decimal/libmpdec/constants.c', + '_decimal/libmpdec/context.c', + '_decimal/libmpdec/convolute.c', + '_decimal/libmpdec/crt.c', + '_decimal/libmpdec/difradix2.c', + '_decimal/libmpdec/fnt.c', + '_decimal/libmpdec/fourstep.c', + '_decimal/libmpdec/io.c', + '_decimal/libmpdec/memory.c', + '_decimal/libmpdec/mpdecimal.c', + '_decimal/libmpdec/numbertheory.c', + '_decimal/libmpdec/sixstep.c', + '_decimal/libmpdec/transpose.c', + ] + depends = [ + '_decimal/docstrings.h', + '_decimal/libmpdec/basearith.h', + '_decimal/libmpdec/bits.h', + '_decimal/libmpdec/constants.h', + '_decimal/libmpdec/convolute.h', + '_decimal/libmpdec/crt.h', + '_decimal/libmpdec/difradix2.h', + '_decimal/libmpdec/fnt.h', + '_decimal/libmpdec/fourstep.h', + '_decimal/libmpdec/io.h', + '_decimal/libmpdec/memory.h', + '_decimal/libmpdec/mpdecimal.h', + '_decimal/libmpdec/numbertheory.h', + '_decimal/libmpdec/sixstep.h', + '_decimal/libmpdec/transpose.h', + '_decimal/libmpdec/typearith.h', + '_decimal/libmpdec/umodarith.h', + ] + config = { 'x64': [('CONFIG_64','1'), ('ASM','1')], 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')], @@ -1843,10 +1854,6 @@ class PyBuildExt(build_ext): 'universal': [('UNIVERSAL','1')] } - include_dirs = ['./Modules/_decimal/libmpdec'] - extra_compile_args = [] - undef_macros=['NDEBUG'] - platform = self.get_platform() cc = sysconfig.get_config_var('CC') sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T') @@ -1898,6 +1905,7 @@ class PyBuildExt(build_ext): ext = Extension ( '_decimal', include_dirs=include_dirs, + libraries=libraries, define_macros=define_macros, undef_macros=undef_macros, extra_compile_args=extra_compile_args,