We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Incorrect (broken) virtualenv layout with pypy3.8's new layout
**Issue**

PyPy3.8 (currently 7.3.6rc1) supports a new install layout that resembles CPython more. That is, `sys.prefix` no longer needs being isolated, and site-packages are found in `$prefix/lib/pypy3.8/site-packages`. However, virtualenv tries to symlink everything from `/usr/lib` including the `pypy3.8` directory. As a result, the user can't write to the site-packages directory in the venv.

I haven't tried running it as root but I can imagine it doing major mess if it virtualenv doesn't take any precautions from writing into system directories.

**Environment**

Provide at least:
- OS: Gentoo Linux
- ``pip list`` of the host python where ``virtualenv`` is installed: [pip-list.txt](https://github.com/pypa/virtualenv/files/7167321/pip-list.txt)


**Output of the virtual environment creation**

Make sure to run the creation with `-vvv --with-traceback`:

Full output: [output.txt](https://github.com/pypa/virtualenv/files/7167331/output.txt)

tail:
```
1048 create virtualenv import hook file /tmp/z/lib/pypy3.8/site-packages/_virtualenv.pth [DEBUG api:95]
Traceback (most recent call last):
  File "/usr/lib/pypy3.8/runpy.py", line 198, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/pypy3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/pypy3.8/site-packages/virtualenv/__main__.py", line 80, in <module>
    run_with_catch()  # pragma: no cov
  File "/usr/lib/pypy3.8/site-packages/virtualenv/__main__.py", line 65, in run_with_catch
    run(args, options, env)
  File "/usr/lib/pypy3.8/site-packages/virtualenv/__main__.py", line 18, in run
    session = cli_run(args, options, env)
  File "/usr/lib/pypy3.8/site-packages/virtualenv/run/__init__.py", line 32, in cli_run
    of_session.run()
  File "/usr/lib/pypy3.8/site-packages/virtualenv/run/session.py", line 46, in run
    self._create()
  File "/usr/lib/pypy3.8/site-packages/virtualenv/run/session.py", line 53, in _create
    self.creator.run()
  File "/usr/lib/pypy3.8/site-packages/virtualenv/create/creator.py", line 171, in run
    self.create()
  File "/usr/lib/pypy3.8/site-packages/virtualenv/create/via_global_ref/builtin/via_global_self_do.py", line 101, in create
    super(ViaGlobalRefVirtualenvBuiltin, self).create()
  File "/usr/lib/pypy3.8/site-packages/virtualenv/create/via_global_ref/api.py", line 89, in create
    self.install_patch()
  File "/usr/lib/pypy3.8/site-packages/virtualenv/create/via_global_ref/api.py", line 96, in install_patch
    pth.write_text("import _virtualenv")
  File "/usr/lib/pypy3.8/pathlib.py", line 1255, in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
  File "/usr/lib/pypy3.8/pathlib.py", line 1223, in open
    opener=self._opener)
  File "/usr/lib/pypy3.8/pathlib.py", line 1078, in _opener
    return self._accessor.open(self, flags, mode)
PermissionError: [Errno 13] Permission denied: PosixPath('/tmp/z/lib/pypy3.8/site-packages/_virtualenv.pth')
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py`
Content:
```
1 from __future__ import absolute_import, unicode_literals
2 
3 import abc
4 
5 from six import add_metaclass
6 
7 from virtualenv.create.describe import PosixSupports, Python3Supports, WindowsSupports
8 from virtualenv.create.via_global_ref.builtin.ref import PathRefToDest
9 from virtualenv.util.path import Path
10 
11 from .common import PyPy
12 
13 
14 @add_metaclass(abc.ABCMeta)
15 class PyPy3(PyPy, Python3Supports):
16     @classmethod
17     def exe_stem(cls):
18         return "pypy3"
19 
20     @classmethod
21     def exe_names(cls, interpreter):
22         return super(PyPy3, cls).exe_names(interpreter) | {"pypy"}
23 
24 
25 class PyPy3Posix(PyPy3, PosixSupports):
26     """PyPy 2 on POSIX"""
27 
28     @property
29     def stdlib(self):
30         """PyPy3 respects sysconfig only for the host python, virtual envs is instead lib/pythonx.y/site-packages"""
31         return self.dest / "lib" / "python{}".format(self.interpreter.version_release_str) / "site-packages"
32 
33     @classmethod
34     def _shared_libs(cls):
35         return ["libpypy3-c.so", "libpypy3-c.dylib"]
36 
37     def to_lib(self, src):
38         return self.dest / "lib" / src.name
39 
40     @classmethod
41     def sources(cls, interpreter):
42         for src in super(PyPy3Posix, cls).sources(interpreter):
43             yield src
44         host_lib = Path(interpreter.system_prefix) / "lib"
45         if host_lib.exists() and host_lib.is_dir():
46             for path in host_lib.iterdir():
47                 yield PathRefToDest(path, dest=cls.to_lib)
48 
49 
50 class Pypy3Windows(PyPy3, WindowsSupports):
51     """PyPy 2 on Windows"""
52 
53     @property
54     def stdlib(self):
55         """PyPy3 respects sysconfig only for the host python, virtual envs is instead Lib/site-packages"""
56         return self.dest / "Lib" / "site-packages"
57 
58     @property
59     def bin_dir(self):
60         """PyPy3 needs to fallback to pypy definition"""
61         return self.dest / "Scripts"
62 
63     @classmethod
64     def _shared_libs(cls):
65         return ["libpypy3-c.dll", "libffi-7.dll"]
66
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py
--- a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py
+++ b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py
@@ -28,7 +28,7 @@
     @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):
@@ -41,9 +41,19 @@
     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)

{"golden_diff": "diff --git a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py\n--- a/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py\n+++ b/src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py\n@@ -28,7 +28,7 @@\n     @property\n     def stdlib(self):\n         \"\"\"PyPy3 respects sysconfig only for the host python, virtual envs is instead lib/pythonx.y/site-packages\"\"\"\n-        return self.dest / \"lib\" / \"python{}\".format(self.interpreter.version_release_str) / \"site-packages\"\n+        return self.dest / \"lib\" / \"pypy{}\".format(self.interpreter.version_release_str) / \"site-packages\"\n \n     @classmethod\n     def _shared_libs(cls):\n@@ -41,9 +41,19 @@\n     def sources(cls, interpreter):\n         for src in super(PyPy3Posix, cls).sources(interpreter):\n             yield src\n+        # Also copy/symlink anything under prefix/lib, which, for \"portable\"\n+        # PyPy builds, includes the tk,tcl runtime and a number of shared\n+        # objects. In distro-specific builds or on conda this should be empty\n+        # (on PyPy3.8+ it will, like on CPython, hold the stdlib).\n         host_lib = Path(interpreter.system_prefix) / \"lib\"\n+        stdlib = Path(interpreter.system_stdlib)\n         if host_lib.exists() and host_lib.is_dir():\n             for path in host_lib.iterdir():\n+                if stdlib == path:\n+                    # For PyPy3.8+ the stdlib lives in lib/pypy3.8\n+                    # We need to avoid creating a symlink to it since that\n+                    # will defeat the purpose of a virtualenv\n+                    continue\n                 yield PathRefToDest(path, dest=cls.to_lib)\n", "issue": "Incorrect (broken) virtualenv layout with pypy3.8's new layout\n**Issue**\r\n\r\nPyPy3.8 (currently 7.3.6rc1) supports a new install layout that resembles CPython more. That is, `sys.prefix` no longer needs being isolated, and site-packages are found in `$prefix/lib/pypy3.8/site-packages`. However, virtualenv tries to symlink everything from `/usr/lib` including the `pypy3.8` directory. As a result, the user can't write to the site-packages directory in the venv.\r\n\r\nI haven't tried running it as root but I can imagine it doing major mess if it virtualenv doesn't take any precautions from writing into system directories.\r\n\r\n**Environment**\r\n\r\nProvide at least:\r\n- OS: Gentoo Linux\r\n- ``pip list`` of the host python where ``virtualenv`` is installed: [pip-list.txt](https://github.com/pypa/virtualenv/files/7167321/pip-list.txt)\r\n\r\n\r\n**Output of the virtual environment creation**\r\n\r\nMake sure to run the creation with `-vvv --with-traceback`:\r\n\r\nFull output: [output.txt](https://github.com/pypa/virtualenv/files/7167331/output.txt)\r\n\r\ntail:\r\n```\r\n1048 create virtualenv import hook file /tmp/z/lib/pypy3.8/site-packages/_virtualenv.pth [DEBUG api:95]\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/pypy3.8/runpy.py\", line 198, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/lib/pypy3.8/runpy.py\", line 87, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/__main__.py\", line 80, in <module>\r\n    run_with_catch()  # pragma: no cov\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/__main__.py\", line 65, in run_with_catch\r\n    run(args, options, env)\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/__main__.py\", line 18, in run\r\n    session = cli_run(args, options, env)\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/run/__init__.py\", line 32, in cli_run\r\n    of_session.run()\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/run/session.py\", line 46, in run\r\n    self._create()\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/run/session.py\", line 53, in _create\r\n    self.creator.run()\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/create/creator.py\", line 171, in run\r\n    self.create()\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/create/via_global_ref/builtin/via_global_self_do.py\", line 101, in create\r\n    super(ViaGlobalRefVirtualenvBuiltin, self).create()\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/create/via_global_ref/api.py\", line 89, in create\r\n    self.install_patch()\r\n  File \"/usr/lib/pypy3.8/site-packages/virtualenv/create/via_global_ref/api.py\", line 96, in install_patch\r\n    pth.write_text(\"import _virtualenv\")\r\n  File \"/usr/lib/pypy3.8/pathlib.py\", line 1255, in write_text\r\n    with self.open(mode='w', encoding=encoding, errors=errors) as f:\r\n  File \"/usr/lib/pypy3.8/pathlib.py\", line 1223, in open\r\n    opener=self._opener)\r\n  File \"/usr/lib/pypy3.8/pathlib.py\", line 1078, in _opener\r\n    return self._accessor.open(self, flags, mode)\r\nPermissionError: [Errno 13] Permission denied: PosixPath('/tmp/z/lib/pypy3.8/site-packages/_virtualenv.pth')\r\n```\n", "before_files": [{"content": "from __future__ import absolute_import, unicode_literals\n\nimport abc\n\nfrom six import add_metaclass\n\nfrom virtualenv.create.describe import PosixSupports, Python3Supports, WindowsSupports\nfrom virtualenv.create.via_global_ref.builtin.ref import PathRefToDest\nfrom virtualenv.util.path import Path\n\nfrom .common import PyPy\n\n\n@add_metaclass(abc.ABCMeta)\nclass PyPy3(PyPy, Python3Supports):\n    @classmethod\n    def exe_stem(cls):\n        return \"pypy3\"\n\n    @classmethod\n    def exe_names(cls, interpreter):\n        return super(PyPy3, cls).exe_names(interpreter) | {\"pypy\"}\n\n\nclass PyPy3Posix(PyPy3, PosixSupports):\n    \"\"\"PyPy 2 on POSIX\"\"\"\n\n    @property\n    def stdlib(self):\n        \"\"\"PyPy3 respects sysconfig only for the host python, virtual envs is instead lib/pythonx.y/site-packages\"\"\"\n        return self.dest / \"lib\" / \"python{}\".format(self.interpreter.version_release_str) / \"site-packages\"\n\n    @classmethod\n    def _shared_libs(cls):\n        return [\"libpypy3-c.so\", \"libpypy3-c.dylib\"]\n\n    def to_lib(self, src):\n        return self.dest / \"lib\" / src.name\n\n    @classmethod\n    def sources(cls, interpreter):\n        for src in super(PyPy3Posix, cls).sources(interpreter):\n            yield src\n        host_lib = Path(interpreter.system_prefix) / \"lib\"\n        if host_lib.exists() and host_lib.is_dir():\n            for path in host_lib.iterdir():\n                yield PathRefToDest(path, dest=cls.to_lib)\n\n\nclass Pypy3Windows(PyPy3, WindowsSupports):\n    \"\"\"PyPy 2 on Windows\"\"\"\n\n    @property\n    def stdlib(self):\n        \"\"\"PyPy3 respects sysconfig only for the host python, virtual envs is instead Lib/site-packages\"\"\"\n        return self.dest / \"Lib\" / \"site-packages\"\n\n    @property\n    def bin_dir(self):\n        \"\"\"PyPy3 needs to fallback to pypy definition\"\"\"\n        return self.dest / \"Scripts\"\n\n    @classmethod\n    def _shared_libs(cls):\n        return [\"libpypy3-c.dll\", \"libffi-7.dll\"]\n", "path": "src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py"}], "after_files": [{"content": "from __future__ import absolute_import, unicode_literals\n\nimport abc\n\nfrom six import add_metaclass\n\nfrom virtualenv.create.describe import PosixSupports, Python3Supports, WindowsSupports\nfrom virtualenv.create.via_global_ref.builtin.ref import PathRefToDest\nfrom virtualenv.util.path import Path\n\nfrom .common import PyPy\n\n\n@add_metaclass(abc.ABCMeta)\nclass PyPy3(PyPy, Python3Supports):\n    @classmethod\n    def exe_stem(cls):\n        return \"pypy3\"\n\n    @classmethod\n    def exe_names(cls, interpreter):\n        return super(PyPy3, cls).exe_names(interpreter) | {\"pypy\"}\n\n\nclass PyPy3Posix(PyPy3, PosixSupports):\n    \"\"\"PyPy 2 on POSIX\"\"\"\n\n    @property\n    def stdlib(self):\n        \"\"\"PyPy3 respects sysconfig only for the host python, virtual envs is instead lib/pythonx.y/site-packages\"\"\"\n        return self.dest / \"lib\" / \"pypy{}\".format(self.interpreter.version_release_str) / \"site-packages\"\n\n    @classmethod\n    def _shared_libs(cls):\n        return [\"libpypy3-c.so\", \"libpypy3-c.dylib\"]\n\n    def to_lib(self, src):\n        return self.dest / \"lib\" / src.name\n\n    @classmethod\n    def sources(cls, interpreter):\n        for src in super(PyPy3Posix, cls).sources(interpreter):\n            yield src\n        # Also copy/symlink anything under prefix/lib, which, for \"portable\"\n        # PyPy builds, includes the tk,tcl runtime and a number of shared\n        # objects. In distro-specific builds or on conda this should be empty\n        # (on PyPy3.8+ it will, like on CPython, hold the stdlib).\n        host_lib = Path(interpreter.system_prefix) / \"lib\"\n        stdlib = Path(interpreter.system_stdlib)\n        if host_lib.exists() and host_lib.is_dir():\n            for path in host_lib.iterdir():\n                if stdlib == path:\n                    # For PyPy3.8+ the stdlib lives in lib/pypy3.8\n                    # We need to avoid creating a symlink to it since that\n                    # will defeat the purpose of a virtualenv\n                    continue\n                yield PathRefToDest(path, dest=cls.to_lib)\n\n\nclass Pypy3Windows(PyPy3, WindowsSupports):\n    \"\"\"PyPy 2 on Windows\"\"\"\n\n    @property\n    def stdlib(self):\n        \"\"\"PyPy3 respects sysconfig only for the host python, virtual envs is instead Lib/site-packages\"\"\"\n        return self.dest / \"Lib\" / \"site-packages\"\n\n    @property\n    def bin_dir(self):\n        \"\"\"PyPy3 needs to fallback to pypy definition\"\"\"\n        return self.dest / \"Scripts\"\n\n    @classmethod\n    def _shared_libs(cls):\n        return [\"libpypy3-c.dll\", \"libffi-7.dll\"]\n", "path": "src/virtualenv/create/via_global_ref/builtin/pypy/pypy3.py"}]}