diff -r 20dd07abde5b -r 38f5b3beeb2a setup.py --- a/setup.py Thu Mar 19 15:04:40 2015 -0500 +++ b/setup.py Thu Mar 19 15:16:03 2015 -0500 @@ -570,6 +570,8 @@ # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] + # Android needs the -libc, -libm, -libdl and -libpython3.4m explicitly linked + sys_libs = ['c', 'dl', 'm', 'python3.4m'] if host_platform == 'darwin': math_libs = [] @@ -581,88 +583,89 @@ # # array objects - exts.append( Extension('array', ['arraymodule.c']) ) + exts.append( Extension('array', ['arraymodule.c'], libraries=sys_libs) ) # complex math library functions exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'], depends=['_math.h'], - libraries=math_libs) ) + libraries=sys_libs) ) # math library functions, e.g. sin() exts.append( Extension('math', ['mathmodule.c', '_math.c'], depends=['_math.h'], - libraries=math_libs) ) + libraries=sys_libs) ) # time libraries: librt may be needed for clock_gettime() # floatsleep() needs math_libs for fmod() and floor() - time_libs = list(math_libs) + # for Android we want sys_libs, which includes math_libs + time_libs = [] lib = sysconfig.get_config_var('TIMEMODULE_LIB') if lib: time_libs.append(lib) # time operations and variables exts.append( Extension('time', ['timemodule.c'], - libraries=time_libs) ) - exts.append( Extension('_datetime', ['_datetimemodule.c']) ) + libraries=sys_libs) ) + exts.append( Extension('_datetime', ['_datetimemodule.c'], libraries=sys_libs) ) # random number generator implemented in C - exts.append( Extension("_random", ["_randommodule.c"]) ) + exts.append( Extension("_random", ["_randommodule.c"], libraries=sys_libs) ) # bisect - exts.append( Extension("_bisect", ["_bisectmodule.c"]) ) + exts.append( Extension("_bisect", ["_bisectmodule.c"], libraries=sys_libs) ) # heapq - exts.append( Extension("_heapq", ["_heapqmodule.c"]) ) + exts.append( Extension("_heapq", ["_heapqmodule.c"], libraries=sys_libs) ) # C-optimized pickle replacement - exts.append( Extension("_pickle", ["_pickle.c"]) ) + exts.append( Extension("_pickle", ["_pickle.c"], libraries=sys_libs) ) # atexit - exts.append( Extension("atexit", ["atexitmodule.c"]) ) + exts.append( Extension("atexit", ["atexitmodule.c"], libraries=sys_libs) ) # _json speedups - exts.append( Extension("_json", ["_json.c"]) ) + exts.append( Extension("_json", ["_json.c"], libraries=sys_libs) ) # Python C API test module exts.append( Extension('_testcapi', ['_testcapimodule.c'], - depends=['testcapi_long.h']) ) + depends=['testcapi_long.h'], libraries=sys_libs) ) # Python PEP-3118 (buffer protocol) test module - exts.append( Extension('_testbuffer', ['_testbuffer.c']) ) + exts.append( Extension('_testbuffer', ['_testbuffer.c'], libraries=sys_libs) ) # Test loading multiple modules from one compiled file (http://bugs.python.org/issue16421) - exts.append( Extension('_testimportmultiple', ['_testimportmultiple.c']) ) + exts.append( Extension('_testimportmultiple', ['_testimportmultiple.c'], libraries=sys_libs) ) # profiler (_lsprof is for cProfile.py) - exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) ) + exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c'], libraries=sys_libs) ) # static Unicode character database - exts.append( Extension('unicodedata', ['unicodedata.c']) ) + exts.append( Extension('unicodedata', ['unicodedata.c'], libraries=sys_libs) ) # _opcode module - exts.append( Extension('_opcode', ['_opcode.c']) ) + exts.append( Extension('_opcode', ['_opcode.c'], libraries=sys_libs) ) # Modules with some UNIX dependencies -- on by default: # (If you have a really backward UNIX, select and socket may not be # supported...) # fcntl(2) and ioctl(2) - libs = [] + libs = ['c', 'dl'] if (config_h_vars.get('FLOCK_NEEDS_LIBBSD', False)): # May be necessary on AIX for flock function - libs = ['bsd'] + libs = ['c', 'dl', 'bsd'] exts.append( Extension('fcntl', ['fcntlmodule.c'], libraries=libs) ) # pwd(3) - exts.append( Extension('pwd', ['pwdmodule.c']) ) + exts.append( Extension('pwd', ['pwdmodule.c'], libraries=sys_libs) ) # grp(3) - exts.append( Extension('grp', ['grpmodule.c']) ) + exts.append( Extension('grp', ['grpmodule.c'], libraries=sys_libs) ) # spwd, shadow passwords if (config_h_vars.get('HAVE_GETSPNAM', False) or config_h_vars.get('HAVE_GETSPENT', False)): - exts.append( Extension('spwd', ['spwdmodule.c']) ) + exts.append( Extension('spwd', ['spwdmodule.c'], libraries=sys_libs) ) else: missing.append('spwd') # select(2); not on ancient System V # pyepoll_poll needs math_libs for ceil() exts.append( Extension('select', ['selectmodule.c'], - libraries=math_libs) ) + libraries=sys_libs) ) # Fred Drake's interface to the Python parser - exts.append( Extension('parser', ['parsermodule.c']) ) + exts.append( Extension('parser', ['parsermodule.c'], libraries=sys_libs) ) # Memory-mapped files (also works on Win32). - exts.append( Extension('mmap', ['mmapmodule.c']) ) + exts.append( Extension('mmap', ['mmapmodule.c'], libraries=sys_libs) ) # Lance Ellinghaus's syslog module # syslog daemon interface - exts.append( Extension('syslog', ['syslogmodule.c']) ) + exts.append( Extension('syslog', ['syslogmodule.c'], libraries=sys_libs) ) # # Here ends the simple stuff. From here on, modules need certain @@ -678,7 +681,7 @@ # 64-bit platforms. # audioop needs math_libs for floor() in multiple functions. exts.append( Extension('audioop', ['audioop.c'], - libraries=math_libs) ) + libraries=sys_libs) ) # readline do_readline = self.compiler.find_library_file(lib_dirs, 'readline') @@ -747,7 +750,7 @@ else: readline_extra_link_args = () - readline_libs = ['readline'] + readline_libs = ['c', 'dl', 'readline'] if readline_termcap_library: pass # Issue 7384: Already linked against curses or tinfo. elif curses_library: @@ -766,20 +769,20 @@ # crypt module. if self.compiler.find_library_file(lib_dirs, 'crypt'): - libs = ['crypt'] + libs = ['c', 'dl', 'crypt'] else: - libs = [] + libs = ['c', 'dl'] exts.append( Extension('_crypt', ['_cryptmodule.c'], libraries=libs) ) # CSV files - exts.append( Extension('_csv', ['_csv.c']) ) + exts.append( Extension('_csv', ['_csv.c'], libraries=sys_libs) ) # POSIX subprocess module helper. - exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c']) ) + exts.append( Extension('_posixsubprocess', ['_posixsubprocess.c'], libraries=sys_libs) ) # socket(2) exts.append( Extension('_socket', ['socketmodule.c'], - depends = ['socketmodule.h']) ) + depends = ['socketmodule.h'], libraries=sys_libs) ) # Detect SSL support for the socket module (via _ssl) search_for_ssl_incs_in = [ '/usr/local/ssl/include', @@ -803,7 +806,7 @@ exts.append( Extension('_ssl', ['_ssl.c'], include_dirs = ssl_incs, library_dirs = ssl_libs, - libraries = ['ssl', 'crypto'], + libraries = ['c', 'dl', 'ssl', 'crypto'], depends = ['socketmodule.h']), ) else: missing.append('_ssl') @@ -844,7 +847,7 @@ depends = ['hashlib.h'], include_dirs = ssl_incs, library_dirs = ssl_libs, - libraries = ['ssl', 'crypto']) ) + libraries = ['c', 'dl', 'ssl', 'crypto']) ) else: print("warning: openssl 0x%08x is too old for _hashlib" % openssl_ver) @@ -854,13 +857,13 @@ # It's harmless and the object code is tiny (40-50 KB per module, # only loaded when actually used). exts.append( Extension('_sha256', ['sha256module.c'], - depends=['hashlib.h']) ) + depends=['hashlib.h'], libraries=sys_libs) ) exts.append( Extension('_sha512', ['sha512module.c'], - depends=['hashlib.h']) ) + depends=['hashlib.h'], libraries=sys_libs) ) exts.append( Extension('_md5', ['md5module.c'], - depends=['hashlib.h']) ) + depends=['hashlib.h'], libraries=sys_libs) ) exts.append( Extension('_sha1', ['sha1module.c'], - depends=['hashlib.h']) ) + depends=['hashlib.h'], libraries=sys_libs) ) # Modules that provide persistent dictionary-like semantics. You will # probably want to arrange for at least one of them to be available on @@ -1272,9 +1275,9 @@ # Unix-only modules if host_platform != 'win32': # Steen Lumholt's termios module - exts.append( Extension('termios', ['termios.c']) ) + exts.append( Extension('termios', ['termios.c'], libraries=sys_libs) ) # Jeremy Hylton's rlimit interface - exts.append( Extension('resource', ['resource.c']) ) + exts.append( Extension('resource', ['resource.c'], libraries=sys_libs) ) # Sun yellow pages. Some systems have the functions in libc. if (host_platform not in ['cygwin', 'qnx6'] and @@ -1381,7 +1384,7 @@ else: zlib_extra_link_args = () exts.append( Extension('zlib', ['zlibmodule.c'], - libraries = ['z'], + libraries = ['c', 'dl', 'z'], extra_link_args = zlib_extra_link_args)) have_zlib = True else: @@ -1395,7 +1398,7 @@ # crc32 if we have it. Otherwise binascii uses its own. if have_zlib: extra_compile_args = ['-DUSE_ZLIB_CRC32'] - libraries = ['z'] + libraries = ['c', 'dl', 'z'] extra_link_args = zlib_extra_link_args else: extra_compile_args = [] @@ -1413,7 +1416,7 @@ else: bz2_extra_link_args = () exts.append( Extension('_bz2', ['_bz2module.c'], - libraries = ['bz2'], + libraries = ['c', 'dl', 'bz2'], extra_link_args = bz2_extra_link_args) ) else: missing.append('_bz2') @@ -1421,7 +1424,7 @@ # LZMA compression support. if self.compiler.find_library_file(lib_dirs, 'lzma'): exts.append( Extension('_lzma', ['_lzmamodule.c'], - libraries = ['lzma']) ) + libraries = ['c', 'dl', 'lzma']) ) else: missing.append('_lzma') @@ -1439,7 +1442,7 @@ if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"): expat_inc = [] define_macros = [] - expat_lib = ['expat'] + expat_lib = ['c', 'dl', 'expat'] expat_sources = [] expat_depends = [] else: @@ -1530,7 +1533,7 @@ else: # Linux and other unices macros = dict() - libraries = ['rt'] + libraries = ['c', 'dl', 'm', 'rt'] if host_platform == 'win32': multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', @@ -1578,10 +1581,10 @@ ## ext = Extension('xx', ['xxmodule.c']) ## self.extensions.append(ext) - if 'd' not in sys.abiflags: - ext = Extension('xxlimited', ['xxlimited.c'], - define_macros=[('Py_LIMITED_API', '0x03040000')]) - self.extensions.append(ext) +# if 'd' not in sys.abiflags: +# ext = Extension('xxlimited', ['xxlimited.c'], +# define_macros=[('Py_LIMITED_API', '0x03040000')]) +# self.extensions.append(ext) return missing @@ -1883,7 +1886,7 @@ # Pass empty CFLAGS because we'll just append the resulting # CFLAGS to Python's; -g or -O2 is to be avoided. - cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ + cmd = "cd %s && CFLAGS='' '%s/configure' %s" \ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) res = os.system(cmd) @@ -1942,18 +1945,26 @@ elif host_platform.startswith('hp-ux'): extra_link_args.append('-fPIC') + # to add -fPIC for Android + # assumes use of host triplet set to arm-linux-androideabi + elif host_platform.startswith('arm-linux'): + extra_link_args.append('-fPIC') + # in case host triplet not set to arm-linux-androideabi + # android systems in KBOX usually report as linux + elif host_platform.startswith('linux') + extra_link_args.append('-fPIC') ext = Extension('_ctypes', include_dirs=include_dirs, extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, - libraries=[], + libraries=['c', 'dl'], sources=sources, depends=depends) # function my_sqrt() needs math library for sqrt() ext_test = Extension('_ctypes_test', sources=['_ctypes/_ctypes_test.c'], - libraries=['m']) + libraries=['c', 'dl', 'm']) self.extensions.extend([ext, ext_test]) if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): @@ -1994,7 +2005,7 @@ undef_macros = [] if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): include_dirs = [] - libraries = [':libmpdec.so.2'] + libraries = ['c', 'dl', 'm', ':libmpdec.so.2'] sources = ['_decimal/_decimal.c'] depends = ['_decimal/docstrings.h'] else: @@ -2003,7 +2014,7 @@ 'Modules', '_decimal', 'libmpdec'))] - libraries = [] + libraries = ['c', 'dl', 'm'] sources = [ '_decimal/_decimal.c', '_decimal/libmpdec/basearith.c', @@ -2243,7 +2254,7 @@ 'install_lib': PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. - ext_modules=[Extension('_struct', ['_struct.c'])], + ext_modules=[Extension('_struct', ['_struct.c'], libraries = ['c', 'dl', 'z'])], # If you change the scripts installed here, you also need to # check the PyBuildScripts command above, and change the links