Commit ef0d3333 authored by Matti Picus's avatar Matti Picus
Browse files

merge py3.7 into branch

--HG--
branch : release-pypy3.7-v7.x
Pipeline #27471 passed with stage
in 28 minutes and 40 seconds
......@@ -14,6 +14,7 @@ import types
logger = logging.getLogger(__name__)
IS_PYPY = sys.implementation.name == 'pypy'
class EnvBuilder:
"""
......@@ -208,8 +209,8 @@ class EnvBuilder:
except Exception: # may need to use a more specific exception
logger.warning('Unable to symlink %r to %r', src, dst)
# On Windows, we rewrite symlinks to our base python.exe into
# copies of venvlauncher.exe
# On Windows in CPython, we rewrite symlinks to our base python.exe
# into copies of venvlauncher.exe
basename, ext = os.path.splitext(os.path.basename(src))
srcfn = os.path.join(os.path.dirname(__file__),
"scripts",
......@@ -221,9 +222,9 @@ class EnvBuilder:
if basename.endswith('_d'):
ext = '_d' + ext
basename = basename[:-2]
if basename == 'python':
if not IS_PYPY and basename == 'python':
basename = 'venvlauncher'
elif basename == 'pythonw':
elif not IS_PYPY and basename == 'pythonw':
basename = 'venvwlauncher'
src = os.path.join(os.path.dirname(src), basename + ext)
else:
......@@ -250,7 +251,7 @@ class EnvBuilder:
copier(context.executable, path)
if not os.path.islink(path):
os.chmod(path, 0o755)
for suffix in ('python', 'python3', 'pypy3'):
for suffix in ('python', 'python3', 'pypy3', 'pypy'):
path = os.path.join(binpath, suffix)
if not os.path.exists(path):
# Issue 18807: make copies if
......@@ -258,18 +259,17 @@ class EnvBuilder:
copier(context.env_exe, path, relative_symlinks_ok=True)
if not os.path.islink(path):
os.chmod(path, 0o755)
#
# PyPy extension: also copy needed dlls, not just the
# small executable
for libname in ['libpypy3-c.so', 'libpypy3-c.dylib', 'libffi-7.dll']:
dest_library = os.path.join(binpath, libname)
src_library = os.path.join(os.path.dirname(context.executable),
libname)
if (not os.path.exists(dest_library) and
os.path.exists(src_library)):
copier(src_library, dest_library)
if not os.path.islink(dest_library):
os.chmod(dest_library, 0o755)
# PyPy: also copy lib/*.so*, lib/tk, lib/tkl for portable builds
# if symlinks are not available
libsrc = os.path.join(context.python_dir, '..', 'lib')
if os.path.exists(libsrc) and not self.symlinks:
libdst = os.path.join(context.env_dir, 'lib')
if not os.path.exists(libdst):
os.mkdir(libdst)
for f in os.listdir(libsrc):
src = os.path.join(libsrc, f)
dst = os.path.join(libdst, f)
copier(src, dst)
#
else:
if self.symlinks:
......
......@@ -61,6 +61,7 @@ if sys.platform[:6] == "darwin":
arch = 'x86_64'
build_time_vars['CC'] += ' -arch %s' % (arch,)
build_time_vars['LDSHARED'] = build_time_vars['CC'] + ' -shared -undefined dynamic_lookup'
build_time_vars['LDLIBRARY'] = 'libpypy3-c.dylib'
if "CXX" in build_time_vars:
build_time_vars['CXX'] += ' -arch %s' % (arch,)
build_time_vars['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
......
......@@ -232,8 +232,11 @@ else: # _WIN32
raise DLOpenError(ustr)
return res
def dlopenex(name):
res = rwin32.LoadLibraryExA(name)
def dlopenex(name, flags=rwin32.LOAD_WITH_ALTERED_SEARCH_PATH):
# Don't display a message box when Python can't load a DLL */
old_mode = rwin32.SetErrorMode(rwin32.SEM_FAILCRITICALERRORS)
res = rwin32.LoadLibraryExA(name, flags)
rwin32.SetErrorMode(old_mode)
if not res:
err = rwin32.GetLastError_saved()
ustr, lgt = rwin32.FormatErrorW(err)
......
......@@ -117,6 +117,8 @@ class CConfig:
STD_ERROR_HANDLE HANDLE_FLAG_INHERIT FILE_TYPE_CHAR
LOAD_WITH_ALTERED_SEARCH_PATH CT_CTYPE3 C3_HIGHSURROGATE
CP_ACP CP_UTF8 CP_UTF7 CP_OEMCP MB_ERR_INVALID_CHARS
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS SEM_FAILCRITICALERRORS
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR
"""
from rpython.translator.platform import host_factory
static_platform = host_factory()
......@@ -213,7 +215,7 @@ if WIN32:
LoadLibrary = winexternal('LoadLibraryA', [rffi.CCHARP], HMODULE,
save_err=rffi.RFFI_SAVE_LASTERROR)
def wrap_loadlibraryex(func):
def loadlibrary(name, flags=LOAD_WITH_ALTERED_SEARCH_PATH):
def loadlibrary(name, flags):
# Requires a full path name with '/' -> '\\'
return func(name, NULL_HANDLE, flags)
return loadlibrary
......@@ -265,8 +267,8 @@ if WIN32:
fd = _open_osfhandle(handle, flags)
with SuppressIPH():
return fd
wcsncpy_s = rffi.llexternal('wcsncpy_s',
wcsncpy_s = rffi.llexternal('wcsncpy_s',
[rffi.CWCHARP, rffi.SIZE_T, rffi.CWCHARP, rffi.SIZE_T], rffi.INT)
def build_winerror_to_errno():
......@@ -583,27 +585,27 @@ if WIN32:
os.close(fd2)
raise
return res
GetConsoleMode = winexternal(
'GetConsoleMode', [HANDLE, LPDWORD], BOOL)
GetNumberOfConsoleInputEvents = winexternal(
'GetNumberOfConsoleInputEvents', [HANDLE, LPDWORD], BOOL)
ERROR_INSUFFICIENT_BUFFER = 122
ERROR_OPERATION_ABORTED = 995
CP_UTF8 = 65001
CP_UTF8 = 65001
ReadConsoleW = winexternal(
'ReadConsoleW', [HANDLE, LPWSTR, DWORD, LPDWORD, LPVOID], BOOL,
save_err=rffi.RFFI_SAVE_LASTERROR)
WriteConsoleW = winexternal(
'WriteConsoleW', [HANDLE, LPVOID, DWORD, LPDWORD, LPVOID], BOOL,
save_err=rffi.RFFI_SAVE_LASTERROR)
GetStringTypeW = winexternal(
'GetStringTypeW', [DWORD, rffi.CWCHARP, rffi.INT, LPWORD], BOOL,
'GetStringTypeW', [DWORD, rffi.CWCHARP, rffi.INT, LPWORD], BOOL,
save_err=rffi.RFFI_SAVE_LASTERROR)
_SetEnvironmentVariableW = winexternal(
......@@ -613,4 +615,17 @@ if WIN32:
def SetEnvironmentVariableW(name, value):
with rffi.scoped_unicode2wcharp(name) as nameWbuf:
with rffi.scoped_unicode2wcharp(value) as valueWbuf:
return _SetEnvironmentVariableW(nameWbuf, valueWbuf)
return _SetEnvironmentVariableW(nameWbuf, valueWbuf)
_AddDllDirectory = winexternal('AddDllDirectory', [LPWSTR], rffi.VOIDP,
save_err=rffi.RFFI_SAVE_LASTERROR)
def AddDllDirectory(path, length):
with rffi.scoped_utf82wcharp(path, length) as pathW:
return _AddDllDirectory(pathW)
RemoveDllDirectory = winexternal('RemoveDllDirectory', [rffi.VOIDP], BOOL,
save_err=rffi.RFFI_SAVE_LASTERROR)
# Don't save the err since this is called before checking err in rdynload
SetErrorMode = winexternal('SetErrorMode', [rffi.UINT], rffi.UINT)
......@@ -112,7 +112,7 @@ def test_loadlibraryA():
assert os.path.exists(test1)
hdll = rwin32.LoadLibraryExA(test1)
hdll = rwin32.LoadLibraryExA(test1, rwin32.LOAD_WITH_ALTERED_SEARCH_PATH)
assert hdll
faddr = rwin32.GetProcAddress(hdll, 'sum')
assert faddr
......@@ -131,7 +131,7 @@ def test_loadlibraryW():
assert os.path.exists(unicode(test1))
hdll = rwin32.LoadLibraryExW(unicode(test1))
hdll = rwin32.LoadLibraryExW(unicode(test1), rwin32.LOAD_WITH_ALTERED_SEARCH_PATH)
assert hdll
faddr = rwin32.GetProcAddress(hdll, 'sum')
assert faddr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment