Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c8b8a57
gh-115119: Removed bundled copy of the libmpdec
skirpichev May 13, 2025
43c8721
+ configure
skirpichev May 13, 2025
9d6c9b5
+1
skirpichev May 13, 2025
5de2aa2
Apply suggestions from code review
skirpichev May 13, 2025
dfd9f40
+ configure
skirpichev May 13, 2025
769a36a
autoconf
AA-Turner May 13, 2025
60f7ae2
revert
AA-Turner May 13, 2025
b9af863
makesetup
AA-Turner May 13, 2025
81c7020
+ lint and macos
skirpichev May 13, 2025
3bf12e8
Windows: SBOM
AA-Turner May 13, 2025
4555447
lint
AA-Turner May 13, 2025
2fca0e5
fix docs
skirpichev May 14, 2025
800dd01
XXX disable _decimal if no libmpdec is available
skirpichev May 14, 2025
be3d413
+1
skirpichev May 14, 2025
bd03679
fix json
skirpichev May 14, 2025
2ba6b8b
reorder
skirpichev May 14, 2025
8bc2e53
install libmpdec on this job
skirpichev May 14, 2025
a79e284
Merge branch 'main' into remove-bundled-mpdecimal/115119
skirpichev Jun 3, 2025
f0dc0bb
XXX try libmpdec-dev from PPA for PHP: https://launchpad.net/~ondrej/…
skirpichev Jun 3, 2025
6e74feb
+1
skirpichev Jun 3, 2025
a4a6796
Merge branch 'master' into remove-bundled-mpdecimal/115119
skirpichev May 8, 2026
e0bdb87
news
skirpichev May 8, 2026
adf7af4
+1
skirpichev May 8, 2026
9ccd488
+1
skirpichev May 8, 2026
e10ed83
Apply suggestions from code review
skirpichev May 9, 2026
b2f5f30
address review: restore license.rst
skirpichev May 9, 2026
081d1e0
address review: revert unrelated change
skirpichev May 9, 2026
97767d6
address review: cleanup configure.ac
skirpichev May 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/posix-deps-apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apt-get -yq --no-install-recommends install \
zlib1g-dev

# Workaround missing libmpdec-dev on ubuntu 24.04 by building mpdecimal
# from source. ppa:ondrej/php (launchpad.net) are unreliable
# from source. ppa:ondrej/php (launchpad.net) are unreliable
# (https://status.canonical.com) so fetch the tarball directly
# from the upstream host.
# https://www.bytereef.org/mpdecimal/
Expand Down
2 changes: 2 additions & 0 deletions Doc/tools/removed-ids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ c-api/allocation.html: deprecated-aliases
c-api/file.html: deprecated-api

library/asyncio-task.html: terminating-a-task-group

using/configure.html: cmdoption-with-system-libmpdec
29 changes: 0 additions & 29 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ Dependencies to build optional modules are:

.. [1] If *libmpdec* is not available, the :mod:`decimal` module will use
a pure-Python implementation.
See :option:`--with-system-libmpdec` for details.
.. [2] See :option:`--with-readline` for choosing the backend for the
:mod:`readline` module.
.. [3] The :mod:`uuid` module uses ``_uuid`` to generate "safe" UUIDs.
Expand Down Expand Up @@ -553,11 +552,6 @@ Options for third-party dependencies
C compiler and linker flags for ``libmpdec``, used by :mod:`decimal` module,
overriding ``pkg-config``.

.. note::

These environment variables have no effect unless
:option:`--with-system-libmpdec` is specified.

.. option:: LIBLZMA_CFLAGS
.. option:: LIBLZMA_LIBS

Expand Down Expand Up @@ -1067,29 +1061,6 @@ Libraries options
Build the :mod:`!pyexpat` module using an installed ``expat`` library
(default is no).

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

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.

.. versionchanged:: 3.15

A bundled copy of the library will no longer be selected
implicitly if an installed ``mpdecimal`` library is not found.
In Python 3.15 only, it can still be selected explicitly using
``--with-system-libmpdec=no`` or ``--without-system-libmpdec``.

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

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

.. option:: --with-readline=readline|editline

Designate a backend library for the :mod:`readline` module.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ Build Changes

.. _mimalloc library: https://github.com/microsoft/mimalloc/

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

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,7 @@ Build changes
=============

* Removed implicit fallback to the bundled copy of the ``libmpdec`` library.
Now this should be explicitly enabled with :option:`--with-system-libmpdec`
Now this should be explicitly enabled with :option:`!--with-system-libmpdec`
set to ``no`` or with :option:`!--without-system-libmpdec`.
(Contributed by Sergey B Kirpichev in :gh:`115119`.)

Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,12 @@ Deprecated C APIs

Removed C APIs
--------------

* Remove the bundled copy of the libmpdec_ decimal library from the CPython source tree
to simplify maintenence and updates. The :mod:`decimal` module will now
unconditionally use the system's libmpdec decimal library. Also remove the
now unused :option:`!--with-system-libmpdec` :program:`configure` flag.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably mention that binary distributions will still include the _decimal module with libmpdec compiled in.


(Contributed by Sergey B Kirpichev in :gh:`115119`.)

.. _libmpdec: https://www.bytereef.org/mpdecimal/
1 change: 0 additions & 1 deletion Mac/BuildScript/build-installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ def buildPython():
print(" NOTE: --with-mimalloc=no pending resolution of weak linking issues")
runCommand("%s -C --enable-framework --enable-universalsdk=/ "
"--with-mimalloc=no "
"--with-system-libmpdec "
"--with-universal-archs=%s "
"%s "
"%s "
Expand Down
96 changes: 0 additions & 96 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ RUNSHARED= @RUNSHARED@
ENSUREPIP= @ENSUREPIP@

# Internal static libraries
LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a
LIBEXPAT_A= Modules/expat/libexpat.a

# HACL* build configuration
Expand Down Expand Up @@ -606,45 +605,6 @@ LINK_PYTHON_OBJS=@LINK_PYTHON_OBJS@
DTRACE_DEPS = \
Python/ceval.o Python/gc.o Python/import.o Python/sysmodule.o

##########################################################################
# decimal's libmpdec

LIBMPDEC_OBJS= \
Modules/_decimal/libmpdec/basearith.o \
Modules/_decimal/libmpdec/constants.o \
Modules/_decimal/libmpdec/context.o \
Modules/_decimal/libmpdec/convolute.o \
Modules/_decimal/libmpdec/crt.o \
Modules/_decimal/libmpdec/difradix2.o \
Modules/_decimal/libmpdec/fnt.o \
Modules/_decimal/libmpdec/fourstep.o \
Modules/_decimal/libmpdec/io.o \
Modules/_decimal/libmpdec/mpalloc.o \
Modules/_decimal/libmpdec/mpdecimal.o \
Modules/_decimal/libmpdec/numbertheory.o \
Modules/_decimal/libmpdec/sixstep.o \
Modules/_decimal/libmpdec/transpose.o
# _decimal does not use signaling API
# Modules/_decimal/libmpdec/mpsignal.o

LIBMPDEC_HEADERS= \
$(srcdir)/Modules/_decimal/libmpdec/basearith.h \
$(srcdir)/Modules/_decimal/libmpdec/bits.h \
$(srcdir)/Modules/_decimal/libmpdec/constants.h \
$(srcdir)/Modules/_decimal/libmpdec/convolute.h \
$(srcdir)/Modules/_decimal/libmpdec/crt.h \
$(srcdir)/Modules/_decimal/libmpdec/difradix2.h \
$(srcdir)/Modules/_decimal/libmpdec/fnt.h \
$(srcdir)/Modules/_decimal/libmpdec/fourstep.h \
$(srcdir)/Modules/_decimal/libmpdec/io.h \
$(srcdir)/Modules/_decimal/libmpdec/mpalloc.h \
$(srcdir)/Modules/_decimal/libmpdec/mpdecimal.h \
$(srcdir)/Modules/_decimal/libmpdec/numbertheory.h \
$(srcdir)/Modules/_decimal/libmpdec/sixstep.h \
$(srcdir)/Modules/_decimal/libmpdec/transpose.h \
$(srcdir)/Modules/_decimal/libmpdec/typearith.h \
$(srcdir)/Modules/_decimal/libmpdec/umodarith.h

##########################################################################
# pyexpat's expat library

Expand Down Expand Up @@ -962,7 +922,6 @@ coverage-lcov:
@lcov $(COVERAGE_LCOV_OPTIONS) --remove $(COVERAGE_INFO) \
'*/Modules/_hacl/*' \
'*/Modules/_ctypes/libffi*/*' \
'*/Modules/_decimal/libmpdec/*' \
'*/Modules/expat/*' \
'*/Modules/xx*.c' \
'*/Python/pyfpe.c' \
Expand Down Expand Up @@ -1471,60 +1430,6 @@ PYTHON_HEADERS= \
\
$(srcdir)/Python/stdlib_module_names.h

##########################################################################
# Build static libmpdec.a
LIBMPDEC_CFLAGS=@LIBMPDEC_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)

# "%.o: %c" is not portable
Modules/_decimal/libmpdec/basearith.o: $(srcdir)/Modules/_decimal/libmpdec/basearith.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/basearith.c

Modules/_decimal/libmpdec/constants.o: $(srcdir)/Modules/_decimal/libmpdec/constants.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/constants.c

Modules/_decimal/libmpdec/context.o: $(srcdir)/Modules/_decimal/libmpdec/context.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/context.c

Modules/_decimal/libmpdec/convolute.o: $(srcdir)/Modules/_decimal/libmpdec/convolute.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/convolute.c

Modules/_decimal/libmpdec/crt.o: $(srcdir)/Modules/_decimal/libmpdec/crt.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/crt.c

Modules/_decimal/libmpdec/difradix2.o: $(srcdir)/Modules/_decimal/libmpdec/difradix2.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/difradix2.c

Modules/_decimal/libmpdec/fnt.o: $(srcdir)/Modules/_decimal/libmpdec/fnt.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/fnt.c

Modules/_decimal/libmpdec/fourstep.o: $(srcdir)/Modules/_decimal/libmpdec/fourstep.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/fourstep.c

Modules/_decimal/libmpdec/io.o: $(srcdir)/Modules/_decimal/libmpdec/io.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/io.c

Modules/_decimal/libmpdec/mpalloc.o: $(srcdir)/Modules/_decimal/libmpdec/mpalloc.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpalloc.c

Modules/_decimal/libmpdec/mpdecimal.o: $(srcdir)/Modules/_decimal/libmpdec/mpdecimal.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpdecimal.c

Modules/_decimal/libmpdec/mpsignal.o: $(srcdir)/Modules/_decimal/libmpdec/mpsignal.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/mpsignal.c

Modules/_decimal/libmpdec/numbertheory.o: $(srcdir)/Modules/_decimal/libmpdec/numbertheory.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/numbertheory.c

Modules/_decimal/libmpdec/sixstep.o: $(srcdir)/Modules/_decimal/libmpdec/sixstep.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/sixstep.c

Modules/_decimal/libmpdec/transpose.o: $(srcdir)/Modules/_decimal/libmpdec/transpose.c $(LIBMPDEC_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBMPDEC_CFLAGS) -o $@ $(srcdir)/Modules/_decimal/libmpdec/transpose.c

$(LIBMPDEC_A): $(LIBMPDEC_OBJS)
-rm -f $@
$(AR) $(ARFLAGS) $@ $(LIBMPDEC_OBJS)

##########################################################################
# Build static libexpat.a
LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
Expand Down Expand Up @@ -3501,7 +3406,6 @@ MODULE_UNICODEDATA_DEPS=$(srcdir)/Modules/unicodedata_db.h $(srcdir)/Modules/uni
MODULE__CTYPES_DEPS=$(srcdir)/Modules/_ctypes/ctypes.h
MODULE__CTYPES_TEST_DEPS=$(srcdir)/Modules/_ctypes/_ctypes_test_generated.c.h
MODULE__CTYPES_MALLOC_CLOSURE=@MODULE__CTYPES_MALLOC_CLOSURE@
MODULE__DECIMAL_DEPS=@LIBMPDEC_INTERNAL@
MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@
MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h
MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.12.0a2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ Fix ``make regen-test-levenshtein`` for out-of-tree builds.
.. nonce: eVXGEx
.. section: Build
Don't use vendored ``libmpdec`` headers if :option:`--with-system-libmpdec`
Don't use vendored ``libmpdec`` headers if :option:`!--with-system-libmpdec`
is passed to :program:`configure`. Don't use vendored ``libexpat`` headers
if :option:`--with-system-expat` is passed to :program:`configure`.

Expand Down
4 changes: 2 additions & 2 deletions Misc/NEWS.d/3.13.0b1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ script) without specifying a value for ``UseTIER2``.
.. nonce: LT27pF
.. section: Build
The :file:`configure` option :option:`--with-system-libmpdec` now defaults
The :file:`configure` option :option:`!--with-system-libmpdec` now defaults
to ``yes``. The bundled copy of ``libmpdecimal`` will be removed in Python
3.15.

Expand Down Expand Up @@ -1470,7 +1470,7 @@ Increase WASI stack size from 512 KiB to 8 MiB and the initial memory from
.. section: Build
:program:`configure` now uses :program:`pkg-config` to detect :mod:`decimal`
dependencies if the :option:`--with-system-libmpdec` option is given.
dependencies if the :option:`!--with-system-libmpdec` option is given.

..
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.15.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6395,7 +6395,7 @@ Add support for configuring compiler flags for the JIT with ``CFLAGS_JIT``
.. section: Build
Removed implicit fallback to the bundled copy of the ``libmpdec`` library.
Now this should be explicitly enabled via :option:`--with-system-libmpdec`
Now this should be explicitly enabled via :option:`!--with-system-libmpdec`
set to ``no`` or :option:`!--without-system-libmpdec`. Patch by Sergey B
Kirpichev.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removed bundled copy of the libmpdec, use system library if it's available.
Patch by Sergey B Kirpichev.
Loading
Loading