Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PyPy 3.8 #2206

Merged
merged 7 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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