Skip to content

gh-115119: Removed bundled copy of the libmpdec #133964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
name: 'Check if generated files are up to date'
# Don't use ubuntu-latest but a specific version to make the job
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
timeout-minutes: 60
needs: build-context
if: needs.build-context.outputs.run-tests == 'true'
Expand All @@ -110,7 +110,9 @@ jobs:
# Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
key: ${{ github.job }}-${{ env.IMAGE_OS_VERSION }}-${{ needs.build-context.outputs.config-hash }}-${{ env.pythonLocation }}
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
run: |
sudo ./.github/workflows/posix-deps-apt.sh
sudo apt-get -yq install libmpdec-dev
- name: Add ccache to PATH
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
Expand Down
1 change: 0 additions & 1 deletion Doc/deprecations/c-api-pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Pending removal in Python 3.15
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* The bundled copy of ``libmpdecimal``.
* The :c:func:`!PyImport_ImportModuleNoBlock`:
Use :c:func:`PyImport_ImportModule` instead.
* :c:func:`PyWeakref_GetObject` and :c:func:`PyWeakref_GET_OBJECT`:
Expand Down
33 changes: 0 additions & 33 deletions Doc/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -975,39 +975,6 @@ on the cfuhash project::
OF THE POSSIBILITY OF SUCH DAMAGE.


libmpdec
--------

The :mod:`!_decimal` C extension underlying the :mod:`decimal` module
is built using an included copy of the libmpdec
library unless the build is configured ``--with-system-libmpdec``::

Copyright (c) 2008-2020 Stefan Krah. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.


W3C C14N test suite
-------------------

Expand Down
21 changes: 0 additions & 21 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,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 @@ -835,22 +830,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.

.. 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`.
Comment on lines -838 to -852
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's worth keeping a mention of --with-system-libmpdec, just for the purpose of saying it's been removed? Unsure though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this something that expected for removed stuff?

I see one removed option, --with-wctype-functions - it's only in whatsnew.


.. 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 @@ -2575,7 +2575,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 ``libmpdecimal`` will be removed in Python 3.15.

Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ that may require changes to your code.
Build changes
=============

* Remove the bundled 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.

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

.. _libmpdec: https://www.bytereef.org/mpdecimal/


C API changes
=============
Expand Down
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
97 changes: 1 addition & 96 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,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 @@ -589,45 +588,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 @@ -945,7 +905,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 @@ -1409,60 +1368,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 @@ -3321,7 +3226,7 @@ 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=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@
MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h
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
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