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

Side by Side Diff: setup.py

Issue 7652: Merge C version of decimal into py3k.
Patch Set: Created 8 years, 4 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « pyconfig.h.in ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Autodetecting setup.py script for building the Python extensions 1 # Autodetecting setup.py script for building the Python extensions
2 # 2 #
3 3
4 import sys, os, imp, re, optparse 4 import sys, os, imp, re, optparse
5 from glob import glob 5 from glob import glob
6 import sysconfig 6 import sysconfig
7 7
8 from distutils import log 8 from distutils import log
9 from distutils import text_file 9 from distutils import text_file
10 from distutils.errors import * 10 from distutils.errors import *
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 )) 1316 ))
1317 else: 1317 else:
1318 missing.append('_elementtree') 1318 missing.append('_elementtree')
1319 1319
1320 # Hye-Shik Chang's CJKCodecs modules. 1320 # Hye-Shik Chang's CJKCodecs modules.
1321 exts.append(Extension('_multibytecodec', 1321 exts.append(Extension('_multibytecodec',
1322 ['cjkcodecs/multibytecodec.c'])) 1322 ['cjkcodecs/multibytecodec.c']))
1323 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): 1323 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
1324 exts.append(Extension('_codecs_%s' % loc, 1324 exts.append(Extension('_codecs_%s' % loc,
1325 ['cjkcodecs/_codecs_%s.c' % loc])) 1325 ['cjkcodecs/_codecs_%s.c' % loc]))
1326
1327 # Stefan Krah's _decimal module
1328 exts.append(self._decimal_ext())
1326 1329
1327 # Thomas Heller's _ctypes module 1330 # Thomas Heller's _ctypes module
1328 self.detect_ctypes(inc_dirs, lib_dirs) 1331 self.detect_ctypes(inc_dirs, lib_dirs)
1329 1332
1330 # Richard Oudkerk's multiprocessing module 1333 # Richard Oudkerk's multiprocessing module
1331 if platform == 'win32': # Windows 1334 if platform == 'win32': # Windows
1332 macros = dict() 1335 macros = dict()
1333 libraries = ['ws2_32'] 1336 libraries = ['ws2_32']
1334 1337
1335 elif platform == 'darwin': # Mac OSX 1338 elif platform == 'darwin': # Mac OSX
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): 1771 for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'):
1769 if (self.compiler.find_library_file(lib_dirs, lib_name)): 1772 if (self.compiler.find_library_file(lib_dirs, lib_name)):
1770 ffi_lib = lib_name 1773 ffi_lib = lib_name
1771 break 1774 break
1772 1775
1773 if ffi_inc and ffi_lib: 1776 if ffi_inc and ffi_lib:
1774 ext.include_dirs.extend(ffi_inc) 1777 ext.include_dirs.extend(ffi_inc)
1775 ext.libraries.append(ffi_lib) 1778 ext.libraries.append(ffi_lib)
1776 self.use_system_libffi = True 1779 self.use_system_libffi = True
1777 1780
1781 def _decimal_ext(self):
1782 sources = [
1783 '_decimal/_decimal.c',
1784 '_decimal/basearith.c',
1785 '_decimal/constants.c',
1786 '_decimal/context.c',
1787 '_decimal/convolute.c',
1788 '_decimal/crt.c',
1789 '_decimal/difradix2.c',
1790 '_decimal/fnt.c',
1791 '_decimal/fourstep.c',
1792 '_decimal/io.c',
1793 '_decimal/memory.c',
1794 '_decimal/mpdecimal.c',
1795 '_decimal/numbertheory.c',
1796 '_decimal/sixstep.c',
1797 '_decimal/transpose.c',
1798 ]
1799 depends = [
1800 '_decimal/basearith.h',
1801 '_decimal/bits.h',
1802 '_decimal/constants.h',
1803 '_decimal/convolute.h',
1804 '_decimal/crt.h',
1805 '_decimal/difradix2.h',
1806 '_decimal/docstrings.h',
1807 '_decimal/fnt.h',
1808 '_decimal/fourstep.h',
1809 '_decimal/io.h',
1810 '_decimal/memory.h',
1811 '_decimal/mpdecimal.h',
1812 '_decimal/mptypes.h',
1813 '_decimal/numbertheory.h',
1814 '_decimal/sixstep.h',
1815 '_decimal/transpose.h',
1816 '_decimal/typearith.h',
1817 '_decimal/umodarith.h',
1818 ]
1819 config = {
1820 'x64': [('CONFIG_64','1'), ('ASM','1')],
1821 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
1822 'ansi64': [('CONFIG_64','1'), ('ANSI','1')],
1823 'ppro': [('CONFIG_32','1'), ('PPRO','1'), ('ASM','1')],
1824 'ansi32': [('CONFIG_32','1'), ('ANSI','1')],
1825 'ansi-legacy': [('CONFIG_32','1'), ('ANSI','1'),
1826 ('LEGACY_COMPILER','1')],
1827 'universal': [('UNIVERSAL','1')]
1828 }
1829
1830 extra_compile_args = []
1831 undef_macros=['NDEBUG']
1832
1833 platform = self.get_platform()
1834 cc = sysconfig.get_config_var('CC')
1835 sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
1836 machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE')
1837
1838 if machine:
1839 # Override automatic configuration to facilitate testing.
1840 define_macros = config[machine]
1841 elif platform == 'darwin':
1842 # Universal here means: build with the same options Python
1843 # was built with.
1844 define_macros = config['universal']
1845 elif sizeof_size_t == 8:
1846 if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'):
1847 define_macros = config['x64']
1848 elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'):
1849 define_macros = config['uint128']
1850 else:
1851 define_macros = config['ansi64']
1852 elif sizeof_size_t == 4:
1853 ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87')
1854 if ppro and ('gcc' in cc or 'clang' in cc) and \
1855 not 'sunos' in platform:
1856 # solaris: problems with register allocation.
1857 # icc >= 11.0 works as well.
1858 define_macros = config['ppro']
1859 else:
1860 define_macros = config['ansi32']
1861 else:
1862 raise DistutilsError("_decimal: unsupported architecture")
1863
1864 # Workarounds for toolchain bugs:
1865 if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'):
1866 # Some versions of gcc miscompile inline asm:
1867 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
1868 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
1869 extra_compile_args.append('-fno-ipa-pure-const')
1870 if sysconfig.get_config_var('HAVE_GLIBC_MEMMOVE_BUG'):
1871 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
1872 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
1873 undef_macros.append('_FORTIFY_SOURCE')
1874
1875 # Faster version without thread local contexts:
1876 if not sysconfig.get_config_var('WITH_THREAD'):
1877 define_macros.append(('WITHOUT_THREADS', 1))
1878
1879 ext = Extension (
1880 '_decimal',
1881 define_macros=define_macros,
1882 undef_macros=undef_macros,
1883 extra_compile_args=extra_compile_args,
1884 sources=sources,
1885 depends=depends
1886 )
1887 return ext
1778 1888
1779 class PyBuildInstall(install): 1889 class PyBuildInstall(install):
1780 # Suppress the warning about installation into the lib_dynload 1890 # Suppress the warning about installation into the lib_dynload
1781 # directory, which is not in sys.path when running Python during 1891 # directory, which is not in sys.path when running Python during
1782 # installation: 1892 # installation:
1783 def initialize_options (self): 1893 def initialize_options (self):
1784 install.initialize_options(self) 1894 install.initialize_options(self)
1785 self.warn_dir=0 1895 self.warn_dir=0
1786 1896
1787 # Customize subcommands to not install an egg-info file for Python 1897 # Customize subcommands to not install an egg-info file for Python
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 # If you change the scripts installed here, you also need to 2012 # If you change the scripts installed here, you also need to
1903 # check the PyBuildScripts command above, and change the links 2013 # check the PyBuildScripts command above, and change the links
1904 # created by the bininstall target in Makefile.pre.in 2014 # created by the bininstall target in Makefile.pre.in
1905 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", 2015 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
1906 "Tools/scripts/2to3", "Tools/scripts/pysetup3"] 2016 "Tools/scripts/2to3", "Tools/scripts/pysetup3"]
1907 ) 2017 )
1908 2018
1909 # --install-platlib 2019 # --install-platlib
1910 if __name__ == '__main__': 2020 if __name__ == '__main__':
1911 main() 2021 main()
OLDNEW
« 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+