Skip to content

Commit c7e7bfc

Browse files
gh-115119: Detect _decimal dependencies using pkg-config (#115406)
pkg-config is supported for libmpdec 4.0.0 and newer.
1 parent ab6eda0 commit c7e7bfc

File tree

5 files changed

+211
-104
lines changed

5 files changed

+211
-104
lines changed

Doc/using/configure.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,17 @@ Options for third-party dependencies
389389
C compiler and linker flags for ``libffi``, used by :mod:`ctypes` module,
390390
overriding ``pkg-config``.
391391

392+
.. option:: LIBMPDEC_CFLAGS
393+
.. option:: LIBMPDEC_LIBS
394+
395+
C compiler and linker flags for ``libmpdec``, used by :mod:`decimal` module,
396+
overriding ``pkg-config``.
397+
398+
.. note::
399+
400+
These environment variables have no effect unless
401+
:option:`--with-system-libmpdec` is specified.
402+
392403
.. option:: LIBLZMA_CFLAGS
393404
.. option:: LIBLZMA_LIBS
394405

@@ -798,6 +809,8 @@ Libraries options
798809

799810
.. versionadded:: 3.3
800811

812+
.. seealso:: :option:`LIBMPDEC_CFLAGS` and :option:`LIBMPDEC_LIBS`.
813+
801814
.. option:: --with-readline=readline|editline
802815

803816
Designate a backend library for the :mod:`readline` module.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:program:`configure` now uses :program:`pkg-config` to detect :mod:`decimal`
2+
dependencies if the :option:`--with-system-libmpdec` option is given.

Modules/_decimal/_decimal.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,19 @@
3434
#include "pycore_pystate.h" // _PyThreadState_GET()
3535
#include "pycore_typeobject.h"
3636
#include "complexobject.h"
37-
#include "mpdecimal.h"
37+
38+
#include <mpdecimal.h>
39+
40+
// Reuse config from mpdecimal.h if present.
41+
#if defined(MPD_CONFIG_64)
42+
#ifndef CONFIG_64
43+
#define CONFIG_64 MPD_CONFIG_64
44+
#endif
45+
#elif defined(MPD_CONFIG_32)
46+
#ifndef CONFIG_32
47+
#define CONFIG_32 MPD_CONFIG_32
48+
#endif
49+
#endif
3850

3951
#include <ctype.h> // isascii()
4052
#include <stdlib.h>

configure

Lines changed: 118 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)