diff -Naur -x __pycache__ Python-3.5.2/Makefile.pre.in Python-test-3.5.2/Makefile.pre.in --- Python-3.5.2/Makefile.pre.in 2016-06-25 17:38:37.000000000 -0400 +++ Python-test-3.5.2/Makefile.pre.in 2016-09-24 16:49:05.690865725 -0400 @@ -602,6 +602,9 @@ *\ -s*|s*) quiet="-q";; \ *) quiet="";; \ esac; \ + if test -n "$(_PYTHON_HOST_PLATFORM)" ; then \ + export _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) ; \ + fi ; \ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build diff -Naur -x __pycache__ Python-3.5.2/setup.py Python-test-3.5.2/setup.py --- Python-3.5.2/setup.py 2016-06-25 17:38:39.000000000 -0400 +++ Python-test-3.5.2/setup.py 2016-09-24 17:52:26.537909483 -0400 @@ -19,11 +19,28 @@ cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ +if cross_compiling: + config_vars = sysconfig._parse_makefile('Makefile') + with open('pyconfig.h') as conf_file: + sysconfig.parse_config_h(conf_file,config_vars) +else: + config_vars = sysconfig.get_config_vars() + +def get_srcdir(): + if cross_compiling: + return os.path.dirname(__file__) + else: + srcdir = config_vars.get('srcdir') + if not srcdir: + # Maybe running on Windows but not using CYGWIN? + raise ValueError("No source directory; cannot proceed.") + return os.path.abspath(srcdir) + # Add special CFLAGS reserved for building the interpreter and the stdlib # modules (Issue #21121). -cflags = sysconfig.get_config_var('CFLAGS') -py_cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') -sysconfig.get_config_vars()['CFLAGS'] = cflags + ' ' + py_cflags_nodist +cflags = config_vars.get('CFLAGS') +py_cflags_nodist = config_vars.get('PY_CFLAGS_NODIST') +config_vars['CFLAGS'] = cflags + ' ' + py_cflags_nodist class Dummy: """Hack for parallel build""" @@ -41,7 +58,7 @@ host_platform = get_platform() # Were we compiled --with-pydebug or with #define Py_DEBUG? -COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS")) +COMPILED_WITH_PYDEBUG = ('--with-pydebug' in config_vars.get("CONFIG_ARGS")) # This global variable is used to hold the list of modules to be disabled. disabled_module_list = [] @@ -66,7 +83,7 @@ Return the directory of the current OSX SDK, or '/' if no SDK was specified. """ - cflags = sysconfig.get_config_var('CFLAGS') + cflags = config_vars.get('CFLAGS') m = re.search(r'-isysroot\s+(\S+)', cflags) if m is None: sysroot = '/' @@ -215,11 +232,7 @@ # Fix up the autodetected modules, prefixing all the source files # with Modules/. - srcdir = sysconfig.get_config_var('srcdir') - if not srcdir: - # Maybe running on Windows but not using CYGWIN? - raise ValueError("No source directory; cannot proceed.") - srcdir = os.path.abspath(srcdir) + srcdir = get_srcdir() moddirlist = [os.path.join(srcdir, 'Modules')] # Fix up the paths for scripts, too @@ -227,8 +240,14 @@ for filename in self.distribution.scripts] # Python header files - headers = [sysconfig.get_config_h_filename()] - headers += glob(os.path.join(sysconfig.get_path('include'), "*.h")) + if cross_compiling: + headers = ['config.h', os.path.join('Include','graminit.h')] + headers += [p for p in glob( + os.path.join(srcdir, 'Include', '*.h') + ) if os.path.basename(p) != 'graminit.h'] + else: + headers = [sysconfig.get_config_h_filename()] + headers += glob(os.path.join(sysconfig.get_path('include'), "*.h")) for ext in self.extensions[:]: ext.sources = [ find_module_file(filename, moddirlist) @@ -270,7 +289,8 @@ # unfortunately, distutils doesn't let us provide separate C and C++ # compilers if compiler is not None: - (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS') + ccshared = config_vars.get('CCSHARED') + cflags = config_vars.get('CFLAGS') args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags self.compiler.set_executables(**args) @@ -405,7 +425,7 @@ def add_multiarch_paths(self): # Debian/Ubuntu multiarch support. # https://wiki.ubuntu.com/MultiarchSpec - cc = sysconfig.get_config_var('CC') + cc = config_vars.get('CC') tmpfile = os.path.join(self.build_temp, 'multiarch') if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) @@ -430,7 +450,7 @@ return opt = '' if cross_compiling: - opt = '-t' + sysconfig.get_config_var('HOST_GNU_TYPE') + opt = '-t' + config_vars.get('HOST_GNU_TYPE') tmpfile = os.path.join(self.build_temp, 'multiarch') if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) @@ -449,7 +469,7 @@ os.unlink(tmpfile) def add_gcc_paths(self): - gcc = sysconfig.get_config_var('CC') + gcc = config_vars.get('CC') tmpfile = os.path.join(self.build_temp, 'gccpaths') if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) @@ -509,7 +529,7 @@ ('LDFLAGS', '-R', self.compiler.runtime_library_dirs), ('LDFLAGS', '-L', self.compiler.library_dirs), ('CPPFLAGS', '-I', self.compiler.include_dirs)): - env_val = sysconfig.get_config_var(env_var) + env_val = config_vars.get(env_var) if env_val: # To prevent optparse from raising an exception about any # options in env_val that it doesn't know about we strip out @@ -534,15 +554,15 @@ add_dir_to_list(dir_list, directory) if os.path.normpath(sys.base_prefix) != '/usr' \ - and not sysconfig.get_config_var('PYTHONFRAMEWORK'): + and not config_vars.get('PYTHONFRAMEWORK'): # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework # (PYTHONFRAMEWORK is set) to avoid # linking problems when # building a framework with different architectures than # the one that is currently installed (issue #7473) add_dir_to_list(self.compiler.library_dirs, - sysconfig.get_config_var("LIBDIR")) + config_vars.get("LIBDIR")) add_dir_to_list(self.compiler.include_dirs, - sysconfig.get_config_var("INCLUDEDIR")) + config_vars.get("INCLUDEDIR")) # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can @@ -553,17 +573,18 @@ '/lib', '/usr/lib', ] inc_dirs = self.compiler.include_dirs + ['/usr/include'] + config_h = sysconfig.get_config_h_filename() else: lib_dirs = self.compiler.library_dirs[:] inc_dirs = self.compiler.include_dirs[:] + config_h = 'pyconfig.h' exts = [] missing = [] - config_h = sysconfig.get_config_h_filename() with open(config_h) as file: config_h_vars = sysconfig.parse_config_h(file) - srcdir = sysconfig.get_config_var('srcdir') + srcdir = get_srcdir() # OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb) if host_platform in ['osf1', 'unixware7', 'openunix8']: @@ -581,8 +602,9 @@ # NOTE: using shlex.split would technically be more correct, but # also gives a bootstrap problem. Let's hope nobody uses # directories with whitespace in the name to store libraries. - cflags, ldflags = sysconfig.get_config_vars( - 'CFLAGS', 'LDFLAGS') + cflags = config_vars.get('CFLAGS') + ldflags = config_vars.get('LDFLAGS') + for item in cflags.split(): if item.startswith('-I'): inc_dirs.append(item[2:]) @@ -617,7 +639,7 @@ # time libraries: librt may be needed for clock_gettime() time_libs = [] - lib = sysconfig.get_config_var('TIMEMODULE_LIB') + lib = config_vars.get('TIMEMODULE_LIB') if lib: time_libs.append(lib) @@ -719,7 +741,7 @@ if do_readline: if cross_compiling: ret = os.system("%s -d %s | grep '(NEEDED)' > %s" \ - % (sysconfig.get_config_var('READELF'), + % (config_vars.get('READELF'), do_readline, tmpfile)) elif find_executable('ldd'): ret = os.system("ldd %s > %s" % (do_readline, tmpfile)) @@ -752,7 +774,7 @@ if host_platform == 'darwin': os_release = int(os.uname()[2].split('.')[0]) - dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') + dep_target = config_vars.get('MACOSX_DEPLOYMENT_TARGET') if (dep_target and (tuple(int(n) for n in dep_target.split('.')[0:2]) < (10, 5) ) ): @@ -1181,7 +1203,7 @@ # Enable support for loadable extensions in the sqlite3 module # if --enable-loadable-sqlite-extensions configure option is used. - if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"): + if '--enable-loadable-sqlite-extensions' not in config_vars.get("CONFIG_ARGS"): sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1")) if host_platform == 'darwin': @@ -1217,7 +1239,7 @@ # The standard Unix dbm module: if host_platform not in ['cygwin']: config_args = [arg.strip("'") - for arg in sysconfig.get_config_var("CONFIG_ARGS").split()] + for arg in config_vars.get("CONFIG_ARGS").split()] dbm_args = [arg for arg in config_args if arg.startswith('--with-dbmliborder=')] if dbm_args: @@ -1463,7 +1485,7 @@ # # More information on Expat can be found at www.libexpat.org. # - if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"): + if '--with-system-expat' in config_vars.get("CONFIG_ARGS"): expat_inc = [] define_macros = [] expat_lib = ['expat'] @@ -1567,11 +1589,11 @@ else: multiprocessing_srcs = [ '_multiprocessing/multiprocessing.c', ] - if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not - sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): + if (config_vars.get('HAVE_SEM_OPEN') and not + config_vars.get('POSIX_SEMAPHORES_NOT_ENABLED')): multiprocessing_srcs.append('_multiprocessing/semaphore.c') - if sysconfig.get_config_var('WITH_THREAD'): + if config_vars.get('WITH_THREAD'): exts.append ( Extension('_multiprocessing', multiprocessing_srcs, define_macros=list(macros.items()), include_dirs=["Modules/_multiprocessing"])) @@ -1700,7 +1722,7 @@ # All existing framework builds of Tcl/Tk don't support 64-bit # architectures. - cflags = sysconfig.get_config_vars('CFLAGS')[0] + cflags = config_vars.get('CFLAGS') archs = re.findall('-arch\s+(\w+)', cflags) tmpfile = os.path.join(self.build_temp, 'tk.arch') @@ -1859,7 +1881,7 @@ def configure_ctypes_darwin(self, ext): # Darwin (OS X) uses preconfigured files, in # the Modules/_ctypes/libffi_osx directory. - srcdir = sysconfig.get_config_var('srcdir') + srcdir = get_srcdir() ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi_osx')) sources = [os.path.join(ffi_srcdir, p) @@ -1888,7 +1910,7 @@ if host_platform == 'darwin': return self.configure_ctypes_darwin(ext) - srcdir = sysconfig.get_config_var('srcdir') + srcdir = get_srcdir() ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) @@ -1903,7 +1925,7 @@ ffi_configfile): from distutils.dir_util import mkpath mkpath(ffi_builddir) - config_args = [arg for arg in sysconfig.get_config_var("CONFIG_ARGS").split() + config_args = [arg for arg in config_vars.get("CONFIG_ARGS").split() if (('--host=' in arg) or ('--build=' in arg))] if not self.verbose: config_args.append("-q") @@ -1984,7 +2006,7 @@ libraries=math_libs) self.extensions.extend([ext, ext_test]) - if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): + if not '--with-system-ffi' in config_vars.get("CONFIG_ARGS"): return if host_platform == 'darwin': @@ -1992,7 +2014,7 @@ # in /usr/include/ffi inc_dirs.append('/usr/include/ffi') - ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] + ffi_inc = [config_vars.get("LIBFFI_INCLUDEDIR")] if not ffi_inc or ffi_inc[0] == '': ffi_inc = find_file('ffi.h', [], inc_dirs) if ffi_inc is not None: @@ -2020,13 +2042,13 @@ def _decimal_ext(self): extra_compile_args = [] undef_macros = [] - if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): + if '--with-system-libmpdec' in config_vars.get("CONFIG_ARGS"): include_dirs = [] libraries = [':libmpdec.so.2'] sources = ['_decimal/_decimal.c'] depends = ['_decimal/docstrings.h'] else: - srcdir = sysconfig.get_config_var('srcdir') + srcdir = get_srcdir() include_dirs = [os.path.abspath(os.path.join(srcdir, 'Modules', '_decimal', @@ -2080,8 +2102,8 @@ 'universal': [('UNIVERSAL','1')] } - cc = sysconfig.get_config_var('CC') - sizeof_size_t = sysconfig.get_config_var('SIZEOF_SIZE_T') + cc = config_vars.get('CC') + sizeof_size_t = config_vars.get('SIZEOF_SIZE_T') machine = os.environ.get('PYTHON_DECIMAL_WITH_MACHINE') if machine: @@ -2092,14 +2114,14 @@ # was built with. define_macros = config['universal'] elif sizeof_size_t == 8: - if sysconfig.get_config_var('HAVE_GCC_ASM_FOR_X64'): + if config_vars.get('HAVE_GCC_ASM_FOR_X64'): define_macros = config['x64'] - elif sysconfig.get_config_var('HAVE_GCC_UINT128_T'): + elif config_vars.get('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') + ppro = config_vars.get('HAVE_GCC_ASM_FOR_X87') if ppro and ('gcc' in cc or 'clang' in cc) and \ not 'sunos' in host_platform: # solaris: problems with register allocation. @@ -2112,18 +2134,18 @@ raise DistutilsError("_decimal: unsupported architecture") # Workarounds for toolchain bugs: - if sysconfig.get_config_var('HAVE_IPA_PURE_CONST_BUG'): + if config_vars.get('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'): + if config_vars.get('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'): + if not config_vars.get('WITH_THREAD'): define_macros.append(('WITHOUT_THREADS', 1)) # Increase warning level for gcc: @@ -2171,7 +2193,7 @@ # mode 755. All installed directories will get mode 755. # this is works for EXT_SUFFIX too, which ends with SHLIB_SUFFIX - shlib_suffix = sysconfig.get_config_var("SHLIB_SUFFIX") + shlib_suffix = config_vars.get("SHLIB_SUFFIX") def install(self): outfiles = install_lib.install(self)