prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  21.3 regression with legacy resolver
  Assuming the following project with an empty `pyproject.toml` and the following `setup.cfg`:
  
  ```ini
  [metadata]
  name = pkgb
  version = 1.0
  
  [options]
  install_requires =
      wrapt
  ```
  
  We get the following stack trace, using pip main branch, today:
  
  ```console
  $ pip install --use-deprecated=legacy-resolver -e ./pkgb
  Obtaining file:///home/me/tmp/brol/pkgb
    Installing build dependencies ... done
    Getting requirements to build wheel ... done
      Preparing wheel metadata ... done
  Requirement already satisfied: wrapt in /home/me/.virtualenvs/tempenv-49ea1126817e6/lib/python3.8/site-packages (from pkgb==1.0) (1.12.1)
  ERROR: Exception:
  Traceback (most recent call last):
    File "/home/me/pip/src/pip/_internal/cli/base_command.py", line 179, in exc_logging_wrapper
      status = run_func(*args)
    File "/home/me/pip/src/pip/_internal/cli/req_command.py", line 203, in wrapper
      return func(self, options, args)
    File "/home/me/pip/src/pip/_internal/commands/install.py", line 334, in run
      requirement_set = resolver.resolve(
    File "/home/me/pip/src/pip/_internal/resolution/legacy/resolver.py", line 181, in resolve
      discovered_reqs.extend(self._resolve_one(requirement_set, req))
    File "/home/me/pip/src/pip/_internal/resolution/legacy/resolver.py", line 382, in _resolve_one
      _check_dist_requires_python(
    File "/home/me/pip/src/pip/_internal/resolution/legacy/resolver.py", line 75, in _check_dist_requires_python
      requires_python = str(dist.requires_python)
    File "/home/me/pip/src/pip/_vendor/pkg_resources/__init__.py", line 2816, in __getattr__
      return getattr(self._provider, attr)
  AttributeError: 'PathMetadata' object has no attribute 'requires_python'
  ```
  
  
  </issue>
  <code>
  [start of src/pip/_internal/distributions/installed.py]
  1 from pip._internal.distributions.base import AbstractDistribution
  2 from pip._internal.index.package_finder import PackageFinder
  3 from pip._internal.metadata import BaseDistribution
  4 
  5 
  6 class InstalledDistribution(AbstractDistribution):
  7     """Represents an installed package.
  8 
  9     This does not need any preparation as the required information has already
  10     been computed.
  11     """
  12 
  13     def get_metadata_distribution(self) -> BaseDistribution:
  14         assert self.req.satisfied_by is not None, "not actually installed"
  15         return self.req.satisfied_by
  16 
  17     def prepare_distribution_metadata(
  18         self, finder: PackageFinder, build_isolation: bool
  19     ) -> None:
  20         pass
  21
  [end of src/pip/_internal/distributions/installed.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/src/pip/_internal/distributions/installed.py b/src/pip/_internal/distributions/installed.py
  --- a/src/pip/_internal/distributions/installed.py
  +++ b/src/pip/_internal/distributions/installed.py
  @@ -11,8 +11,10 @@
       """
   
       def get_metadata_distribution(self) -> BaseDistribution:
  +        from pip._internal.metadata.pkg_resources import Distribution as _Dist
  +
           assert self.req.satisfied_by is not None, "not actually installed"
  -        return self.req.satisfied_by
  +        return _Dist(self.req.satisfied_by)
   
       def prepare_distribution_metadata(
           self, finder: PackageFinder, build_isolation: bool
  
verification_info: {"golden_diff": "diff --git a/src/pip/_internal/distributions/installed.py b/src/pip/_internal/distributions/installed.py\n--- a/src/pip/_internal/distributions/installed.py\n+++ b/src/pip/_internal/distributions/installed.py\n@@ -11,8 +11,10 @@\n     \"\"\"\n \n     def get_metadata_distribution(self) -> BaseDistribution:\n+        from pip._internal.metadata.pkg_resources import Distribution as _Dist\n+\n         assert self.req.satisfied_by is not None, \"not actually installed\"\n-        return self.req.satisfied_by\n+        return _Dist(self.req.satisfied_by)\n \n     def prepare_distribution_metadata(\n         self, finder: PackageFinder, build_isolation: bool\n", "issue": "21.3 regression with legacy resolver\nAssuming the following project with an empty `pyproject.toml` and the following `setup.cfg`:\r\n\r\n```ini\r\n[metadata]\r\nname = pkgb\r\nversion = 1.0\r\n\r\n[options]\r\ninstall_requires =\r\n    wrapt\r\n```\r\n\r\nWe get the following stack trace, using pip main branch, today:\r\n\r\n```console\r\n$ pip install --use-deprecated=legacy-resolver -e ./pkgb\r\nObtaining file:///home/me/tmp/brol/pkgb\r\n  Installing build dependencies ... done\r\n  Getting requirements to build wheel ... done\r\n    Preparing wheel metadata ... done\r\nRequirement already satisfied: wrapt in /home/me/.virtualenvs/tempenv-49ea1126817e6/lib/python3.8/site-packages (from pkgb==1.0) (1.12.1)\r\nERROR: Exception:\r\nTraceback (most recent call last):\r\n  File \"/home/me/pip/src/pip/_internal/cli/base_command.py\", line 179, in exc_logging_wrapper\r\n    status = run_func(*args)\r\n  File \"/home/me/pip/src/pip/_internal/cli/req_command.py\", line 203, in wrapper\r\n    return func(self, options, args)\r\n  File \"/home/me/pip/src/pip/_internal/commands/install.py\", line 334, in run\r\n    requirement_set = resolver.resolve(\r\n  File \"/home/me/pip/src/pip/_internal/resolution/legacy/resolver.py\", line 181, in resolve\r\n    discovered_reqs.extend(self._resolve_one(requirement_set, req))\r\n  File \"/home/me/pip/src/pip/_internal/resolution/legacy/resolver.py\", line 382, in _resolve_one\r\n    _check_dist_requires_python(\r\n  File \"/home/me/pip/src/pip/_internal/resolution/legacy/resolver.py\", line 75, in _check_dist_requires_python\r\n    requires_python = str(dist.requires_python)\r\n  File \"/home/me/pip/src/pip/_vendor/pkg_resources/__init__.py\", line 2816, in __getattr__\r\n    return getattr(self._provider, attr)\r\nAttributeError: 'PathMetadata' object has no attribute 'requires_python'\r\n```\r\n\n", "before_files": [{"content": "from pip._internal.distributions.base import AbstractDistribution\nfrom pip._internal.index.package_finder import PackageFinder\nfrom pip._internal.metadata import BaseDistribution\n\n\nclass InstalledDistribution(AbstractDistribution):\n    \"\"\"Represents an installed package.\n\n    This does not need any preparation as the required information has already\n    been computed.\n    \"\"\"\n\n    def get_metadata_distribution(self) -> BaseDistribution:\n        assert self.req.satisfied_by is not None, \"not actually installed\"\n        return self.req.satisfied_by\n\n    def prepare_distribution_metadata(\n        self, finder: PackageFinder, build_isolation: bool\n    ) -> None:\n        pass\n", "path": "src/pip/_internal/distributions/installed.py"}]}