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

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