Skip to content

Commit

Permalink
pythongh-115119: Default to --with-system-libmpdec=yes (python#118539)
Browse files Browse the repository at this point in the history
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
  • Loading branch information
erlend-aasland and zware authored May 6, 2024
1 parent e5353d4 commit 325a1da
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 20 deletions.
1 change: 1 addition & 0 deletions .github/workflows/posix-deps-apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ apt-get -yq install \
libgdbm-dev \
libgdbm-compat-dev \
liblzma-dev \
libmpdec-dev \
libncurses5-dev \
libreadline6-dev \
libsqlite3-dev \
Expand Down
11 changes: 9 additions & 2 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,18 @@ Libraries options

.. option:: --with-system-libmpdec

Build the ``_decimal`` extension module using an installed ``mpdec``
library, see the :mod:`decimal` module (default is no).
Build the ``_decimal`` extension module using an installed ``mpdecimal``
library, see the :mod:`decimal` module (default is yes).

.. versionadded:: 3.3

.. versionchanged:: 3.13
Default to using the installed ``mpdecimal`` library.

.. deprecated-removed:: 3.13 3.15
A copy of the ``mpdecimal`` library sources will no longer be distributed
with Python 3.15.

.. seealso:: :option:`LIBMPDEC_CFLAGS` and :option:`LIBMPDEC_LIBS`.

.. option:: --with-readline=readline|editline
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,10 @@ Changes in the Python API
Build Changes
=============

* The :file:`configure` option :option:`--with-system-libmpdec` now defaults
to ``yes``. The bundled copy of ``libmpdecimal`` will be removed in Python
3.15.

* Autoconf 2.71 and aclocal 1.16.4 are now required to regenerate
the :file:`configure` script.
(Contributed by Christian Heimes in :gh:`89886`.)
Expand Down Expand Up @@ -2336,6 +2340,7 @@ Pending Removal in Python 3.14
Pending Removal in Python 3.15
------------------------------

* The bundled copy of ``libmpdecimal``.
* :c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule`.
* :c:func:`PyWeakref_GET_OBJECT`: use :c:func:`PyWeakref_GetRef` instead.
* :c:func:`PyWeakref_GetObject`: use :c:func:`PyWeakref_GetRef` instead.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The :file:`configure` option :option:`--with-system-libmpdec` now defaults to ``yes``.
The bundled copy of ``libmpdecimal`` will be removed in Python 3.15.
84 changes: 70 additions & 14 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 29 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3974,23 +3974,46 @@ AC_ARG_WITH(
[system_libmpdec],
[AS_HELP_STRING(
[--with-system-libmpdec],
[build _decimal module using an installed libmpdec library, see Doc/library/decimal.rst (default is no)]
[build _decimal module using an installed mpdecimal library, see Doc/library/decimal.rst (default is yes)]
)],
[],
[with_system_libmpdec="no"])
[with_system_libmpdec="yes"])
AC_MSG_RESULT([$with_system_libmpdec])

AS_VAR_IF(
[with_system_libmpdec], [yes],
[PKG_CHECK_MODULES(
[LIBMPDEC], [libmpdec], [],
[LIBMPDEC], [libmpdec >= 2.5.0], [],
[LIBMPDEC_CFLAGS=${LIBMPDEC_CFLAGS-""}
LIBMPDEC_LIBS=${LIBMPDEC_LIBS-"-lmpdec -lm"}
LIBMPDEC_INTERNAL=])],
[LIBMPDEC_CFLAGS="-I\$(srcdir)/Modules/_decimal/libmpdec"
LIBMPDEC_LIBS="-lm \$(LIBMPDEC_A)"
LIBMPDEC_INTERNAL="\$(LIBMPDEC_HEADERS) \$(LIBMPDEC_A)"])

AS_VAR_IF([with_system_libmpdec], [yes],
[WITH_SAVE_ENV([
CPPFLAGS="$LIBMPDEC_CFLAGS $CPPFLAGS"
LIBS="$LIBMPDEC_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <mpdecimal.h>
#if MPD_VERSION_HEX < 0x02050000
# error "mpdecimal 2.5.0 or higher required"
#endif
], [const char *x = mpd_version();])],
[have_mpdec=yes],
[have_mpdec=no])
])],
[AS_VAR_SET([have_mpdec], [yes])
AC_MSG_WARN([m4_normalize([
the bundled copy of libmpdecimal is scheduled for removal in Python 3.15;
consider using a system installed mpdecimal library.])])])

AS_IF([test "$with_system_libmpdec" = "yes" && test "$have_mpdec" = "no"],
[AC_MSG_WARN([no system libmpdecimal found; unable to build _decimal])])

# Disable forced inlining in debug builds, see GH-94847
AS_VAR_IF(
[with_pydebug], [yes],
Expand Down Expand Up @@ -7668,7 +7691,9 @@ PY_STDLIB_MOD([_curses_panel],
[], [test "$have_panel" != "no"],
[$PANEL_CFLAGS $CURSES_CFLAGS], [$PANEL_LIBS $CURSES_LIBS]
)
PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS])
PY_STDLIB_MOD([_decimal],
[], [test "$have_mpdec" = "yes"],
[$LIBMPDEC_CFLAGS], [$LIBMPDEC_LIBS])
PY_STDLIB_MOD([_dbm],
[test -n "$with_dbmliborder"], [test "$have_dbm" != "no"],
[$DBM_CFLAGS], [$DBM_LIBS])
Expand Down

0 comments on commit 325a1da

Please sign in to comment.