Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(195200)

Unified Diff: setup.py

Issue 7652: Merge C version of decimal into py3k.
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pyconfig.h.in ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/setup.py Tue Dec 13 15:53:47 2011 +0200
+++ b/setup.py Thu Feb 23 16:43:15 2012 +0100
@@ -1340,6 +1340,9 @@
exts.append(Extension('_codecs_%s' % loc,
['cjkcodecs/_codecs_%s.c' % loc]))
+ # Stefan Krah's _decimal module
+ exts.append(self._decimal_ext())
+
# Thomas Heller's _ctypes module
self.detect_ctypes(inc_dirs, lib_dirs)
@@ -1790,6 +1793,113 @@
ext.libraries.append(ffi_lib)
self.use_system_libffi = True
+ def _decimal_ext(self):
+ sources = [
+ '_decimal/_decimal.c',
+ '_decimal/basearith.c',
+ '_decimal/constants.c',
+ '_decimal/context.c',
+ '_decimal/convolute.c',
+ '_decimal/crt.c',
+ '_decimal/difradix2.c',
+ '_decimal/fnt.c',
+ '_decimal/fourstep.c',
+ '_decimal/io.c',
+ '_decimal/memory.c',
+ '_decimal/mpdecimal.c',
+ '_decimal/numbertheory.c',
+ '_decimal/sixstep.c',
+ '_decimal/transpose.c',
+ ]
+ depends = [
+ '_decimal/basearith.h',
+ '_decimal/bits.h',
+ '_decimal/constants.h',
+ '_decimal/convolute.h',
+ '_decimal/crt.h',
+ '_decimal/difradix2.h',
+ '_decimal/docstrings.h',
+ '_decimal/fnt.h',
+ '_decimal/fourstep.h',
+ '_decimal/io.h',
+ '_decimal/memory.h',
+ '_decimal/mpdecimal.h',
+ '_decimal/mptypes.h',
+ '_decimal/numbertheory.h',
+ '_decimal/sixstep.h',
+ '_decimal/transpose.h',
+ '_decimal/typearith.h',
+ '_decimal/umodarith.h',
+ ]
+ config = {
+ 'x64': [('CONFIG_64','1'), ('ASM','1')],
+ 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
+ 'ansi64': [('CONFIG_64','1'), ('ANSI','1')],
+ 'ppro': [('CONFIG_32','1'), ('PPRO','1'), ('ASM','1')],
+ 'ansi32': [('CONFIG_32','1'), ('ANSI','1')],
+ 'ansi-legacy': [('CONFIG_32','1'), ('ANSI','1'),
+ ('LEGACY_COMPILER','1')],
+ 'universal': [('UNIVERSAL','1')]
+ }
+
+ 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')
+ machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE')
+
+ if machine:
+ # Override automatic configuration to facilitate testing.
+ define_macros = config[machine]
+ elif platform == 'darwin':
+ # Universal here means: build with the same options Python
+ # was built with.
+ define_macros = config['universal']
+ elif sizeof_size_t == 8:
+ if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'):
+ define_macros = config['x64']
+ elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'):
+ define_macros = config['uint128']
+ else:
+ define_macros = config['ansi64']
+ elif sizeof_size_t == 4:
+ ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87')
+ if ppro and ('gcc' in cc or 'clang' in cc) and \
+ not 'sunos' in platform:
+ # solaris: problems with register allocation.
+ # icc >= 11.0 works as well.
+ define_macros = config['ppro']
+ else:
+ define_macros = config['ansi32']
+ else:
+ raise DistutilsError("_decimal: unsupported architecture")
+
+ # Workarounds for toolchain bugs:
+ if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'):
+ # Some versions of gcc miscompile inline asm:
+ # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
+ # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
+ extra_compile_args.append('-fno-ipa-pure-const')
+ if sysconfig.get_config_var('HAVE_GLIBC_MEMMOVE_BUG'):
+ # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
+ # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
+ undef_macros.append('_FORTIFY_SOURCE')
+
+ # Faster version without thread local contexts:
+ if not sysconfig.get_config_var('WITH_THREAD'):
+ define_macros.append(('WITHOUT_THREADS', 1))
+
+ ext = Extension (
+ '_decimal',
+ define_macros=define_macros,
+ undef_macros=undef_macros,
+ extra_compile_args=extra_compile_args,
+ sources=sources,
+ depends=depends
+ )
+ return ext
class PyBuildInstall(install):
# Suppress the warning about installation into the lib_dynload
« no previous file with comments | « pyconfig.h.in ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+