We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
1.1.0b2 causes EnvCommandError (Non-posix paths with file:// protocol on Windows)
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [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] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: Windows 10
- **Poetry version**: 1.1.0b2
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: <!-- Gist Link Here -->

## Issue

When on Poetry 1.0.10 there are no issues. But after having updated to poetry 1.1.0b2, I constantly get an EnvCommandError caused by a FileNotFoundError (a temporary setup.py file is not found):

```bash
$ poetry --version
Poetry version 1.1.0b2

$ poetry lock
Updating dependencies
Resolving dependencies...

Writing lock file

$ poetry install -vvv                                         
Using virtualenv: C:\Users\fredrik\code\repos\mylittleci\venv
Installing dependencies from lock file

Finding the necessary packages for the current system

Package operations: 2 installs, 0 updates, 0 removals

  • Installing zipp (3.1.0)

  Stack trace:

  7  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\executor.py:183 in _execute_operation
      181│
      182│             try:
    → 183│                 result = self._do_execute_operation(operation)
      184│             except EnvCommandError as e:
      185│                 if e.e.returncode == -2:

  6  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\executor.py:257 in _do_execute_operation
      255│             return 0
      256│
    → 257│         result = getattr(self, "_execute_{}".format(method))(operation)
      258│
      259│         if result != 0:

  5  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\executor.py:394 in _execute_install
      392│
      393│     def _execute_install(self, operation):  # type: (Install) -> None
    → 394│         return self._install(operation)
      395│
      396│     def _execute_update(self, operation):  # type: (Update) -> None

  4  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\executor.py:432 in _install
      430│             args.insert(2, "-U")
      431│
    → 432│         return self.run_pip(*args)
      433│
      434│     def _update(self, operation):

  3  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\executor.py:283 in run_pip
      281│     def run_pip(self, *args, **kwargs):  # type: (...) -> int
      282│         try:
    → 283│             self._env.run_pip(*args, **kwargs)
      284│         except EnvCommandError as e:
      285│             output = decode(e.e.output)

  2  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\utils\env.py:883 in run_pip
       881│         pip = self.get_pip_command()
       882│         cmd = pip + list(args)
    →  883│         return self._run(cmd, **kwargs)
       884│
       885│     def _run(self, cmd, **kwargs):

  1  c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\utils\env.py:1151 in _run
      1149│             self.unset_env("__PYVENV_LAUNCHER__")
      1150│
    → 1151│             return super(VirtualEnv, self)._run(cmd, **kwargs)
      1152│
      1153│     def execute(self, bin, *args, **kwargs):

  EnvCommandError

  Command C:\Users\fredrik\code\repos\mylittleci\venv\Scripts\pip.exe install --no-deps file://C:\Users\fredrik\AppData\Local\pypoetry\Cache\artifacts\3f\29\e0\445941d0045028dce97085f4263281587225a49fa7dd09f41e4c2752af\zipp-3.1.0-py3-none-any.whl errored with the following return code 1, and output:
  Processing c:\users\fredrik\appdata\local\pypoetry\cache\artifacts\3f\29\e0\445941d0045028dce97085f4263281587225a49fa7dd09f41e4c2752af\zipp-3.1.0-py3-none-any.whl
      ERROR: Command errored out with exit status 1:
       command: 'c:\users\fredrik\code\repos\mylittleci\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\fredrik\\AppData\\Local\\Temp\\pip-req-build-gsp4euj0\\setup.py'"'"'; __file__='"'"'C:\\Users\\fredrik\\AppData\\Local\\Temp\\pip-req-build-gsp4euj0\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\fredrik\AppData\Local\Temp\pip-pip-egg-info-_md_1odm'
           cwd: C:\Users\fredrik\AppData\Local\Temp\pip-req-build-gsp4euj0\
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "C:\Users\fredrik\AppData\Local\Programs\Python\Python37\lib\tokenize.py", line 447, in open
          buffer = _builtin_open(filename, 'rb')
      FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\fredrik\\AppData\\Local\\Temp\\pip-req-build-gsp4euj0\\setup.py'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


  at c:\users\fredrik\.local\pipx\venvs\poetry\lib\site-packages\poetry\utils\env.py:915 in _run
       911│                 output = subprocess.check_output(
       912│                     cmd, stderr=subprocess.STDOUT, **kwargs
       913│                 )
       914│         except CalledProcessError as e:
    →  915│             raise EnvCommandError(e, input=input_)
       916│
       917│         return decode(output)
       918│
       919│     def execute(self, bin, *args, **kwargs):
```

The contents of my `pyproject.toml`:

```
[tool.poetry]
name = "mylittleci"
version = "0.0.1"
authors = ["Fredrik <***@***.***>"]
description = "mylittleci"


[tool.poetry.dependencies]
python = "^3.7"


[tool.poetry.dev-dependencies]
importlib_metadata = "^1.7.0"


[tool.poetry.scripts]
calculator = "mylittleci.cli.calculator:main"


[build-system]
# https://python-poetry.org/docs/faq/#is-tox-supported
requires = ["poetry-core>=1.0.0a5"]
build-backend = "poetry.core.masonry.api"
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `poetry/installation/chef.py`
Content:
```
1 import hashlib
2 import json
3 
4 from typing import TYPE_CHECKING
5 
6 from poetry.core.packages.utils.link import Link
7 from poetry.utils._compat import Path
8 
9 from .chooser import InvalidWheelName
10 from .chooser import Wheel
11 
12 
13 if TYPE_CHECKING:
14     from typing import List
15     from typing import Optional
16 
17     from poetry.config.config import Config
18     from poetry.utils.env import Env
19 
20 
21 class Chef:
22     def __init__(self, config, env):  # type: (Config, Env) -> None
23         self._config = config
24         self._env = env
25         self._cache_dir = (
26             Path(config.get("cache-dir")).expanduser().joinpath("artifacts")
27         )
28 
29     def prepare(self, archive):  # type: (Path) -> Path
30         return archive
31 
32     def prepare_sdist(self, archive):  # type: (Path) -> Path
33         return archive
34 
35     def prepare_wheel(self, archive):  # type: (Path) -> Path
36         return archive
37 
38     def should_prepare(self, archive):  # type: (Path) -> bool
39         return not self.is_wheel(archive)
40 
41     def is_wheel(self, archive):  # type: (Path) -> bool
42         return archive.suffix == ".whl"
43 
44     def get_cached_archive_for_link(self, link):  # type: (Link) -> Optional[Link]
45         # If the archive is already a wheel, there is no need to cache it.
46         if link.is_wheel:
47             pass
48 
49         archives = self.get_cached_archives_for_link(link)
50 
51         if not archives:
52             return link
53 
54         candidates = []
55         for archive in archives:
56             if not archive.is_wheel:
57                 candidates.append((float("inf"), archive))
58                 continue
59 
60             try:
61                 wheel = Wheel(archive.filename)
62             except InvalidWheelName:
63                 continue
64 
65             if not wheel.is_supported_by_environment(self._env):
66                 continue
67 
68             candidates.append(
69                 (wheel.get_minimum_supported_index(self._env.supported_tags), archive),
70             )
71 
72         if not candidates:
73             return link
74 
75         return min(candidates)[1]
76 
77     def get_cached_archives_for_link(self, link):  # type: (Link) -> List[Link]
78         cache_dir = self.get_cache_directory_for_link(link)
79 
80         archive_types = ["whl", "tar.gz", "tar.bz2", "bz2", "zip"]
81         links = []
82         for archive_type in archive_types:
83             for archive in cache_dir.glob("*.{}".format(archive_type)):
84                 links.append(Link("file://{}".format(str(archive))))
85 
86         return links
87 
88     def get_cache_directory_for_link(self, link):  # type: (Link) -> Path
89         key_parts = {"url": link.url_without_fragment}
90 
91         if link.hash_name is not None and link.hash is not None:
92             key_parts[link.hash_name] = link.hash
93 
94         if link.subdirectory_fragment:
95             key_parts["subdirectory"] = link.subdirectory_fragment
96 
97         key_parts["interpreter_name"] = self._env.marker_env["interpreter_name"]
98         key_parts["interpreter_version"] = "".join(
99             self._env.marker_env["interpreter_version"].split(".")[:2]
100         )
101 
102         key = hashlib.sha256(
103             json.dumps(
104                 key_parts, sort_keys=True, separators=(",", ":"), ensure_ascii=True
105             ).encode("ascii")
106         ).hexdigest()
107 
108         split_key = [key[:2], key[2:4], key[4:6], key[6:]]
109 
110         return self._cache_dir.joinpath(*split_key)
111
```
--- 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/poetry/installation/chef.py b/poetry/installation/chef.py
--- a/poetry/installation/chef.py
+++ b/poetry/installation/chef.py
@@ -81,7 +81,7 @@
         links = []
         for archive_type in archive_types:
             for archive in cache_dir.glob("*.{}".format(archive_type)):
-                links.append(Link("file://{}".format(str(archive))))
+                links.append(Link(archive.as_uri()))
 
         return links

{"golden_diff": "diff --git a/poetry/installation/chef.py b/poetry/installation/chef.py\n--- a/poetry/installation/chef.py\n+++ b/poetry/installation/chef.py\n@@ -81,7 +81,7 @@\n         links = []\n         for archive_type in archive_types:\n             for archive in cache_dir.glob(\"*.{}\".format(archive_type)):\n-                links.append(Link(\"file://{}\".format(str(archive))))\n+                links.append(Link(archive.as_uri()))\n \n         return links\n", "issue": "1.1.0b2 causes EnvCommandError (Non-posix paths with file:// protocol on Windows)\n<!--\r\n  Hi there! Thank you for discovering and submitting an issue.\r\n\r\n  Before you submit this; let's make sure of a few things.\r\n  Please make sure the following boxes are ticked if they are correct.\r\n  If not, please try and fulfill these first.\r\n-->\r\n\r\n<!-- Checked checkbox should look like this: [x] -->\r\n- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.\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] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).\r\n\r\n<!--\r\n  Once those are done, if you're able to fill in the following list with your information,\r\n  it'd be very helpful to whoever handles the issue.\r\n-->\r\n\r\n- **OS version and name**: Windows 10\r\n- **Poetry version**: 1.1.0b2\r\n- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: <!-- Gist Link Here -->\r\n\r\n## Issue\r\n\r\nWhen on Poetry 1.0.10 there are no issues. But after having updated to poetry 1.1.0b2, I constantly get an EnvCommandError caused by a FileNotFoundError (a temporary setup.py file is not found):\r\n\r\n```bash\r\n$ poetry --version\r\nPoetry version 1.1.0b2\r\n\r\n$ poetry lock\r\nUpdating dependencies\r\nResolving dependencies...\r\n\r\nWriting lock file\r\n\r\n$ poetry install -vvv                                         \r\nUsing virtualenv: C:\\Users\\fredrik\\code\\repos\\mylittleci\\venv\r\nInstalling dependencies from lock file\r\n\r\nFinding the necessary packages for the current system\r\n\r\nPackage operations: 2 installs, 0 updates, 0 removals\r\n\r\n  \u2022 Installing zipp (3.1.0)\r\n\r\n  Stack trace:\r\n\r\n  7  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\installation\\executor.py:183 in _execute_operation\r\n      181\u2502\r\n      182\u2502             try:\r\n    \u2192 183\u2502                 result = self._do_execute_operation(operation)\r\n      184\u2502             except EnvCommandError as e:\r\n      185\u2502                 if e.e.returncode == -2:\r\n\r\n  6  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\installation\\executor.py:257 in _do_execute_operation\r\n      255\u2502             return 0\r\n      256\u2502\r\n    \u2192 257\u2502         result = getattr(self, \"_execute_{}\".format(method))(operation)\r\n      258\u2502\r\n      259\u2502         if result != 0:\r\n\r\n  5  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\installation\\executor.py:394 in _execute_install\r\n      392\u2502\r\n      393\u2502     def _execute_install(self, operation):  # type: (Install) -> None\r\n    \u2192 394\u2502         return self._install(operation)\r\n      395\u2502\r\n      396\u2502     def _execute_update(self, operation):  # type: (Update) -> None\r\n\r\n  4  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\installation\\executor.py:432 in _install\r\n      430\u2502             args.insert(2, \"-U\")\r\n      431\u2502\r\n    \u2192 432\u2502         return self.run_pip(*args)\r\n      433\u2502\r\n      434\u2502     def _update(self, operation):\r\n\r\n  3  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\installation\\executor.py:283 in run_pip\r\n      281\u2502     def run_pip(self, *args, **kwargs):  # type: (...) -> int\r\n      282\u2502         try:\r\n    \u2192 283\u2502             self._env.run_pip(*args, **kwargs)\r\n      284\u2502         except EnvCommandError as e:\r\n      285\u2502             output = decode(e.e.output)\r\n\r\n  2  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\utils\\env.py:883 in run_pip\r\n       881\u2502         pip = self.get_pip_command()\r\n       882\u2502         cmd = pip + list(args)\r\n    \u2192  883\u2502         return self._run(cmd, **kwargs)\r\n       884\u2502\r\n       885\u2502     def _run(self, cmd, **kwargs):\r\n\r\n  1  c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\utils\\env.py:1151 in _run\r\n      1149\u2502             self.unset_env(\"__PYVENV_LAUNCHER__\")\r\n      1150\u2502\r\n    \u2192 1151\u2502             return super(VirtualEnv, self)._run(cmd, **kwargs)\r\n      1152\u2502\r\n      1153\u2502     def execute(self, bin, *args, **kwargs):\r\n\r\n  EnvCommandError\r\n\r\n  Command C:\\Users\\fredrik\\code\\repos\\mylittleci\\venv\\Scripts\\pip.exe install --no-deps file://C:\\Users\\fredrik\\AppData\\Local\\pypoetry\\Cache\\artifacts\\3f\\29\\e0\\445941d0045028dce97085f4263281587225a49fa7dd09f41e4c2752af\\zipp-3.1.0-py3-none-any.whl errored with the following return code 1, and output:\r\n  Processing c:\\users\\fredrik\\appdata\\local\\pypoetry\\cache\\artifacts\\3f\\29\\e0\\445941d0045028dce97085f4263281587225a49fa7dd09f41e4c2752af\\zipp-3.1.0-py3-none-any.whl\r\n      ERROR: Command errored out with exit status 1:\r\n       command: 'c:\\users\\fredrik\\code\\repos\\mylittleci\\venv\\scripts\\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '\"'\"'C:\\\\Users\\\\fredrik\\\\AppData\\\\Local\\\\Temp\\\\pip-req-build-gsp4euj0\\\\setup.py'\"'\"'; __file__='\"'\"'C:\\\\Users\\\\fredrik\\\\AppData\\\\Local\\\\Temp\\\\pip-req-build-gsp4euj0\\\\setup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(code, __file__, '\"'\"'exec'\"'\"'))' egg_info --egg-base 'C:\\Users\\fredrik\\AppData\\Local\\Temp\\pip-pip-egg-info-_md_1odm'\r\n           cwd: C:\\Users\\fredrik\\AppData\\Local\\Temp\\pip-req-build-gsp4euj0\\\r\n      Complete output (5 lines):\r\n      Traceback (most recent call last):\r\n        File \"<string>\", line 1, in <module>\r\n        File \"C:\\Users\\fredrik\\AppData\\Local\\Programs\\Python\\Python37\\lib\\tokenize.py\", line 447, in open\r\n          buffer = _builtin_open(filename, 'rb')\r\n      FileNotFoundError: [Errno 2] No such file or directory: 'C:\\\\Users\\\\fredrik\\\\AppData\\\\Local\\\\Temp\\\\pip-req-build-gsp4euj0\\\\setup.py'\r\n      ----------------------------------------\r\n  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.\r\n\r\n\r\n  at c:\\users\\fredrik\\.local\\pipx\\venvs\\poetry\\lib\\site-packages\\poetry\\utils\\env.py:915 in _run\r\n       911\u2502                 output = subprocess.check_output(\r\n       912\u2502                     cmd, stderr=subprocess.STDOUT, **kwargs\r\n       913\u2502                 )\r\n       914\u2502         except CalledProcessError as e:\r\n    \u2192  915\u2502             raise EnvCommandError(e, input=input_)\r\n       916\u2502\r\n       917\u2502         return decode(output)\r\n       918\u2502\r\n       919\u2502     def execute(self, bin, *args, **kwargs):\r\n```\r\n\r\nThe contents of my `pyproject.toml`:\r\n\r\n```\r\n[tool.poetry]\r\nname = \"mylittleci\"\r\nversion = \"0.0.1\"\r\nauthors = [\"Fredrik <***@***.***>\"]\r\ndescription = \"mylittleci\"\r\n\r\n\r\n[tool.poetry.dependencies]\r\npython = \"^3.7\"\r\n\r\n\r\n[tool.poetry.dev-dependencies]\r\nimportlib_metadata = \"^1.7.0\"\r\n\r\n\r\n[tool.poetry.scripts]\r\ncalculator = \"mylittleci.cli.calculator:main\"\r\n\r\n\r\n[build-system]\r\n# https://python-poetry.org/docs/faq/#is-tox-supported\r\nrequires = [\"poetry-core>=1.0.0a5\"]\r\nbuild-backend = \"poetry.core.masonry.api\"\r\n```\r\n\n", "before_files": [{"content": "import hashlib\nimport json\n\nfrom typing import TYPE_CHECKING\n\nfrom poetry.core.packages.utils.link import Link\nfrom poetry.utils._compat import Path\n\nfrom .chooser import InvalidWheelName\nfrom .chooser import Wheel\n\n\nif TYPE_CHECKING:\n    from typing import List\n    from typing import Optional\n\n    from poetry.config.config import Config\n    from poetry.utils.env import Env\n\n\nclass Chef:\n    def __init__(self, config, env):  # type: (Config, Env) -> None\n        self._config = config\n        self._env = env\n        self._cache_dir = (\n            Path(config.get(\"cache-dir\")).expanduser().joinpath(\"artifacts\")\n        )\n\n    def prepare(self, archive):  # type: (Path) -> Path\n        return archive\n\n    def prepare_sdist(self, archive):  # type: (Path) -> Path\n        return archive\n\n    def prepare_wheel(self, archive):  # type: (Path) -> Path\n        return archive\n\n    def should_prepare(self, archive):  # type: (Path) -> bool\n        return not self.is_wheel(archive)\n\n    def is_wheel(self, archive):  # type: (Path) -> bool\n        return archive.suffix == \".whl\"\n\n    def get_cached_archive_for_link(self, link):  # type: (Link) -> Optional[Link]\n        # If the archive is already a wheel, there is no need to cache it.\n        if link.is_wheel:\n            pass\n\n        archives = self.get_cached_archives_for_link(link)\n\n        if not archives:\n            return link\n\n        candidates = []\n        for archive in archives:\n            if not archive.is_wheel:\n                candidates.append((float(\"inf\"), archive))\n                continue\n\n            try:\n                wheel = Wheel(archive.filename)\n            except InvalidWheelName:\n                continue\n\n            if not wheel.is_supported_by_environment(self._env):\n                continue\n\n            candidates.append(\n                (wheel.get_minimum_supported_index(self._env.supported_tags), archive),\n            )\n\n        if not candidates:\n            return link\n\n        return min(candidates)[1]\n\n    def get_cached_archives_for_link(self, link):  # type: (Link) -> List[Link]\n        cache_dir = self.get_cache_directory_for_link(link)\n\n        archive_types = [\"whl\", \"tar.gz\", \"tar.bz2\", \"bz2\", \"zip\"]\n        links = []\n        for archive_type in archive_types:\n            for archive in cache_dir.glob(\"*.{}\".format(archive_type)):\n                links.append(Link(\"file://{}\".format(str(archive))))\n\n        return links\n\n    def get_cache_directory_for_link(self, link):  # type: (Link) -> Path\n        key_parts = {\"url\": link.url_without_fragment}\n\n        if link.hash_name is not None and link.hash is not None:\n            key_parts[link.hash_name] = link.hash\n\n        if link.subdirectory_fragment:\n            key_parts[\"subdirectory\"] = link.subdirectory_fragment\n\n        key_parts[\"interpreter_name\"] = self._env.marker_env[\"interpreter_name\"]\n        key_parts[\"interpreter_version\"] = \"\".join(\n            self._env.marker_env[\"interpreter_version\"].split(\".\")[:2]\n        )\n\n        key = hashlib.sha256(\n            json.dumps(\n                key_parts, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=True\n            ).encode(\"ascii\")\n        ).hexdigest()\n\n        split_key = [key[:2], key[2:4], key[4:6], key[6:]]\n\n        return self._cache_dir.joinpath(*split_key)\n", "path": "poetry/installation/chef.py"}], "after_files": [{"content": "import hashlib\nimport json\n\nfrom typing import TYPE_CHECKING\n\nfrom poetry.core.packages.utils.link import Link\nfrom poetry.utils._compat import Path\n\nfrom .chooser import InvalidWheelName\nfrom .chooser import Wheel\n\n\nif TYPE_CHECKING:\n    from typing import List\n    from typing import Optional\n\n    from poetry.config.config import Config\n    from poetry.utils.env import Env\n\n\nclass Chef:\n    def __init__(self, config, env):  # type: (Config, Env) -> None\n        self._config = config\n        self._env = env\n        self._cache_dir = (\n            Path(config.get(\"cache-dir\")).expanduser().joinpath(\"artifacts\")\n        )\n\n    def prepare(self, archive):  # type: (Path) -> Path\n        return archive\n\n    def prepare_sdist(self, archive):  # type: (Path) -> Path\n        return archive\n\n    def prepare_wheel(self, archive):  # type: (Path) -> Path\n        return archive\n\n    def should_prepare(self, archive):  # type: (Path) -> bool\n        return not self.is_wheel(archive)\n\n    def is_wheel(self, archive):  # type: (Path) -> bool\n        return archive.suffix == \".whl\"\n\n    def get_cached_archive_for_link(self, link):  # type: (Link) -> Optional[Link]\n        # If the archive is already a wheel, there is no need to cache it.\n        if link.is_wheel:\n            pass\n\n        archives = self.get_cached_archives_for_link(link)\n\n        if not archives:\n            return link\n\n        candidates = []\n        for archive in archives:\n            if not archive.is_wheel:\n                candidates.append((float(\"inf\"), archive))\n                continue\n\n            try:\n                wheel = Wheel(archive.filename)\n            except InvalidWheelName:\n                continue\n\n            if not wheel.is_supported_by_environment(self._env):\n                continue\n\n            candidates.append(\n                (wheel.get_minimum_supported_index(self._env.supported_tags), archive),\n            )\n\n        if not candidates:\n            return link\n\n        return min(candidates)[1]\n\n    def get_cached_archives_for_link(self, link):  # type: (Link) -> List[Link]\n        cache_dir = self.get_cache_directory_for_link(link)\n\n        archive_types = [\"whl\", \"tar.gz\", \"tar.bz2\", \"bz2\", \"zip\"]\n        links = []\n        for archive_type in archive_types:\n            for archive in cache_dir.glob(\"*.{}\".format(archive_type)):\n                links.append(Link(archive.as_uri()))\n\n        return links\n\n    def get_cache_directory_for_link(self, link):  # type: (Link) -> Path\n        key_parts = {\"url\": link.url_without_fragment}\n\n        if link.hash_name is not None and link.hash is not None:\n            key_parts[link.hash_name] = link.hash\n\n        if link.subdirectory_fragment:\n            key_parts[\"subdirectory\"] = link.subdirectory_fragment\n\n        key_parts[\"interpreter_name\"] = self._env.marker_env[\"interpreter_name\"]\n        key_parts[\"interpreter_version\"] = \"\".join(\n            self._env.marker_env[\"interpreter_version\"].split(\".\")[:2]\n        )\n\n        key = hashlib.sha256(\n            json.dumps(\n                key_parts, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=True\n            ).encode(\"ascii\")\n        ).hexdigest()\n\n        split_key = [key[:2], key[2:4], key[4:6], key[6:]]\n\n        return self._cache_dir.joinpath(*split_key)\n", "path": "poetry/installation/chef.py"}]}