summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-03-23 18:06:27 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-03-23 18:06:27 (GMT)
commit60187b5ee5119094b52f11d7cdc742d1c36403ea (patch)
treef6ed3b09374028283723a844c4b5ad0bc76d5682 /setup.py
parent0175af85a574800d8ea44e57fc9c0810edf2d0e1 (diff)
downloadcpython-60187b5ee5119094b52f11d7cdc742d1c36403ea.zip
cpython-60187b5ee5119094b52f11d7cdc742d1c36403ea.tar.gz
cpython-60187b5ee5119094b52f11d7cdc742d1c36403ea.tar.bz2
Issue #7652: Enable linking of _decimal.so against an installed libmpdec.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py88
1 files changed, 48 insertions, 40 deletions
diff --git a/setup.py b/setup.py
index 6c8d378..eae1b85 100644
--- a/setup.py
+++ b/setup.py
@@ -1796,42 +1796,53 @@ class PyBuildExt(build_ext):
self.use_system_libffi = True
def _decimal_ext(self):
- sources = [
- '_decimal/_decimal.c',
- '_decimal/libmpdec/basearith.c',
- '_decimal/libmpdec/constants.c',
- '_decimal/libmpdec/context.c',
- '_decimal/libmpdec/convolute.c',
- '_decimal/libmpdec/crt.c',
- '_decimal/libmpdec/difradix2.c',
- '_decimal/libmpdec/fnt.c',
- '_decimal/libmpdec/fourstep.c',
- '_decimal/libmpdec/io.c',
- '_decimal/libmpdec/memory.c',
- '_decimal/libmpdec/mpdecimal.c',
- '_decimal/libmpdec/numbertheory.c',
- '_decimal/libmpdec/sixstep.c',
- '_decimal/libmpdec/transpose.c',
- ]
- depends = [
- '_decimal/docstrings.h',
- '_decimal/libmpdec/basearith.h',
- '_decimal/libmpdec/bits.h',
- '_decimal/libmpdec/constants.h',
- '_decimal/libmpdec/convolute.h',
- '_decimal/libmpdec/crt.h',
- '_decimal/libmpdec/difradix2.h',
- '_decimal/libmpdec/fnt.h',
- '_decimal/libmpdec/fourstep.h',
- '_decimal/libmpdec/io.h',
- '_decimal/libmpdec/memory.h',
- '_decimal/libmpdec/mpdecimal.h',
- '_decimal/libmpdec/numbertheory.h',
- '_decimal/libmpdec/sixstep.h',
- '_decimal/libmpdec/transpose.h',
- '_decimal/libmpdec/typearith.h',
- '_decimal/libmpdec/umodarith.h',
- ]
+ extra_compile_args = []
+ undef_macros=['NDEBUG']
+ if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"):
+ include_dirs = []
+ libraries = ['mpdec']
+ sources = ['_decimal/_decimal.c']
+ depends = ['_decimal/docstrings.h']
+ else:
+ include_dirs = ['./Modules/_decimal/libmpdec']
+ libraries = []
+ sources = [
+ '_decimal/_decimal.c',
+ '_decimal/libmpdec/basearith.c',
+ '_decimal/libmpdec/constants.c',
+ '_decimal/libmpdec/context.c',
+ '_decimal/libmpdec/convolute.c',
+ '_decimal/libmpdec/crt.c',
+ '_decimal/libmpdec/difradix2.c',
+ '_decimal/libmpdec/fnt.c',
+ '_decimal/libmpdec/fourstep.c',
+ '_decimal/libmpdec/io.c',
+ '_decimal/libmpdec/memory.c',
+ '_decimal/libmpdec/mpdecimal.c',
+ '_decimal/libmpdec/numbertheory.c',
+ '_decimal/libmpdec/sixstep.c',
+ '_decimal/libmpdec/transpose.c',
+ ]
+ depends = [
+ '_decimal/docstrings.h',
+ '_decimal/libmpdec/basearith.h',
+ '_decimal/libmpdec/bits.h',
+ '_decimal/libmpdec/constants.h',
+ '_decimal/libmpdec/convolute.h',
+ '_decimal/libmpdec/crt.h',
+ '_decimal/libmpdec/difradix2.h',
+ '_decimal/libmpdec/fnt.h',
+ '_decimal/libmpdec/fourstep.h',
+ '_decimal/libmpdec/io.h',
+ '_decimal/libmpdec/memory.h',
+ '_decimal/libmpdec/mpdecimal.h',
+ '_decimal/libmpdec/numbertheory.h',
+ '_decimal/libmpdec/sixstep.h',
+ '_decimal/libmpdec/transpose.h',
+ '_decimal/libmpdec/typearith.h',
+ '_decimal/libmpdec/umodarith.h',
+ ]
+
config = {
'x64': [('CONFIG_64','1'), ('ASM','1')],
'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
@@ -1843,10 +1854,6 @@ class PyBuildExt(build_ext):
'universal': [('UNIVERSAL','1')]
}
- include_dirs = ['./Modules/_decimal/libmpdec']
- extra_compile_args = []
- undef_macros=['NDEBUG']
-
platform = self.get_platform()
cc = sysconfig.get_config_var('CC')
sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
@@ -1898,6 +1905,7 @@ class PyBuildExt(build_ext):
ext = Extension (
'_decimal',
include_dirs=include_dirs,
+ libraries=libraries,
define_macros=define_macros,
undef_macros=undef_macros,
extra_compile_args=extra_compile_args,