diff options
author | Steve Dower <steve.dower@microsoft.com> | 2017-02-04 15:39:38 -0800 |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2017-02-04 15:39:38 -0800 |
commit | 1a5780aabb550cae175ad8711e2f33ba644d0ddb (patch) | |
tree | 68e47eaafb4ccc17bbdb7668c6058984945b332d /setup.py | |
parent | 956c7cfa7111ab5458e2f69868a05b7b84fc6843 (diff) | |
parent | d1d8706cdb77e2adbbb4110338dcda0e1811f892 (diff) | |
download | cpython-1a5780aabb550cae175ad8711e2f33ba644d0ddb.tar.gz |
Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 73 |
1 files changed, 48 insertions, 25 deletions
@@ -185,7 +185,7 @@ def find_module_file(module, dirlist): if not list: return module if len(list) > 1: - log.info("WARNING: multiple copies of %s found"%module) + log.info("WARNING: multiple copies of %s found", module) return os.path.join(list[0], module) class PyBuildExt(build_ext): @@ -532,8 +532,9 @@ class PyBuildExt(build_ext): for directory in reversed(options.dirs): add_dir_to_list(dir_list, directory) - if os.path.normpath(sys.base_prefix) != '/usr' \ - and not sysconfig.get_config_var('PYTHONFRAMEWORK'): + if (not cross_compiling and + os.path.normpath(sys.base_prefix) != '/usr' and + not sysconfig.get_config_var('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 @@ -651,9 +652,12 @@ class PyBuildExt(build_ext): # profiler (_lsprof is for cProfile.py) exts.append( Extension('_lsprof', ['_lsprof.c', 'rotatingtree.c']) ) # static Unicode character database - exts.append( Extension('unicodedata', ['unicodedata.c']) ) + exts.append( Extension('unicodedata', ['unicodedata.c'], + depends=['unicodedata_db.h', 'unicodename_db.h']) ) # _opcode module exts.append( Extension('_opcode', ['_opcode.c']) ) + # asyncio speedups + exts.append( Extension("_asyncio", ["_asynciomodule.c"]) ) # Modules with some UNIX dependencies -- on by default: # (If you have a really backward UNIX, select and socket may not be @@ -837,7 +841,7 @@ class PyBuildExt(build_ext): # find out which version of OpenSSL we have openssl_ver = 0 openssl_ver_re = re.compile( - '^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' ) + r'^\s*#\s*define\s+OPENSSL_VERSION_NUMBER\s+(0x[0-9a-fA-F]+)' ) # look for the openssl version header on the compiler search path. opensslv_h = find_file('openssl/opensslv.h', [], @@ -888,6 +892,29 @@ class PyBuildExt(build_ext): exts.append( Extension('_sha1', ['sha1module.c'], depends=['hashlib.h']) ) + blake2_deps = glob(os.path.join(os.getcwd(), srcdir, + 'Modules/_blake2/impl/*')) + blake2_deps.append('hashlib.h') + + blake2_macros = [] + if not cross_compiling and os.uname().machine == "x86_64": + # Every x86_64 machine has at least SSE2. + blake2_macros.append(('BLAKE2_USE_SSE', '1')) + + exts.append( Extension('_blake2', + ['_blake2/blake2module.c', + '_blake2/blake2b_impl.c', + '_blake2/blake2s_impl.c'], + define_macros=blake2_macros, + depends=blake2_deps) ) + + sha3_deps = glob(os.path.join(os.getcwd(), srcdir, + 'Modules/_sha3/kcp/*')) + sha3_deps.append('hashlib.h') + exts.append( Extension('_sha3', + ['_sha3/sha3module.c'], + depends=sha3_deps)) + # Modules that provide persistent dictionary-like semantics. You will # probably want to arrange for at least one of them to be available on # your machine, though none are defined by default because of library @@ -1323,7 +1350,8 @@ class PyBuildExt(build_ext): panel_library = 'panel' if curses_library == 'ncursesw': curses_defines.append(('HAVE_NCURSESW', '1')) - curses_includes.append('/usr/include/ncursesw') + if not cross_compiling: + curses_includes.append('/usr/include/ncursesw') # Bug 1464056: If _curses.so links with ncursesw, # _curses_panel.so must link with panelw. panel_library = 'panelw' @@ -1604,7 +1632,7 @@ class PyBuildExt(build_ext): ## ext = Extension('xx', ['xxmodule.c']) ## self.extensions.append(ext) - if 'd' not in sys.abiflags: + if 'd' not in sysconfig.get_config_var('ABIFLAGS'): ext = Extension('xxlimited', ['xxlimited.c'], define_macros=[('Py_LIMITED_API', '0x03050000')]) self.extensions.append(ext) @@ -1700,7 +1728,7 @@ class PyBuildExt(build_ext): # All existing framework builds of Tcl/Tk don't support 64-bit # architectures. cflags = sysconfig.get_config_vars('CFLAGS')[0] - archs = re.findall('-arch\s+(\w+)', cflags) + archs = re.findall(r'-arch\s+(\w+)', cflags) tmpfile = os.path.join(self.build_temp, 'tk.arch') if not os.path.exists(self.build_temp): @@ -1887,6 +1915,9 @@ class PyBuildExt(build_ext): if host_platform == 'darwin': return self.configure_ctypes_darwin(ext) + print('warning: building with the bundled copy of libffi is' + ' deprecated on this platform. It will not be' + ' distributed with Python 3.7') srcdir = sysconfig.get_config_var('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', @@ -1983,13 +2014,14 @@ class PyBuildExt(build_ext): libraries=math_libs) self.extensions.extend([ext, ext_test]) - if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): - return - if host_platform == 'darwin': + if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"): + return # OS X 10.5 comes with libffi.dylib; the include files are # in /usr/include/ffi inc_dirs.append('/usr/include/ffi') + elif '--without-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): + return ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")] if not ffi_inc or ffi_inc[0] == '': @@ -2008,7 +2040,7 @@ class PyBuildExt(build_ext): 'ffi_wrapper_h'.format(ffi_h)) ffi_lib = None if ffi_inc is not None: - for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): + for lib_name in ('ffi', 'ffi_pic'): if (self.compiler.find_library_file(lib_dirs, lib_name)): ffi_lib = lib_name break @@ -2032,7 +2064,7 @@ class PyBuildExt(build_ext): 'Modules', '_decimal', 'libmpdec'))] - libraries = [] + libraries = self.detect_math_libs() sources = [ '_decimal/_decimal.c', '_decimal/libmpdec/basearith.c', @@ -2061,7 +2093,7 @@ class PyBuildExt(build_ext): '_decimal/libmpdec/fnt.h', '_decimal/libmpdec/fourstep.h', '_decimal/libmpdec/io.h', - '_decimal/libmpdec/memory.h', + '_decimal/libmpdec/mpalloc.h', '_decimal/libmpdec/mpdecimal.h', '_decimal/libmpdec/numbertheory.h', '_decimal/libmpdec/sixstep.h', @@ -2127,15 +2159,6 @@ class PyBuildExt(build_ext): if not sysconfig.get_config_var('WITH_THREAD'): define_macros.append(('WITHOUT_THREADS', 1)) - # Increase warning level for gcc: - if 'gcc' in cc: - cmd = ("echo '' | %s -Wextra -Wno-missing-field-initializers -E - " - "> /dev/null 2>&1" % cc) - ret = os.system(cmd) - if ret >> 8 == 0: - extra_compile_args.extend(['-Wextra', - '-Wno-missing-field-initializers']) - # Uncomment for extra functionality: #define_macros.append(('EXTRA_FUNCTIONALITY', 1)) ext = Extension ( @@ -2214,7 +2237,7 @@ class PyBuildScripts(build_scripts): newfilename = filename + fullversion else: newfilename = filename + minoronly - log.info('renaming {} to {}'.format(filename, newfilename)) + log.info('renaming %s to %s', filename, newfilename) os.rename(filename, newfilename) newoutfiles.append(newfilename) if filename in updated_files: @@ -2256,7 +2279,7 @@ def main(): setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], - url = "http://www.python.org/%s" % sys.version[:3], + url = "http://www.python.org/%d.%d" % sys.version_info[:2], maintainer = "Guido van Rossum and the Python community", maintainer_email = "python-dev@python.org", description = "A high-level object-oriented programming language", |