prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Poetry 1.1.0a2 includes python code in the version string
  To reproduce:
  
  1. `poetry init` with default choices; no dependencies.
  1. `poetry add pytest-cov`
  1. `poetry install`
  
  The last command prints:
  ```
  Installing dependencies from lock file
  
  Package operations: 0 installs, 1 update, 0 removals
  
  - Updating pytest-cov (2.10.0 import os, sys;exec('if \'COV_CORE_SOURCE\' in os.environ:\n try:\n  from pytest_cov.embed import init\n  init()\n except Exception as exc:\n  sys.stderr.write(\n   "pytest-cov: Failed to setup subprocess coverage. "\n   "Environ: {0!r} "\n   "Exception: {1!r}\\n".format(\n    dict((k, v) for k, v in os.environ.items() if k.startswith(\'COV_CORE\')),\n    exc\n   )\n  )\n') -> 2.10.0) 
  ```
  
  </issue>
  <code>
  [start of poetry/repositories/installed_repository.py]
  1 from poetry.core.packages import Package
  2 from poetry.utils._compat import Path
  3 from poetry.utils._compat import metadata
  4 from poetry.utils.env import Env
  5 
  6 from .repository import Repository
  7 
  8 
  9 _VENDORS = Path(__file__).parent.parent.joinpath("_vendor")
  10 
  11 
  12 class InstalledRepository(Repository):
  13     @classmethod
  14     def load(cls, env):  # type: (Env) -> InstalledRepository
  15         """
  16         Load installed packages.
  17         """
  18         repo = cls()
  19         seen = set()
  20 
  21         for entry in reversed(env.sys_path):
  22             for distribution in sorted(
  23                 metadata.distributions(path=[entry]), key=lambda d: str(d._path),
  24             ):
  25                 name = distribution.metadata["name"]
  26                 path = Path(str(distribution._path))
  27                 version = distribution.metadata["version"]
  28                 package = Package(name, version, version)
  29                 package.description = distribution.metadata.get("summary", "")
  30 
  31                 if package.name in seen:
  32                     continue
  33 
  34                 try:
  35                     path.relative_to(_VENDORS)
  36                 except ValueError:
  37                     pass
  38                 else:
  39                     continue
  40 
  41                 seen.add(package.name)
  42 
  43                 repo.add_package(package)
  44 
  45                 is_standard_package = True
  46                 try:
  47                     path.relative_to(env.site_packages)
  48                 except ValueError:
  49                     is_standard_package = False
  50 
  51                 if is_standard_package:
  52                     if (
  53                         path.name.endswith(".dist-info")
  54                         and env.site_packages.joinpath(
  55                             "{}.pth".format(package.pretty_name)
  56                         ).exists()
  57                     ):
  58                         with env.site_packages.joinpath(
  59                             "{}.pth".format(package.pretty_name)
  60                         ).open() as f:
  61                             directory = Path(f.readline().strip())
  62                             package.source_type = "directory"
  63                             package.source_url = directory.as_posix()
  64 
  65                     continue
  66 
  67                 src_path = env.path / "src"
  68 
  69                 # A VCS dependency should have been installed
  70                 # in the src directory. If not, it's a path dependency
  71                 try:
  72                     path.relative_to(src_path)
  73 
  74                     from poetry.core.vcs.git import Git
  75 
  76                     git = Git()
  77                     revision = git.rev_parse("HEAD", src_path / package.name).strip()
  78                     url = git.remote_url(src_path / package.name)
  79 
  80                     package.source_type = "git"
  81                     package.source_url = url
  82                     package.source_reference = revision
  83                 except ValueError:
  84                     package.source_type = "directory"
  85                     package.source_url = str(path.parent)
  86 
  87         return repo
  88
  [end of poetry/repositories/installed_repository.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/poetry/repositories/installed_repository.py b/poetry/repositories/installed_repository.py
  --- a/poetry/repositories/installed_repository.py
  +++ b/poetry/repositories/installed_repository.py
  @@ -1,3 +1,5 @@
  +from typing import Set
  +
   from poetry.core.packages import Package
   from poetry.utils._compat import Path
   from poetry.utils._compat import metadata
  @@ -10,6 +12,37 @@
   
   
   class InstalledRepository(Repository):
  +    @classmethod
  +    def get_package_paths(cls, sitedir, name):  # type: (Path, str) -> Set[Path]
  +        """
  +        Process a .pth file within the site-packages directory, and return any valid
  +        paths. We skip executable .pth files as there is no reliable means to do this
  +        without side-effects to current run-time. Mo check is made that the item refers
  +        to a directory rather than a file, however, in order to maintain backwards
  +        compatibility, we allow non-existing paths to be discovered. The latter
  +        behaviour is different to how Python's site-specific hook configuration works.
  +
  +        Reference: https://docs.python.org/3.8/library/site.html
  +
  +        :param sitedir: The site-packages directory to search for .pth file.
  +        :param name: The name of the package to search .pth file for.
  +        :return: A `Set` of valid `Path` objects.
  +        """
  +        paths = set()
  +
  +        pth_file = sitedir.joinpath("{}.pth".format(name))
  +        if pth_file.exists():
  +            with pth_file.open() as f:
  +                for line in f:
  +                    line = line.strip()
  +                    if line and not line.startswith(("#", "import ", "import\t")):
  +                        path = Path(line)
  +                        if not path.is_absolute():
  +                            path = sitedir.joinpath(path)
  +                        paths.add(path)
  +
  +        return paths
  +
       @classmethod
       def load(cls, env):  # type: (Env) -> InstalledRepository
           """
  @@ -49,19 +82,14 @@
                       is_standard_package = False
   
                   if is_standard_package:
  -                    if (
  -                        path.name.endswith(".dist-info")
  -                        and env.site_packages.joinpath(
  -                            "{}.pth".format(package.pretty_name)
  -                        ).exists()
  -                    ):
  -                        with env.site_packages.joinpath(
  -                            "{}.pth".format(package.pretty_name)
  -                        ).open() as f:
  -                            directory = Path(f.readline().strip())
  +                    if path.name.endswith(".dist-info"):
  +                        paths = cls.get_package_paths(
  +                            sitedir=env.site_packages, name=package.pretty_name
  +                        )
  +                        if paths:
  +                            # TODO: handle multiple source directories?
                               package.source_type = "directory"
  -                            package.source_url = directory.as_posix()
  -
  +                            package.source_url = paths.pop().as_posix()
                       continue
   
                   src_path = env.path / "src"
  
verification_info: {"golden_diff": "diff --git a/poetry/repositories/installed_repository.py b/poetry/repositories/installed_repository.py\n--- a/poetry/repositories/installed_repository.py\n+++ b/poetry/repositories/installed_repository.py\n@@ -1,3 +1,5 @@\n+from typing import Set\n+\n from poetry.core.packages import Package\n from poetry.utils._compat import Path\n from poetry.utils._compat import metadata\n@@ -10,6 +12,37 @@\n \n \n class InstalledRepository(Repository):\n+    @classmethod\n+    def get_package_paths(cls, sitedir, name):  # type: (Path, str) -> Set[Path]\n+        \"\"\"\n+        Process a .pth file within the site-packages directory, and return any valid\n+        paths. We skip executable .pth files as there is no reliable means to do this\n+        without side-effects to current run-time. Mo check is made that the item refers\n+        to a directory rather than a file, however, in order to maintain backwards\n+        compatibility, we allow non-existing paths to be discovered. The latter\n+        behaviour is different to how Python's site-specific hook configuration works.\n+\n+        Reference: https://docs.python.org/3.8/library/site.html\n+\n+        :param sitedir: The site-packages directory to search for .pth file.\n+        :param name: The name of the package to search .pth file for.\n+        :return: A `Set` of valid `Path` objects.\n+        \"\"\"\n+        paths = set()\n+\n+        pth_file = sitedir.joinpath(\"{}.pth\".format(name))\n+        if pth_file.exists():\n+            with pth_file.open() as f:\n+                for line in f:\n+                    line = line.strip()\n+                    if line and not line.startswith((\"#\", \"import \", \"import\\t\")):\n+                        path = Path(line)\n+                        if not path.is_absolute():\n+                            path = sitedir.joinpath(path)\n+                        paths.add(path)\n+\n+        return paths\n+\n     @classmethod\n     def load(cls, env):  # type: (Env) -> InstalledRepository\n         \"\"\"\n@@ -49,19 +82,14 @@\n                     is_standard_package = False\n \n                 if is_standard_package:\n-                    if (\n-                        path.name.endswith(\".dist-info\")\n-                        and env.site_packages.joinpath(\n-                            \"{}.pth\".format(package.pretty_name)\n-                        ).exists()\n-                    ):\n-                        with env.site_packages.joinpath(\n-                            \"{}.pth\".format(package.pretty_name)\n-                        ).open() as f:\n-                            directory = Path(f.readline().strip())\n+                    if path.name.endswith(\".dist-info\"):\n+                        paths = cls.get_package_paths(\n+                            sitedir=env.site_packages, name=package.pretty_name\n+                        )\n+                        if paths:\n+                            # TODO: handle multiple source directories?\n                             package.source_type = \"directory\"\n-                            package.source_url = directory.as_posix()\n-\n+                            package.source_url = paths.pop().as_posix()\n                     continue\n \n                 src_path = env.path / \"src\"\n", "issue": "Poetry 1.1.0a2 includes python code in the version string\nTo reproduce:\r\n\r\n1. `poetry init` with default choices; no dependencies.\r\n1. `poetry add pytest-cov`\r\n1. `poetry install`\r\n\r\nThe last command prints:\r\n```\r\nInstalling dependencies from lock file\r\n\r\nPackage operations: 0 installs, 1 update, 0 removals\r\n\r\n- Updating pytest-cov (2.10.0 import os, sys;exec('if \\'COV_CORE_SOURCE\\' in os.environ:\\n try:\\n  from pytest_cov.embed import init\\n  init()\\n except Exception as exc:\\n  sys.stderr.write(\\n   \"pytest-cov: Failed to setup subprocess coverage. \"\\n   \"Environ: {0!r} \"\\n   \"Exception: {1!r}\\\\n\".format(\\n    dict((k, v) for k, v in os.environ.items() if k.startswith(\\'COV_CORE\\')),\\n    exc\\n   )\\n  )\\n') -> 2.10.0) \r\n```\n", "before_files": [{"content": "from poetry.core.packages import Package\nfrom poetry.utils._compat import Path\nfrom poetry.utils._compat import metadata\nfrom poetry.utils.env import Env\n\nfrom .repository import Repository\n\n\n_VENDORS = Path(__file__).parent.parent.joinpath(\"_vendor\")\n\n\nclass InstalledRepository(Repository):\n    @classmethod\n    def load(cls, env):  # type: (Env) -> InstalledRepository\n        \"\"\"\n        Load installed packages.\n        \"\"\"\n        repo = cls()\n        seen = set()\n\n        for entry in reversed(env.sys_path):\n            for distribution in sorted(\n                metadata.distributions(path=[entry]), key=lambda d: str(d._path),\n            ):\n                name = distribution.metadata[\"name\"]\n                path = Path(str(distribution._path))\n                version = distribution.metadata[\"version\"]\n                package = Package(name, version, version)\n                package.description = distribution.metadata.get(\"summary\", \"\")\n\n                if package.name in seen:\n                    continue\n\n                try:\n                    path.relative_to(_VENDORS)\n                except ValueError:\n                    pass\n                else:\n                    continue\n\n                seen.add(package.name)\n\n                repo.add_package(package)\n\n                is_standard_package = True\n                try:\n                    path.relative_to(env.site_packages)\n                except ValueError:\n                    is_standard_package = False\n\n                if is_standard_package:\n                    if (\n                        path.name.endswith(\".dist-info\")\n                        and env.site_packages.joinpath(\n                            \"{}.pth\".format(package.pretty_name)\n                        ).exists()\n                    ):\n                        with env.site_packages.joinpath(\n                            \"{}.pth\".format(package.pretty_name)\n                        ).open() as f:\n                            directory = Path(f.readline().strip())\n                            package.source_type = \"directory\"\n                            package.source_url = directory.as_posix()\n\n                    continue\n\n                src_path = env.path / \"src\"\n\n                # A VCS dependency should have been installed\n                # in the src directory. If not, it's a path dependency\n                try:\n                    path.relative_to(src_path)\n\n                    from poetry.core.vcs.git import Git\n\n                    git = Git()\n                    revision = git.rev_parse(\"HEAD\", src_path / package.name).strip()\n                    url = git.remote_url(src_path / package.name)\n\n                    package.source_type = \"git\"\n                    package.source_url = url\n                    package.source_reference = revision\n                except ValueError:\n                    package.source_type = \"directory\"\n                    package.source_url = str(path.parent)\n\n        return repo\n", "path": "poetry/repositories/installed_repository.py"}]}