Skip to content

Commit

Permalink
Support PyPy 3.8 (#2206)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Górny <[email protected]>
Co-authored-by: Bernát Gábor <[email protected]>
  • Loading branch information
3 people authored Oct 23, 2021
1 parent 35ec441 commit 4188ac6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ jobs:
- 3.7
- 3.6
- 3.5
- pypy3
- pypy-3.6
- pypy-3.7-v7.3.6rc3
- pypy-3.8-v7.3.6rc3
- 2.7
- pypy2
- pypy-2.7
include:
- { os: macos-latest, py: brew@py3 }
steps:
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog/2182.bugfix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed path collision that could lead to a PermissionError or writing to system
directories when using PyPy3.8 - by :user:`mgorny`.
12 changes: 11 additions & 1 deletion src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PyPy3Posix(PyPy3, PosixSupports):
@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" / "python{}".format(self.interpreter.version_release_str) / "site-packages"
return self.dest / "lib" / "pypy{}".format(self.interpreter.version_release_str) / "site-packages"

@classmethod
def _shared_libs(cls):
Expand All @@ -41,9 +41,19 @@ def to_lib(self, src):
def sources(cls, interpreter):
for src in super(PyPy3Posix, cls).sources(interpreter):
yield src
# Also copy/symlink anything under prefix/lib, which, for "portable"
# PyPy builds, includes the tk,tcl runtime and a number of shared
# objects. In distro-specific builds or on conda this should be empty
# (on PyPy3.8+ it will, like on CPython, hold the stdlib).
host_lib = Path(interpreter.system_prefix) / "lib"
stdlib = Path(interpreter.system_stdlib)
if host_lib.exists() and host_lib.is_dir():
for path in host_lib.iterdir():
if stdlib == path:
# For PyPy3.8+ the stdlib lives in lib/pypy3.8
# We need to avoid creating a symlink to it since that
# will defeat the purpose of a virtualenv
continue
yield PathRefToDest(path, dest=cls.to_lib)


Expand Down

0 comments on commit 4188ac6

Please sign in to comment.