From 247838ff36981a034c83672ab1a5a081c0114b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 2 Oct 2021 15:42:17 +0200 Subject: [PATCH] Skip directories when symlinking libraries for PyPy3 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 #2182 --- docs/changelog/2182.bugfix.txt | 2 ++ src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 docs/changelog/2182.bugfix.txt diff --git a/docs/changelog/2182.bugfix.txt b/docs/changelog/2182.bugfix.txt new file mode 100644 index 000000000..0f26a202b --- /dev/null +++ b/docs/changelog/2182.bugfix.txt @@ -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`. 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 be5319a2b..f740de963 100644 --- a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py +++ b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py @@ -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)