diff --git a/src/virtualenv/create/via_global_ref/builtin/pypy/common.py b/src/virtualenv/create/via_global_ref/builtin/pypy/common.py index cc03b4293..b0cd401f9 100644 --- a/src/virtualenv/create/via_global_ref/builtin/pypy/common.py +++ b/src/virtualenv/create/via_global_ref/builtin/pypy/common.py @@ -43,11 +43,9 @@ def sources(cls, interpreter): def _add_shared_libs(cls, interpreter): # https://bitbucket.org/pypy/pypy/issue/1922/future-proofing-virtualenv python_dir = Path(interpreter.system_executable).resolve().parent - for libname in cls._shared_libs(): - src = python_dir / libname - if src.exists(): - yield src + for src in cls._shared_libs(python_dir): + yield src @classmethod - def _shared_libs(cls): + def _shared_libs(cls, python_dir): raise NotImplementedError diff --git a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy2.py b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy2.py index 46d1088c6..78349d44e 100644 --- a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy2.py +++ b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy2.py @@ -87,8 +87,8 @@ def modules(cls): return super(PyPy2Posix, cls).modules() + ["posixpath"] @classmethod - def _shared_libs(cls): - return ["libpypy-c.so", "libpypy-c.dylib"] + def _shared_libs(cls, python_dir): + return python_dir.glob("libpypy*.*") @property def lib(self): @@ -111,8 +111,12 @@ def modules(cls): return super(Pypy2Windows, cls).modules() + ["ntpath"] @classmethod - def _shared_libs(cls): - return ["libpypy-c.dll", "libffi-7.dll", "libffi-8.dll"] + def _shared_libs(cls, python_dir): + # No glob in python2 PathLib + for candidate in ["libpypy-c.dll", "libffi-7.dll", "libffi-8.dll"]: + dll = python_dir / candidate + if dll.exists(): + yield dll @classmethod def sources(cls, interpreter): diff --git a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py index 25d8e1680..f1726ec96 100644 --- a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py +++ b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py @@ -23,7 +23,7 @@ def exe_names(cls, interpreter): class PyPy3Posix(PyPy3, PosixSupports): - """PyPy 2 on POSIX""" + """PyPy 3 on POSIX""" @property def stdlib(self): @@ -31,8 +31,9 @@ def stdlib(self): return self.dest / "lib" / "pypy{}".format(self.interpreter.version_release_str) / "site-packages" @classmethod - def _shared_libs(cls): - return ["libpypy3-c.so", "libpypy3-c.dylib"] + def _shared_libs(cls, python_dir): + # glob for libpypy3-c.so, libpypy3-c.dylib, libpypy3.9-c.so ... + return python_dir.glob("libpypy3*.*") def to_lib(self, src): return self.dest / "lib" / src.name @@ -71,5 +72,9 @@ def bin_dir(self): return self.dest / "Scripts" @classmethod - def _shared_libs(cls): - return ["libpypy3-c.dll", "libffi-7.dll", "libffi-8.dll"] + def _shared_libs(cls, python_dir): + # glob for libpypy*.dll and libffi*.dll + for pattern in ["libpypy*.dll", "libffi*.dll"]: + srcs = python_dir.glob(pattern) + for src in srcs: + yield src