aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2021-10-05 12:55:22 +0300
committerMatti Picus <matti.picus@gmail.com>2021-10-05 12:55:22 +0300
commit5f1e5dcd876c1945991de62018c22815eb4bb53b (patch)
treed177e92da138a246af656f62602512845ba375ad
parentmerge py3.7 into release (diff)
parentremove windows copying that was in non-windows clause (diff)
downloadpypy-5f1e5dcd876c1945991de62018c22815eb4bb53b.tar.gz
pypy-5f1e5dcd876c1945991de62018c22815eb4bb53b.tar.bz2
pypy-5f1e5dcd876c1945991de62018c22815eb4bb53b.zip
merge py3.7 into branchrelease-pypy3.7-v7.3.6rc2
-rw-r--r--lib-python/3/venv/__init__.py34
-rw-r--r--lib_pypy/_sysconfigdata.py1
-rw-r--r--rpython/rlib/rdynload.py7
-rw-r--r--rpython/rlib/rwin32.py35
-rw-r--r--rpython/rlib/test/test_rwin32.py4
5 files changed, 50 insertions, 31 deletions
diff --git a/lib-python/3/venv/__init__.py b/lib-python/3/venv/__init__.py
index 4c1a1f1592..885991ef82 100644
--- a/lib-python/3/venv/__init__.py
+++ b/lib-python/3/venv/__init__.py
@@ -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:
diff --git a/lib_pypy/_sysconfigdata.py b/lib_pypy/_sysconfigdata.py
index 208fc5a629..a1c6a8994b 100644
--- a/lib_pypy/_sysconfigdata.py
+++ b/lib_pypy/_sysconfigdata.py
@@ -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'
diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
index 9d2209ee84..33a5e8293e 100644
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -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)
diff --git a/rpython/rlib/rwin32.py b/rpython/rlib/rwin32.py
index 2ed5a8fc31..56072c619e 100644
--- a/rpython/rlib/rwin32.py
+++ b/rpython/rlib/rwin32.py
@@ -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)
diff --git a/rpython/rlib/test/test_rwin32.py b/rpython/rlib/test/test_rwin32.py
index 893b2b2bbf..6552549a12 100644
--- a/rpython/rlib/test/test_rwin32.py
+++ b/rpython/rlib/test/test_rwin32.py
@@ -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