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

Side by Side Diff: setup.py

Issue 7652: Merge C version of decimal into py3k.
Patch Set: Created 7 years, 8 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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 )) 1334 ))
1335 else: 1335 else:
1336 missing.append('_elementtree') 1336 missing.append('_elementtree')
1337 1337
1338 # Hye-Shik Chang's CJKCodecs modules. 1338 # Hye-Shik Chang's CJKCodecs modules.
1339 exts.append(Extension('_multibytecodec', 1339 exts.append(Extension('_multibytecodec',
1340 ['cjkcodecs/multibytecodec.c'])) 1340 ['cjkcodecs/multibytecodec.c']))
1341 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): 1341 for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
1342 exts.append(Extension('_codecs_%s' % loc, 1342 exts.append(Extension('_codecs_%s' % loc,
1343 ['cjkcodecs/_codecs_%s.c' % loc])) 1343 ['cjkcodecs/_codecs_%s.c' % loc]))
1344
1345 # Stefan Krah's _decimal module
1346 exts.append(self._decimal_ext())
1344 1347
1345 # Thomas Heller's _ctypes module 1348 # Thomas Heller's _ctypes module
1346 self.detect_ctypes(inc_dirs, lib_dirs) 1349 self.detect_ctypes(inc_dirs, lib_dirs)
1347 1350
1348 # Richard Oudkerk's multiprocessing module 1351 # Richard Oudkerk's multiprocessing module
1349 if platform == 'win32': # Windows 1352 if platform == 'win32': # Windows
1350 macros = dict() 1353 macros = dict()
1351 libraries = ['ws2_32'] 1354 libraries = ['ws2_32']
1352 1355
1353 elif platform == 'darwin': # Mac OSX 1356 elif platform == 'darwin': # Mac OSX
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): 1788 for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'):
1786 if (self.compiler.find_library_file(lib_dirs, lib_name)): 1789 if (self.compiler.find_library_file(lib_dirs, lib_name)):
1787 ffi_lib = lib_name 1790 ffi_lib = lib_name
1788 break 1791 break
1789 1792
1790 if ffi_inc and ffi_lib: 1793 if ffi_inc and ffi_lib:
1791 ext.include_dirs.extend(ffi_inc) 1794 ext.include_dirs.extend(ffi_inc)
1792 ext.libraries.append(ffi_lib) 1795 ext.libraries.append(ffi_lib)
1793 self.use_system_libffi = True 1796 self.use_system_libffi = True
1794 1797
1798 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 ]
1835 config = {
1836 'x64': [('CONFIG_64','1'), ('ASM','1')],
1837 'uint128': [('CONFIG_64','1'), ('ANSI','1'), ('HAVE_UINT128_T','1')],
1838 'ansi64': [('CONFIG_64','1'), ('ANSI','1')],
1839 'ppro': [('CONFIG_32','1'), ('PPRO','1'), ('ASM','1')],
1840 'ansi32': [('CONFIG_32','1'), ('ANSI','1')],
1841 'ansi-legacy': [('CONFIG_32','1'), ('ANSI','1'),
1842 ('LEGACY_COMPILER','1')],
1843 'universal': [('UNIVERSAL','1')]
1844 }
1845
1846 include_dirs = ['./Modules/_decimal/libmpdec']
1847 extra_compile_args = []
1848 undef_macros=['NDEBUG']
1849
1850 platform = self.get_platform()
1851 cc = sysconfig.get_config_var('CC')
1852 sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T')
1853 machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE')
1854
1855 if machine:
1856 # Override automatic configuration to facilitate testing.
1857 define_macros = config[machine]
1858 elif platform == 'darwin':
1859 # Universal here means: build with the same options Python
1860 # was built with.
1861 define_macros = config['universal']
1862 elif sizeof_size_t == 8:
1863 if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'):
1864 define_macros = config['x64']
1865 elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'):
1866 define_macros = config['uint128']
1867 else:
1868 define_macros = config['ansi64']
1869 elif sizeof_size_t == 4:
1870 ppro = sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X87')
1871 if ppro and ('gcc' in cc or 'clang' in cc) and \
1872 not 'sunos' in platform:
1873 # solaris: problems with register allocation.
1874 # icc >= 11.0 works as well.
1875 define_macros = config['ppro']
1876 else:
1877 define_macros = config['ansi32']
1878 else:
1879 raise DistutilsError("_decimal: unsupported architecture")
1880
1881 # Workarounds for toolchain bugs:
1882 if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'):
1883 # Some versions of gcc miscompile inline asm:
1884 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
1885 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
1886 extra_compile_args.append('-fno-ipa-pure-const')
1887 if sysconfig.get_config_var('HAVE_GLIBC_MEMMOVE_BUG'):
1888 # _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
1889 # http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
1890 undef_macros.append('_FORTIFY_SOURCE')
1891
1892 # Faster version without thread local contexts:
1893 if not sysconfig.get_config_var('WITH_THREAD'):
1894 define_macros.append(('WITHOUT_THREADS', 1))
1895
1896 # Uncomment for extra functionality:
1897 #define_macros.append(('EXTRA_FUNCTIONALITY', 1))
1898 ext = Extension (
1899 '_decimal',
1900 include_dirs=include_dirs,
1901 define_macros=define_macros,
1902 undef_macros=undef_macros,
1903 extra_compile_args=extra_compile_args,
1904 sources=sources,
1905 depends=depends
1906 )
1907 return ext
1795 1908
1796 class PyBuildInstall(install): 1909 class PyBuildInstall(install):
1797 # Suppress the warning about installation into the lib_dynload 1910 # Suppress the warning about installation into the lib_dynload
1798 # directory, which is not in sys.path when running Python during 1911 # directory, which is not in sys.path when running Python during
1799 # installation: 1912 # installation:
1800 def initialize_options (self): 1913 def initialize_options (self):
1801 install.initialize_options(self) 1914 install.initialize_options(self)
1802 self.warn_dir=0 1915 self.warn_dir=0
1803 1916
1804 # Customize subcommands to not install an egg-info file for Python 1917 # Customize subcommands to not install an egg-info file for Python
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 # If you change the scripts installed here, you also need to 2032 # If you change the scripts installed here, you also need to
1920 # check the PyBuildScripts command above, and change the links 2033 # check the PyBuildScripts command above, and change the links
1921 # created by the bininstall target in Makefile.pre.in 2034 # created by the bininstall target in Makefile.pre.in
1922 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3", 2035 scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
1923 "Tools/scripts/2to3", "Tools/scripts/pysetup3"] 2036 "Tools/scripts/2to3", "Tools/scripts/pysetup3"]
1924 ) 2037 )
1925 2038
1926 # --install-platlib 2039 # --install-platlib
1927 if __name__ == '__main__': 2040 if __name__ == '__main__':
1928 main() 2041 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+