Skip to content

Commit

Permalink
Skip directories when symlinking libraries for PyPy3
Browse files Browse the repository at this point in the history
The PyPy3 logic creates symlinks for all files from the library
directory existing alongside the PyPy executable.  This is meant
to ensure that the bundled libraries to which PyPy is linked can also
be found from inside the virtualenv.  However, this logic also symlinks
all directories which is unnecessary and causes library directory
collisions with the new install layout.  Change to logic to symlink
non-directories only.

A similar fix has been applied to the internal venv module in PyPy3.8:
https://foss.heptapod.net/pypy/pypy/-/commit/713b2af9abd2b9453e12c60143e17431a1aefb33

Fixes pypa#2182
  • Loading branch information
mgorny committed Oct 2, 2021
1 parent 5d14665 commit 6cc2dde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
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`.
2 changes: 2 additions & 0 deletions src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def sources(cls, interpreter):
host_lib = Path(interpreter.system_prefix) / "lib"
if host_lib.exists() and host_lib.is_dir():
for path in host_lib.iterdir():
if path.is_dir():
continue
yield PathRefToDest(path, dest=cls.to_lib)


Expand Down

0 comments on commit 6cc2dde

Please sign in to comment.