Skip to content

Commit

Permalink
gh-115119: Detect _decimal dependencies using pkg-config (#115406)
Browse files Browse the repository at this point in the history
pkg-config is supported for libmpdec 4.0.0 and newer.
  • Loading branch information
erlend-aasland authored Apr 29, 2024
1 parent ab6eda0 commit c7e7bfc
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 104 deletions.
13 changes: 13 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,17 @@ Options for third-party dependencies
C compiler and linker flags for ``libffi``, used by :mod:`ctypes` module,
overriding ``pkg-config``.

.. option:: LIBMPDEC_CFLAGS
.. option:: LIBMPDEC_LIBS

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 @@ -798,6 +809,8 @@ Libraries options

.. versionadded:: 3.3

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

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

Designate a backend library for the :mod:`readline` module.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:program:`configure` now uses :program:`pkg-config` to detect :mod:`decimal`
dependencies if the :option:`--with-system-libmpdec` option is given.
14 changes: 13 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_typeobject.h"
#include "complexobject.h"
#include "mpdecimal.h"

#include <mpdecimal.h>

// Reuse config from mpdecimal.h if present.
#if defined(MPD_CONFIG_64)
#ifndef CONFIG_64
#define CONFIG_64 MPD_CONFIG_64
#endif
#elif defined(MPD_CONFIG_32)
#ifndef CONFIG_32
#define CONFIG_32 MPD_CONFIG_32
#endif
#endif

#include <ctype.h> // isascii()
#include <stdlib.h>
Expand Down
159 changes: 118 additions & 41 deletions configure

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

Loading

0 comments on commit c7e7bfc

Please sign in to comment.