prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Relative URLs in pyodide.loadPackage
  ## 🐛 Bug
  
  <!-- A clear and concise description of what the bug is. -->
  The documentation states that [pyodide.loadPackage](https://pyodide.org/en/stable/usage/api/js-api.html#pyodide.loadPackage) supports relative URLs. I'm trying to load an out-of-tree wheel from my local webserver, but this doesn't seem to work out well.
  
  ### To Reproduce
  
  <!-- Minimal code example to reproduce the bug. -->
  ```js
  await pyodide.loadPackage("dist/igraph-0.9.11-cp310-cp310-emscripten_3_1_14_wasm32.whl");
  ```
  or
  ```js
  await pyodide.loadPackage("./dist/igraph-0.9.11-cp310-cp310-emscripten_3_1_14_wasm32.whl");
  ```
  Pyodide tries to load the wheel from `https://cdn.jsdelivr.net/pyodide/v0.21.1/full/dist/igraph-0.9.11-cp310-cp310-emscripten_3_1_14_wasm32.whl`.
  
  ### Expected behavior
  
  <!-- FILL IN -->
  Load the wheel from the relative URL.
  
  ### Environment
  
  - Pyodide Version<!-- (e.g. 1.8.1) -->: 0.21.1
  - Browser version<!-- (e.g. Chrome 95.0.4638.54) -->: Firefox ESR 91.12.0, Chromium 104.0.5112.101
  - Any other relevant information:
  
  <!-- If you are building Pyodide by yourself, please also include these information: -->
  
  <!--
  - Commit hash of Pyodide git repository:
  - Build environment<!--(e.g. Ubuntu 18.04, pyodide/pyodide-env:19 docker)- ->:
  -->
  
  ### Additional context
  
  <!-- Add any other context about the problem here. -->
  
  
  </issue>
  <code>
  [start of packages/micropip/src/micropip/_compat_in_pyodide.py]
  1 from io import BytesIO
  2 from typing import IO
  3 from urllib.parse import urlparse
  4 
  5 from pyodide._core import IN_BROWSER
  6 from pyodide.http import pyfetch
  7 
  8 try:
  9     import pyodide_js
  10     from pyodide_js import loadedPackages, loadPackage
  11     from pyodide_js._api import loadBinaryFile, loadDynlib  # type: ignore[import]
  12 
  13     REPODATA_PACKAGES = pyodide_js._api.repodata_packages.to_py()
  14     REPODATA_INFO = pyodide_js._api.repodata_info.to_py()
  15 except ImportError:
  16     if IN_BROWSER:
  17         raise
  18     # Otherwise, this is pytest test collection so let it go.
  19 
  20 
  21 async def fetch_bytes(url: str, kwargs: dict[str, str]) -> IO[bytes]:
  22     parsed_url = urlparse(url)
  23     if parsed_url.scheme == "emfs":
  24         return open(parsed_url.path, "rb")
  25     if parsed_url.scheme == "file":
  26         result_bytes = (await loadBinaryFile("", parsed_url.path)).to_bytes()
  27     else:
  28         result_bytes = await (await pyfetch(url, **kwargs)).bytes()
  29     return BytesIO(result_bytes)
  30 
  31 
  32 async def fetch_string(url: str, kwargs: dict[str, str]) -> str:
  33     return await (await pyfetch(url, **kwargs)).string()
  34 
  35 
  36 __all__ = [
  37     "fetch_bytes",
  38     "fetch_string",
  39     "REPODATA_INFO",
  40     "REPODATA_PACKAGES",
  41     "loadedPackages",
  42     "loadDynlib",
  43     "loadPackage",
  44 ]
  45
  [end of packages/micropip/src/micropip/_compat_in_pyodide.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/packages/micropip/src/micropip/_compat_in_pyodide.py b/packages/micropip/src/micropip/_compat_in_pyodide.py
  --- a/packages/micropip/src/micropip/_compat_in_pyodide.py
  +++ b/packages/micropip/src/micropip/_compat_in_pyodide.py
  @@ -23,7 +23,7 @@
       if parsed_url.scheme == "emfs":
           return open(parsed_url.path, "rb")
       if parsed_url.scheme == "file":
  -        result_bytes = (await loadBinaryFile("", parsed_url.path)).to_bytes()
  +        result_bytes = (await loadBinaryFile(parsed_url.path)).to_bytes()
       else:
           result_bytes = await (await pyfetch(url, **kwargs)).bytes()
       return BytesIO(result_bytes)
  
verification_info: {"golden_diff": "diff --git a/packages/micropip/src/micropip/_compat_in_pyodide.py b/packages/micropip/src/micropip/_compat_in_pyodide.py\n--- a/packages/micropip/src/micropip/_compat_in_pyodide.py\n+++ b/packages/micropip/src/micropip/_compat_in_pyodide.py\n@@ -23,7 +23,7 @@\n     if parsed_url.scheme == \"emfs\":\n         return open(parsed_url.path, \"rb\")\n     if parsed_url.scheme == \"file\":\n-        result_bytes = (await loadBinaryFile(\"\", parsed_url.path)).to_bytes()\n+        result_bytes = (await loadBinaryFile(parsed_url.path)).to_bytes()\n     else:\n         result_bytes = await (await pyfetch(url, **kwargs)).bytes()\n     return BytesIO(result_bytes)\n", "issue": "Relative URLs in pyodide.loadPackage\n## \ud83d\udc1b Bug\r\n\r\n<!-- A clear and concise description of what the bug is. -->\r\nThe documentation states that [pyodide.loadPackage](https://pyodide.org/en/stable/usage/api/js-api.html#pyodide.loadPackage) supports relative URLs. I'm trying to load an out-of-tree wheel from my local webserver, but this doesn't seem to work out well.\r\n\r\n### To Reproduce\r\n\r\n<!-- Minimal code example to reproduce the bug. -->\r\n```js\r\nawait pyodide.loadPackage(\"dist/igraph-0.9.11-cp310-cp310-emscripten_3_1_14_wasm32.whl\");\r\n```\r\nor\r\n```js\r\nawait pyodide.loadPackage(\"./dist/igraph-0.9.11-cp310-cp310-emscripten_3_1_14_wasm32.whl\");\r\n```\r\nPyodide tries to load the wheel from `https://cdn.jsdelivr.net/pyodide/v0.21.1/full/dist/igraph-0.9.11-cp310-cp310-emscripten_3_1_14_wasm32.whl`.\r\n\r\n### Expected behavior\r\n\r\n<!-- FILL IN -->\r\nLoad the wheel from the relative URL.\r\n\r\n### Environment\r\n\r\n- Pyodide Version<!-- (e.g. 1.8.1) -->: 0.21.1\r\n- Browser version<!-- (e.g. Chrome 95.0.4638.54) -->: Firefox ESR 91.12.0, Chromium 104.0.5112.101\r\n- Any other relevant information:\r\n\r\n<!-- If you are building Pyodide by yourself, please also include these information: -->\r\n\r\n<!--\r\n- Commit hash of Pyodide git repository:\r\n- Build environment<!--(e.g. Ubuntu 18.04, pyodide/pyodide-env:19 docker)- ->:\r\n-->\r\n\r\n### Additional context\r\n\r\n<!-- Add any other context about the problem here. -->\r\n\n", "before_files": [{"content": "from io import BytesIO\nfrom typing import IO\nfrom urllib.parse import urlparse\n\nfrom pyodide._core import IN_BROWSER\nfrom pyodide.http import pyfetch\n\ntry:\n    import pyodide_js\n    from pyodide_js import loadedPackages, loadPackage\n    from pyodide_js._api import loadBinaryFile, loadDynlib  # type: ignore[import]\n\n    REPODATA_PACKAGES = pyodide_js._api.repodata_packages.to_py()\n    REPODATA_INFO = pyodide_js._api.repodata_info.to_py()\nexcept ImportError:\n    if IN_BROWSER:\n        raise\n    # Otherwise, this is pytest test collection so let it go.\n\n\nasync def fetch_bytes(url: str, kwargs: dict[str, str]) -> IO[bytes]:\n    parsed_url = urlparse(url)\n    if parsed_url.scheme == \"emfs\":\n        return open(parsed_url.path, \"rb\")\n    if parsed_url.scheme == \"file\":\n        result_bytes = (await loadBinaryFile(\"\", parsed_url.path)).to_bytes()\n    else:\n        result_bytes = await (await pyfetch(url, **kwargs)).bytes()\n    return BytesIO(result_bytes)\n\n\nasync def fetch_string(url: str, kwargs: dict[str, str]) -> str:\n    return await (await pyfetch(url, **kwargs)).string()\n\n\n__all__ = [\n    \"fetch_bytes\",\n    \"fetch_string\",\n    \"REPODATA_INFO\",\n    \"REPODATA_PACKAGES\",\n    \"loadedPackages\",\n    \"loadDynlib\",\n    \"loadPackage\",\n]\n", "path": "packages/micropip/src/micropip/_compat_in_pyodide.py"}]}