We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Poetry 1.4.0: There is no item named `<package>/WHEEL` in the archive
<!--
    Hi there! Thank you for submitting a bug report!

    Before you submit your issue, please review and follow the instructions at
    https://python-poetry.org/docs/contributing/#reporting-bugs. Fully fill out the template below; insufficient
    information or bad reproduction instructions will impair the ability of others to help you.
-->

<!-- All the below information must be provided for others to understand and help with your issue. -->
- **Poetry version**: 1.4.0<!-- Replace with version, e.g. from `poetry --version` -->
- **Python version**: 3.11<!-- Replace with the version of Python being used to run Poetry, as reported by `poetry debug info` -->
- **OS version and name**: macOS 13.2.1/MacPorts <!-- Replace with version + name, e.g. Ubuntu 22.04 or macOS 12.6 -->
- **pyproject.toml**: https://gist.github.com/elventear/2410f2f8a05926df27488767cfcab780<!-- Replace with a link to a Gist (https://gist.github.com/) containing your sanitized pyproject.toml -->

<!-- All the below steps should be completed before submitting your issue. Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) stable Poetry version, installed using a recommended method.
- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [x] I have consulted the [FAQ](https://python-poetry.org/docs/faq/) and [blog](https://python-poetry.org/blog/) for any relevant entries or release notes.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option) and have included the output below.

## Issue

Hypercorn can't be installed with poetry 1.4.0, it used to be possible to install it:

<!-- Now feel free to write your issue, and please be as descriptive as possible! Make sure to include detailed reproduction steps. -->
<!-- Thanks again 🙌 ❤ -->

```
poetry install                                                                                                                                                                                                          
Creating virtualenv test in /path/to/.venv
Updating dependencies
Resolving dependencies... (0.4s)

Writing lock file

Package operations: 8 installs, 0 updates, 0 removals

  • Installing h11 (0.14.0)
  • Installing hpack (4.0.0)
  • Installing hyperframe (6.0.1)
  • Installing h2 (4.1.0)
  • Installing priority (2.0.0)
  • Installing toml (0.10.2)
  • Installing wsproto (1.2.0)
  • Installing hypercorn (0.14.3): Failed

  Stack trace:

  10  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:271 in _execute_operation
       269│
       270│             try:
     → 271│                 result = self._do_execute_operation(operation)
       272│             except EnvCommandError as e:
       273│                 if e.e.returncode == -2:

   9  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:357 in _do_execute_operation
       355│             return 0
       356│
     → 357│         result: int = getattr(self, f"_execute_{method}")(operation)
       358│
       359│         if result != 0:

   8  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:477 in _execute_install
       475│
       476│     def _execute_install(self, operation: Install | Update) -> int:
     → 477│         status_code = self._install(operation)
       478│
       479│         self._save_url_reference(operation)

   7  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:535 in _install
       533│                 self._remove(operation.initial_package)
       534│
     → 535│             self._wheel_installer.install(archive)
       536│         finally:
       537│             if cleanup_archive:

   6  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/wheel_installer.py:101 in install
        99│     def install(self, wheel: Path) -> None:
       100│         with WheelFile.open(Path(wheel.as_posix())) as source:
     → 101│             install(
       102│                 source=source,
       103│                 destination=self._destination.for_source(source),

   5  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/_core.py:77 in install
        75│
        76│     """
     →  77│     root_scheme = _process_WHEEL_file(source)
        78│
        79│     # RECORD handling

   4  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/_core.py:21 in _process_WHEEL_file
        19│     Returns the scheme that the archive root should go in.
        20│     """
     →  21│     stream = source.read_dist_info("WHEEL")
        22│     metadata = parse_metadata_file(stream)
        23│

   3  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/sources.py:139 in read_dist_info
       137│         """Get contents, from ``filename`` in the dist-info directory."""
       138│         path = posixpath.join(self.dist_info_dir, filename)
     → 139│         return self._zipfile.read(path).decode("utf-8")
       140│
       141│     def get_contents(self) -> Iterator[WheelContentElement]:

   2  /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1507 in read
       1505│     def read(self, name, pwd=None):
       1506│         """Return file bytes for name."""
     → 1507│         with self.open(name, "r", pwd) as fp:
       1508│             return fp.read()
       1509│

   1  /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1544 in open
       1542│         else:
       1543│             # Get info object for name
     → 1544│             zinfo = self.getinfo(name)
       1545│
       1546│         if mode == 'w':

  KeyError

  "There is no item named 'Hypercorn-0.14.3.dist-info/WHEEL' in the archive"

  at /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1473 in getinfo
      1469│     def getinfo(self, name):
      1470│         """Return the instance of ZipInfo given 'name'."""
      1471│         info = self.NameToInfo.get(name)
      1472│         if info is None:
    → 1473│             raise KeyError(
      1474│                 'There is no item named %r in the archive' % name)
      1475│
      1476│         return info
```

Wondering if there is a case sensitivity issue. Looking at the wheel, I do see there is a file in `hypercorn-0.14.3.dist-info/WHEEL`. 

Latest 1.4.0 release causes unclear Issue with aws_psycopg2 install
- **Poetry version**: `1.4.0`
- **Python version**: `python3.9`

<!-- All the below steps should be completed before submitting your issue. Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) stable Poetry version, installed using a recommended method.
- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [ ] I have consulted the [FAQ](https://python-poetry.org/docs/faq/) and [blog](https://python-poetry.org/blog/) for any relevant entries or release notes.
- [ ] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option) and have included the output below.

## Issue
<!-- Now feel free to write your issue, and please be as descriptive as possible! Make sure to include detailed reproduction steps. -->
<!-- Thanks again 🙌 ❤ -->

When using the latest version, `1.4.0` we get the following runtime error:

```
  Installing sqlalchemy (1.4.46)

  AssertionError

  In /builds/project-0/.cache/pypoetry/artifacts/39/96/f1/0f021ed26225e8d9035c9bac5a886b024840f841af84bd33f2be466dcb/aws_psycopg2-1.3.8-py3-none-any.whl, psycopg2/_psycopg.cpython-38-aarch64-linux-gnu.so is not mentioned in RECORD

  at venv/lib/python3.9/site-packages/installer/sources.py:158 in get_contents
      154│             if item.filename[-1:] == "/":  # looks like a directory
      155│                 continue
      156│ 
      157│             record = record_mapping.pop(item.filename, None)
    → 158│             assert record is not None, "In {}, {} is not mentioned in RECORD".format(
      159│                 self._zipfile.filename,
      160│                 item.filename,
      161│             )  # should not happen for valid wheels
      162│ 
```

However, when we downgrade to `poetry==1.3.2` this problem goes away...

--- 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/poetry/installation/wheel_installer.py`
Content:
```
1 from __future__ import annotations
2 
3 import os
4 import platform
5 import sys
6 
7 from pathlib import Path
8 from typing import TYPE_CHECKING
9 
10 from installer import install
11 from installer.destinations import SchemeDictionaryDestination
12 from installer.sources import WheelFile
13 
14 from poetry.__version__ import __version__
15 from poetry.utils._compat import WINDOWS
16 
17 
18 if TYPE_CHECKING:
19     from typing import BinaryIO
20 
21     from installer.records import RecordEntry
22     from installer.scripts import LauncherKind
23     from installer.utils import Scheme
24 
25     from poetry.utils.env import Env
26 
27 
28 class WheelDestination(SchemeDictionaryDestination):
29     """ """
30 
31     def write_to_fs(
32         self,
33         scheme: Scheme,
34         path: Path | str,
35         stream: BinaryIO,
36         is_executable: bool,
37     ) -> RecordEntry:
38         from installer.records import Hash
39         from installer.records import RecordEntry
40         from installer.utils import copyfileobj_with_hashing
41         from installer.utils import make_file_executable
42 
43         target_path = Path(self.scheme_dict[scheme]) / path
44         if target_path.exists():
45             # Contrary to the base library we don't raise an error
46             # here since it can break namespace packages (like Poetry's)
47             pass
48 
49         parent_folder = target_path.parent
50         if not parent_folder.exists():
51             # Due to the parallel installation it can happen
52             # that two threads try to create the directory.
53             os.makedirs(parent_folder, exist_ok=True)
54 
55         with open(target_path, "wb") as f:
56             hash_, size = copyfileobj_with_hashing(stream, f, self.hash_algorithm)
57 
58         if is_executable:
59             make_file_executable(target_path)
60 
61         return RecordEntry(str(path), Hash(self.hash_algorithm, hash_), size)
62 
63     def for_source(self, source: WheelFile) -> WheelDestination:
64         scheme_dict = self.scheme_dict.copy()
65 
66         scheme_dict["headers"] = str(Path(scheme_dict["headers"]) / source.distribution)
67 
68         return self.__class__(
69             scheme_dict,
70             interpreter=self.interpreter,
71             script_kind=self.script_kind,
72             bytecode_optimization_levels=self.bytecode_optimization_levels,
73         )
74 
75 
76 class WheelInstaller:
77     def __init__(self, env: Env) -> None:
78         self._env = env
79 
80         script_kind: LauncherKind
81         if not WINDOWS:
82             script_kind = "posix"
83         else:
84             if platform.uname()[4].startswith("arm"):
85                 script_kind = "win-arm64" if sys.maxsize > 2**32 else "win-arm"
86             else:
87                 script_kind = "win-amd64" if sys.maxsize > 2**32 else "win-ia32"
88 
89         schemes = self._env.paths
90         schemes["headers"] = schemes["include"]
91 
92         self._destination = WheelDestination(
93             schemes, interpreter=self._env.python, script_kind=script_kind
94         )
95 
96     def enable_bytecode_compilation(self, enable: bool = True) -> None:
97         self._destination.bytecode_optimization_levels = (1,) if enable else ()
98 
99     def install(self, wheel: Path) -> None:
100         with WheelFile.open(Path(wheel.as_posix())) as source:
101             install(
102                 source=source,
103                 destination=self._destination.for_source(source),
104                 # Additional metadata that is generated by the installation tool.
105                 additional_metadata={
106                     "INSTALLER": f"Poetry {__version__}".encode(),
107                 },
108             )
109
```
--- 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/poetry/installation/wheel_installer.py b/src/poetry/installation/wheel_installer.py
--- a/src/poetry/installation/wheel_installer.py
+++ b/src/poetry/installation/wheel_installer.py
@@ -97,7 +97,8 @@
         self._destination.bytecode_optimization_levels = (1,) if enable else ()
 
     def install(self, wheel: Path) -> None:
-        with WheelFile.open(Path(wheel.as_posix())) as source:
+        with WheelFile.open(wheel) as source:
+            source.validate_record()
             install(
                 source=source,
                 destination=self._destination.for_source(source),

{"golden_diff": "diff --git a/src/poetry/installation/wheel_installer.py b/src/poetry/installation/wheel_installer.py\n--- a/src/poetry/installation/wheel_installer.py\n+++ b/src/poetry/installation/wheel_installer.py\n@@ -97,7 +97,8 @@\n         self._destination.bytecode_optimization_levels = (1,) if enable else ()\n \n     def install(self, wheel: Path) -> None:\n-        with WheelFile.open(Path(wheel.as_posix())) as source:\n+        with WheelFile.open(wheel) as source:\n+            source.validate_record()\n             install(\n                 source=source,\n                 destination=self._destination.for_source(source),\n", "issue": "Poetry 1.4.0: There is no item named `<package>/WHEEL` in the archive\n<!--\r\n    Hi there! Thank you for submitting a bug report!\r\n\r\n    Before you submit your issue, please review and follow the instructions at\r\n    https://python-poetry.org/docs/contributing/#reporting-bugs. Fully fill out the template below; insufficient\r\n    information or bad reproduction instructions will impair the ability of others to help you.\r\n-->\r\n\r\n<!-- All the below information must be provided for others to understand and help with your issue. -->\r\n- **Poetry version**: 1.4.0<!-- Replace with version, e.g. from `poetry --version` -->\r\n- **Python version**: 3.11<!-- Replace with the version of Python being used to run Poetry, as reported by `poetry debug info` -->\r\n- **OS version and name**: macOS 13.2.1/MacPorts <!-- Replace with version + name, e.g. Ubuntu 22.04 or macOS 12.6 -->\r\n- **pyproject.toml**: https://gist.github.com/elventear/2410f2f8a05926df27488767cfcab780<!-- Replace with a link to a Gist (https://gist.github.com/) containing your sanitized pyproject.toml -->\r\n\r\n<!-- All the below steps should be completed before submitting your issue. Checked checkbox should look like this: [x] -->\r\n- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) stable Poetry version, installed using a recommended method.\r\n- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.\r\n- [x] I have consulted the [FAQ](https://python-poetry.org/docs/faq/) and [blog](https://python-poetry.org/blog/) for any relevant entries or release notes.\r\n- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option) and have included the output below.\r\n\r\n## Issue\r\n\r\nHypercorn can't be installed with poetry 1.4.0, it used to be possible to install it:\r\n\r\n<!-- Now feel free to write your issue, and please be as descriptive as possible! Make sure to include detailed reproduction steps. -->\r\n<!-- Thanks again \ud83d\ude4c \u2764 -->\r\n\r\n```\r\npoetry install                                                                                                                                                                                                          \r\nCreating virtualenv test in /path/to/.venv\r\nUpdating dependencies\r\nResolving dependencies... (0.4s)\r\n\r\nWriting lock file\r\n\r\nPackage operations: 8 installs, 0 updates, 0 removals\r\n\r\n  \u2022 Installing h11 (0.14.0)\r\n  \u2022 Installing hpack (4.0.0)\r\n  \u2022 Installing hyperframe (6.0.1)\r\n  \u2022 Installing h2 (4.1.0)\r\n  \u2022 Installing priority (2.0.0)\r\n  \u2022 Installing toml (0.10.2)\r\n  \u2022 Installing wsproto (1.2.0)\r\n  \u2022 Installing hypercorn (0.14.3): Failed\r\n\r\n  Stack trace:\r\n\r\n  10  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:271 in _execute_operation\r\n       269\u2502\r\n       270\u2502             try:\r\n     \u2192 271\u2502                 result = self._do_execute_operation(operation)\r\n       272\u2502             except EnvCommandError as e:\r\n       273\u2502                 if e.e.returncode == -2:\r\n\r\n   9  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:357 in _do_execute_operation\r\n       355\u2502             return 0\r\n       356\u2502\r\n     \u2192 357\u2502         result: int = getattr(self, f\"_execute_{method}\")(operation)\r\n       358\u2502\r\n       359\u2502         if result != 0:\r\n\r\n   8  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:477 in _execute_install\r\n       475\u2502\r\n       476\u2502     def _execute_install(self, operation: Install | Update) -> int:\r\n     \u2192 477\u2502         status_code = self._install(operation)\r\n       478\u2502\r\n       479\u2502         self._save_url_reference(operation)\r\n\r\n   7  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/executor.py:535 in _install\r\n       533\u2502                 self._remove(operation.initial_package)\r\n       534\u2502\r\n     \u2192 535\u2502             self._wheel_installer.install(archive)\r\n       536\u2502         finally:\r\n       537\u2502             if cleanup_archive:\r\n\r\n   6  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/installation/wheel_installer.py:101 in install\r\n        99\u2502     def install(self, wheel: Path) -> None:\r\n       100\u2502         with WheelFile.open(Path(wheel.as_posix())) as source:\r\n     \u2192 101\u2502             install(\r\n       102\u2502                 source=source,\r\n       103\u2502                 destination=self._destination.for_source(source),\r\n\r\n   5  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/_core.py:77 in install\r\n        75\u2502\r\n        76\u2502     \"\"\"\r\n     \u2192  77\u2502     root_scheme = _process_WHEEL_file(source)\r\n        78\u2502\r\n        79\u2502     # RECORD handling\r\n\r\n   4  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/_core.py:21 in _process_WHEEL_file\r\n        19\u2502     Returns the scheme that the archive root should go in.\r\n        20\u2502     \"\"\"\r\n     \u2192  21\u2502     stream = source.read_dist_info(\"WHEEL\")\r\n        22\u2502     metadata = parse_metadata_file(stream)\r\n        23\u2502\r\n\r\n   3  ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/installer/sources.py:139 in read_dist_info\r\n       137\u2502         \"\"\"Get contents, from ``filename`` in the dist-info directory.\"\"\"\r\n       138\u2502         path = posixpath.join(self.dist_info_dir, filename)\r\n     \u2192 139\u2502         return self._zipfile.read(path).decode(\"utf-8\")\r\n       140\u2502\r\n       141\u2502     def get_contents(self) -> Iterator[WheelContentElement]:\r\n\r\n   2  /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1507 in read\r\n       1505\u2502     def read(self, name, pwd=None):\r\n       1506\u2502         \"\"\"Return file bytes for name.\"\"\"\r\n     \u2192 1507\u2502         with self.open(name, \"r\", pwd) as fp:\r\n       1508\u2502             return fp.read()\r\n       1509\u2502\r\n\r\n   1  /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1544 in open\r\n       1542\u2502         else:\r\n       1543\u2502             # Get info object for name\r\n     \u2192 1544\u2502             zinfo = self.getinfo(name)\r\n       1545\u2502\r\n       1546\u2502         if mode == 'w':\r\n\r\n  KeyError\r\n\r\n  \"There is no item named 'Hypercorn-0.14.3.dist-info/WHEEL' in the archive\"\r\n\r\n  at /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/zipfile.py:1473 in getinfo\r\n      1469\u2502     def getinfo(self, name):\r\n      1470\u2502         \"\"\"Return the instance of ZipInfo given 'name'.\"\"\"\r\n      1471\u2502         info = self.NameToInfo.get(name)\r\n      1472\u2502         if info is None:\r\n    \u2192 1473\u2502             raise KeyError(\r\n      1474\u2502                 'There is no item named %r in the archive' % name)\r\n      1475\u2502\r\n      1476\u2502         return info\r\n```\r\n\r\nWondering if there is a case sensitivity issue. Looking at the wheel, I do see there is a file in `hypercorn-0.14.3.dist-info/WHEEL`. \r\n\nLatest 1.4.0 release causes unclear Issue with aws_psycopg2 install\n- **Poetry version**: `1.4.0`\r\n- **Python version**: `python3.9`\r\n\r\n<!-- All the below steps should be completed before submitting your issue. Checked checkbox should look like this: [x] -->\r\n- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) stable Poetry version, installed using a recommended method.\r\n- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.\r\n- [ ] I have consulted the [FAQ](https://python-poetry.org/docs/faq/) and [blog](https://python-poetry.org/blog/) for any relevant entries or release notes.\r\n- [ ] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option) and have included the output below.\r\n\r\n## Issue\r\n<!-- Now feel free to write your issue, and please be as descriptive as possible! Make sure to include detailed reproduction steps. -->\r\n<!-- Thanks again \ud83d\ude4c \u2764 -->\r\n\r\nWhen using the latest version, `1.4.0` we get the following runtime error:\r\n\r\n```\r\n  Installing sqlalchemy (1.4.46)\r\n\r\n  AssertionError\r\n\r\n  In /builds/project-0/.cache/pypoetry/artifacts/39/96/f1/0f021ed26225e8d9035c9bac5a886b024840f841af84bd33f2be466dcb/aws_psycopg2-1.3.8-py3-none-any.whl, psycopg2/_psycopg.cpython-38-aarch64-linux-gnu.so is not mentioned in RECORD\r\n\r\n  at venv/lib/python3.9/site-packages/installer/sources.py:158 in get_contents\r\n      154\u2502             if item.filename[-1:] == \"/\":  # looks like a directory\r\n      155\u2502                 continue\r\n      156\u2502 \r\n      157\u2502             record = record_mapping.pop(item.filename, None)\r\n    \u2192 158\u2502             assert record is not None, \"In {}, {} is not mentioned in RECORD\".format(\r\n      159\u2502                 self._zipfile.filename,\r\n      160\u2502                 item.filename,\r\n      161\u2502             )  # should not happen for valid wheels\r\n      162\u2502 \r\n```\r\n\r\nHowever, when we downgrade to `poetry==1.3.2` this problem goes away...\n", "before_files": [{"content": "from __future__ import annotations\n\nimport os\nimport platform\nimport sys\n\nfrom pathlib import Path\nfrom typing import TYPE_CHECKING\n\nfrom installer import install\nfrom installer.destinations import SchemeDictionaryDestination\nfrom installer.sources import WheelFile\n\nfrom poetry.__version__ import __version__\nfrom poetry.utils._compat import WINDOWS\n\n\nif TYPE_CHECKING:\n    from typing import BinaryIO\n\n    from installer.records import RecordEntry\n    from installer.scripts import LauncherKind\n    from installer.utils import Scheme\n\n    from poetry.utils.env import Env\n\n\nclass WheelDestination(SchemeDictionaryDestination):\n    \"\"\" \"\"\"\n\n    def write_to_fs(\n        self,\n        scheme: Scheme,\n        path: Path | str,\n        stream: BinaryIO,\n        is_executable: bool,\n    ) -> RecordEntry:\n        from installer.records import Hash\n        from installer.records import RecordEntry\n        from installer.utils import copyfileobj_with_hashing\n        from installer.utils import make_file_executable\n\n        target_path = Path(self.scheme_dict[scheme]) / path\n        if target_path.exists():\n            # Contrary to the base library we don't raise an error\n            # here since it can break namespace packages (like Poetry's)\n            pass\n\n        parent_folder = target_path.parent\n        if not parent_folder.exists():\n            # Due to the parallel installation it can happen\n            # that two threads try to create the directory.\n            os.makedirs(parent_folder, exist_ok=True)\n\n        with open(target_path, \"wb\") as f:\n            hash_, size = copyfileobj_with_hashing(stream, f, self.hash_algorithm)\n\n        if is_executable:\n            make_file_executable(target_path)\n\n        return RecordEntry(str(path), Hash(self.hash_algorithm, hash_), size)\n\n    def for_source(self, source: WheelFile) -> WheelDestination:\n        scheme_dict = self.scheme_dict.copy()\n\n        scheme_dict[\"headers\"] = str(Path(scheme_dict[\"headers\"]) / source.distribution)\n\n        return self.__class__(\n            scheme_dict,\n            interpreter=self.interpreter,\n            script_kind=self.script_kind,\n            bytecode_optimization_levels=self.bytecode_optimization_levels,\n        )\n\n\nclass WheelInstaller:\n    def __init__(self, env: Env) -> None:\n        self._env = env\n\n        script_kind: LauncherKind\n        if not WINDOWS:\n            script_kind = \"posix\"\n        else:\n            if platform.uname()[4].startswith(\"arm\"):\n                script_kind = \"win-arm64\" if sys.maxsize > 2**32 else \"win-arm\"\n            else:\n                script_kind = \"win-amd64\" if sys.maxsize > 2**32 else \"win-ia32\"\n\n        schemes = self._env.paths\n        schemes[\"headers\"] = schemes[\"include\"]\n\n        self._destination = WheelDestination(\n            schemes, interpreter=self._env.python, script_kind=script_kind\n        )\n\n    def enable_bytecode_compilation(self, enable: bool = True) -> None:\n        self._destination.bytecode_optimization_levels = (1,) if enable else ()\n\n    def install(self, wheel: Path) -> None:\n        with WheelFile.open(Path(wheel.as_posix())) as source:\n            install(\n                source=source,\n                destination=self._destination.for_source(source),\n                # Additional metadata that is generated by the installation tool.\n                additional_metadata={\n                    \"INSTALLER\": f\"Poetry {__version__}\".encode(),\n                },\n            )\n", "path": "src/poetry/installation/wheel_installer.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport os\nimport platform\nimport sys\n\nfrom pathlib import Path\nfrom typing import TYPE_CHECKING\n\nfrom installer import install\nfrom installer.destinations import SchemeDictionaryDestination\nfrom installer.sources import WheelFile\n\nfrom poetry.__version__ import __version__\nfrom poetry.utils._compat import WINDOWS\n\n\nif TYPE_CHECKING:\n    from typing import BinaryIO\n\n    from installer.records import RecordEntry\n    from installer.scripts import LauncherKind\n    from installer.utils import Scheme\n\n    from poetry.utils.env import Env\n\n\nclass WheelDestination(SchemeDictionaryDestination):\n    \"\"\" \"\"\"\n\n    def write_to_fs(\n        self,\n        scheme: Scheme,\n        path: Path | str,\n        stream: BinaryIO,\n        is_executable: bool,\n    ) -> RecordEntry:\n        from installer.records import Hash\n        from installer.records import RecordEntry\n        from installer.utils import copyfileobj_with_hashing\n        from installer.utils import make_file_executable\n\n        target_path = Path(self.scheme_dict[scheme]) / path\n        if target_path.exists():\n            # Contrary to the base library we don't raise an error\n            # here since it can break namespace packages (like Poetry's)\n            pass\n\n        parent_folder = target_path.parent\n        if not parent_folder.exists():\n            # Due to the parallel installation it can happen\n            # that two threads try to create the directory.\n            os.makedirs(parent_folder, exist_ok=True)\n\n        with open(target_path, \"wb\") as f:\n            hash_, size = copyfileobj_with_hashing(stream, f, self.hash_algorithm)\n\n        if is_executable:\n            make_file_executable(target_path)\n\n        return RecordEntry(str(path), Hash(self.hash_algorithm, hash_), size)\n\n    def for_source(self, source: WheelFile) -> WheelDestination:\n        scheme_dict = self.scheme_dict.copy()\n\n        scheme_dict[\"headers\"] = str(Path(scheme_dict[\"headers\"]) / source.distribution)\n\n        return self.__class__(\n            scheme_dict,\n            interpreter=self.interpreter,\n            script_kind=self.script_kind,\n            bytecode_optimization_levels=self.bytecode_optimization_levels,\n        )\n\n\nclass WheelInstaller:\n    def __init__(self, env: Env) -> None:\n        self._env = env\n\n        script_kind: LauncherKind\n        if not WINDOWS:\n            script_kind = \"posix\"\n        else:\n            if platform.uname()[4].startswith(\"arm\"):\n                script_kind = \"win-arm64\" if sys.maxsize > 2**32 else \"win-arm\"\n            else:\n                script_kind = \"win-amd64\" if sys.maxsize > 2**32 else \"win-ia32\"\n\n        schemes = self._env.paths\n        schemes[\"headers\"] = schemes[\"include\"]\n\n        self._destination = WheelDestination(\n            schemes, interpreter=self._env.python, script_kind=script_kind\n        )\n\n    def enable_bytecode_compilation(self, enable: bool = True) -> None:\n        self._destination.bytecode_optimization_levels = (1,) if enable else ()\n\n    def install(self, wheel: Path) -> None:\n        with WheelFile.open(wheel) as source:\n            source.validate_record()\n            install(\n                source=source,\n                destination=self._destination.for_source(source),\n                # Additional metadata that is generated by the installation tool.\n                additional_metadata={\n                    \"INSTALLER\": f\"Poetry {__version__}\".encode(),\n                },\n            )\n", "path": "src/poetry/installation/wheel_installer.py"}]}