Skip to content

Commit

Permalink
PyPy: glob for required dlls, check they exist (#2274)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
mattip and pre-commit-ci[bot] authored Jan 2, 2022
1 parent 856933e commit e813ac1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
8 changes: 3 additions & 5 deletions src/virtualenv/create/via_global_ref/builtin/pypy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 8 additions & 4 deletions src/virtualenv/create/via_global_ref/builtin/pypy/pypy2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
15 changes: 10 additions & 5 deletions src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ def exe_names(cls, interpreter):


class PyPy3Posix(PyPy3, PosixSupports):
"""PyPy 2 on POSIX"""
"""PyPy 3 on POSIX"""

@property
def stdlib(self):
"""PyPy3 respects sysconfig only for the host python, virtual envs is instead lib/pythonx.y/site-packages"""
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
Expand Down Expand Up @@ -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

0 comments on commit e813ac1

Please sign in to comment.