Skip to content

Commit 60187b5

Browse files
author
Stefan Krah
committed
Issue #7652: Enable linking of _decimal.so against an installed libmpdec.
1 parent 0175af8 commit 60187b5

4 files changed

Lines changed: 78 additions & 40 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Core and Builtins
3434
Library
3535
-------
3636

37+
- Issue #7652: Add --with-system-libmpdec option to configure for linking
38+
the _decimal module against an installed libmpdec.
39+
3740
- Issue #14380: MIMEText now defaults to utf-8 when passed non-ASCII unicode
3841
with no charset specified.
3942

configure

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ with_pydebug
762762
with_libs
763763
with_system_expat
764764
with_system_ffi
765+
with_system_libmpdec
765766
enable_loadable_sqlite_extensions
766767
with_dbmliborder
767768
with_signal_module
@@ -1434,6 +1435,8 @@ Optional Packages:
14341435
--with-system-expat build pyexpat module using an installed expat
14351436
library
14361437
--with-system-ffi build _ctypes module using an installed ffi library
1438+
--with-system-libmpdec build _decimal module using an installed libmpdec
1439+
library
14371440
--with-dbmliborder=db1:db2:...
14381441
order to check db backends for dbm. Valid value is a
14391442
colon separated string with the backend names
@@ -8501,6 +8504,21 @@ fi
85018504
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_ffi" >&5
85028505
$as_echo "$with_system_ffi" >&6; }
85038506

8507+
# Check for use of the system libmpdec library
8508+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-libmpdec" >&5
8509+
$as_echo_n "checking for --with-system-libmpdec... " >&6; }
8510+
8511+
# Check whether --with-system_libmpdec was given.
8512+
if test "${with_system_libmpdec+set}" = set; then :
8513+
withval=$with_system_libmpdec;
8514+
else
8515+
with_system_libmpdec="no"
8516+
fi
8517+
8518+
8519+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_libmpdec" >&5
8520+
$as_echo "$with_system_libmpdec" >&6; }
8521+
85048522
# Check for support for loadable sqlite extensions
85058523
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-loadable-sqlite-extensions" >&5
85068524
$as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; }

configure.ac

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,15 @@ AC_SUBST(LIBFFI_INCLUDEDIR)
20482048

20492049
AC_MSG_RESULT($with_system_ffi)
20502050

2051+
# Check for use of the system libmpdec library
2052+
AC_MSG_CHECKING(for --with-system-libmpdec)
2053+
AC_ARG_WITH(system_libmpdec,
2054+
AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library]),
2055+
[],
2056+
[with_system_libmpdec="no"])
2057+
2058+
AC_MSG_RESULT($with_system_libmpdec)
2059+
20512060
# Check for support for loadable sqlite extensions
20522061
AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
20532062
AC_ARG_ENABLE(loadable-sqlite-extensions,

setup.py

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,42 +1796,53 @@ def detect_ctypes(self, inc_dirs, lib_dirs):
17961796
self.use_system_libffi = True
17971797

17981798
def _decimal_ext(self):
1799-
sources = [
1800-
'_decimal/_decimal.c',
1801-
'_decimal/libmpdec/basearith.c',
1802-
'_decimal/libmpdec/constants.c',
1803-
'_decimal/libmpdec/context.c',
1804-
'_decimal/libmpdec/convolute.c',
1805-
'_decimal/libmpdec/crt.c',
1806-
'_decimal/libmpdec/difradix2.c',
1807-
'_decimal/libmpdec/fnt.c',
1808-
'_decimal/libmpdec/fourstep.c',
1809-
'_decimal/libmpdec/io.c',
1810-
'_decimal/libmpdec/memory.c',
1811-
'_decimal/libmpdec/mpdecimal.c',
1812-
'_decimal/libmpdec/numbertheory.c',
1813-
'_decimal/libmpdec/sixstep.c',
1814-
'_decimal/libmpdec/transpose.c',
1815-
]
1816-
depends = [
1817-
'_decimal/docstrings.h',
1818-
'_decimal/libmpdec/basearith.h',
1819-
'_decimal/libmpdec/bits.h',
1820-
'_decimal/libmpdec/constants.h',
1821-
'_decimal/libmpdec/convolute.h',
1822-
'_decimal/libmpdec/crt.h',
1823-
'_decimal/libmpdec/difradix2.h',
1824-
'_decimal/libmpdec/fnt.h',
1825-
'_decimal/libmpdec/fourstep.h',
1826-
'_decimal/libmpdec/io.h',
1827-
'_decimal/libmpdec/memory.h',
1828-
'_decimal/libmpdec/mpdecimal.h',
1829-
'_decimal/libmpdec/numbertheory.h',
1830-
'_decimal/libmpdec/sixstep.h',
1831-
'_decimal/libmpdec/transpose.h',
1832-
'_decimal/libmpdec/typearith.h',
1833-
'_decimal/libmpdec/umodarith.h',
1834-
]
1799+
extra_compile_args = []
1800+
undef_macros=['NDEBUG']
1801+
if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"):
1802+
include_dirs = []
1803+
libraries = ['mpdec']
1804+
sources = ['_decimal/_decimal.c']
1805+
depends = ['_decimal/docstrings.h']
1806+
else:
1807+
include_dirs = ['./Modules/_decimal/libmpdec']
1808+
libraries = []
1809+
sources = [
1810+
'_decimal/_decimal.c',
1811+
'_decimal/libmpdec/basearith.c',
1812+
'_decimal/libmpdec/constants.c',
1813+
'_decimal/libmpdec/context.c',
1814+
'_decimal/libmpdec/convolute.c',
1815+
'_decimal/libmpdec/crt.c',
1816+
'_decimal/libmpdec/difradix2.c',
1817+
'_decimal/libmpdec/fnt.c',
1818+
'_decimal/libmpdec/fourstep.c',
1819+
'_decimal/libmpdec/io.c',
1820+
'_decimal/libmpdec/memory.c',
1821+
'_decimal/libmpdec/mpdecimal.c',
1822+
'_decimal/libmpdec/numbertheory.c',
1823+
'_decimal/libmpdec/sixstep.c',
1824+
'_decimal/libmpdec/transpose.c',
1825+
]
1826+
depends = [
1827+
'_decimal/docstrings.h',
1828+
'_decimal/libmpdec/basearith.h',
1829+
'_decimal/libmpdec/bits.h',
1830+
'_decimal/libmpdec/constants.h',
1831+
'_decimal/libmpdec/convolute.h',
1832+
'_decimal/libmpdec/crt.h',
1833+
'_decimal/libmpdec/difradix2.h',
1834+
'_decimal/libmpdec/fnt.h',
1835+
'_decimal/libmpdec/fourstep.h',
1836+
'_decimal/libmpdec/io.h',
1837+
'_decimal/libmpdec/memory.h',
1838+
'_decimal/libmpdec/mpdecimal.h',
1839+
'_decimal/libmpdec/numbertheory.h',
1840+
'_decimal/libmpdec/sixstep.h',
1841+
'_decimal/libmpdec/transpose.h',
1842+
'_decimal/libmpdec/typearith.h',
1843+
'_decimal/libmpdec/umodarith.h',
1844+
]
1845+
18351846
config = {
18361847
'x64': [('CONFIG_64','1'), ('ASM','1')],
18371848
'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
@@ -1843,10 +1854,6 @@ def _decimal_ext(self):
18431854
'universal': [('UNIVERSAL','1')]
18441855
}
18451856

1846-
include_dirs = ['./Modules/_decimal/libmpdec']
1847-
extra_compile_args = []
1848-
undef_macros=['NDEBUG']
1849-
18501857
platform = self.get_platform()
18511858
cc = sysconfig.get_config_var('CC')
18521859
sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
@@ -1898,6 +1905,7 @@ def _decimal_ext(self):
18981905
ext = Extension (
18991906
'_decimal',
19001907
include_dirs=include_dirs,
1908+
libraries=libraries,
19011909
define_macros=define_macros,
19021910
undef_macros=undef_macros,
19031911
extra_compile_args=extra_compile_args,

0 commit comments

Comments
 (0)