We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Show INSTALLER from PEP376 in pip show
Now that #1646 is implemented, it would interesting to show this information in `pip show`.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pip/commands/show.py`
Content:
```
1 from __future__ import absolute_import
2 
3 from email.parser import FeedParser
4 import logging
5 import os
6 
7 from pip.basecommand import Command
8 from pip.status_codes import SUCCESS, ERROR
9 from pip._vendor import pkg_resources
10 
11 
12 logger = logging.getLogger(__name__)
13 
14 
15 class ShowCommand(Command):
16     """Show information about one or more installed packages."""
17     name = 'show'
18     usage = """
19       %prog [options] <package> ..."""
20     summary = 'Show information about installed packages.'
21 
22     def __init__(self, *args, **kw):
23         super(ShowCommand, self).__init__(*args, **kw)
24         self.cmd_opts.add_option(
25             '-f', '--files',
26             dest='files',
27             action='store_true',
28             default=False,
29             help='Show the full list of installed files for each package.')
30 
31         self.parser.insert_option_group(0, self.cmd_opts)
32 
33     def run(self, options, args):
34         if not args:
35             logger.warning('ERROR: Please provide a package name or names.')
36             return ERROR
37         query = args
38 
39         results = search_packages_info(query)
40         if not print_results(results, options.files):
41             return ERROR
42         return SUCCESS
43 
44 
45 def search_packages_info(query):
46     """
47     Gather details from installed distributions. Print distribution name,
48     version, location, and installed files. Installed files requires a
49     pip generated 'installed-files.txt' in the distributions '.egg-info'
50     directory.
51     """
52     installed = dict(
53         [(p.project_name.lower(), p) for p in pkg_resources.working_set])
54     query_names = [name.lower() for name in query]
55     for dist in [installed[pkg] for pkg in query_names if pkg in installed]:
56         package = {
57             'name': dist.project_name,
58             'version': dist.version,
59             'location': dist.location,
60             'requires': [dep.project_name for dep in dist.requires()],
61         }
62         file_list = None
63         metadata = None
64         if isinstance(dist, pkg_resources.DistInfoDistribution):
65             # RECORDs should be part of .dist-info metadatas
66             if dist.has_metadata('RECORD'):
67                 lines = dist.get_metadata_lines('RECORD')
68                 paths = [l.split(',')[0] for l in lines]
69                 paths = [os.path.join(dist.location, p) for p in paths]
70                 file_list = [os.path.relpath(p, dist.location) for p in paths]
71 
72             if dist.has_metadata('METADATA'):
73                 metadata = dist.get_metadata('METADATA')
74         else:
75             # Otherwise use pip's log for .egg-info's
76             if dist.has_metadata('installed-files.txt'):
77                 paths = dist.get_metadata_lines('installed-files.txt')
78                 paths = [os.path.join(dist.egg_info, p) for p in paths]
79                 file_list = [os.path.relpath(p, dist.location) for p in paths]
80 
81             if dist.has_metadata('PKG-INFO'):
82                 metadata = dist.get_metadata('PKG-INFO')
83 
84         if dist.has_metadata('entry_points.txt'):
85             entry_points = dist.get_metadata_lines('entry_points.txt')
86             package['entry_points'] = entry_points
87 
88         # @todo: Should pkg_resources.Distribution have a
89         # `get_pkg_info` method?
90         feed_parser = FeedParser()
91         feed_parser.feed(metadata)
92         pkg_info_dict = feed_parser.close()
93         for key in ('metadata-version', 'summary',
94                     'home-page', 'author', 'author-email', 'license'):
95             package[key] = pkg_info_dict.get(key)
96 
97         # It looks like FeedParser can not deal with repeated headers
98         classifiers = []
99         for line in metadata.splitlines():
100             if not line:
101                 break
102             # Classifier: License :: OSI Approved :: MIT License
103             if line.startswith('Classifier: '):
104                 classifiers.append(line[len('Classifier: '):])
105         package['classifiers'] = classifiers
106 
107         if file_list:
108             package['files'] = sorted(file_list)
109         yield package
110 
111 
112 def print_results(distributions, list_all_files):
113     """
114     Print the informations from installed distributions found.
115     """
116     results_printed = False
117     for dist in distributions:
118         results_printed = True
119         logger.info("---")
120         logger.info("Metadata-Version: %s", dist.get('metadata-version'))
121         logger.info("Name: %s", dist['name'])
122         logger.info("Version: %s", dist['version'])
123         logger.info("Summary: %s", dist.get('summary'))
124         logger.info("Home-page: %s", dist.get('home-page'))
125         logger.info("Author: %s", dist.get('author'))
126         logger.info("Author-email: %s", dist.get('author-email'))
127         logger.info("License: %s", dist.get('license'))
128         logger.info("Location: %s", dist['location'])
129         logger.info("Requires: %s", ', '.join(dist['requires']))
130         logger.info("Classifiers:")
131         for classifier in dist['classifiers']:
132             logger.info("  %s", classifier)
133         if list_all_files:
134             logger.info("Files:")
135             if 'files' in dist:
136                 for line in dist['files']:
137                     logger.info("  %s", line.strip())
138             else:
139                 logger.info("Cannot locate installed-files.txt")
140         if 'entry_points' in dist:
141             logger.info("Entry-points:")
142             for line in dist['entry_points']:
143                 logger.info("  %s", line.strip())
144     return results_printed
145
```
--- 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/pip/commands/show.py b/pip/commands/show.py
--- a/pip/commands/show.py
+++ b/pip/commands/show.py
@@ -85,6 +85,14 @@
             entry_points = dist.get_metadata_lines('entry_points.txt')
             package['entry_points'] = entry_points
 
+        installer = None
+        if dist.has_metadata('INSTALLER'):
+            for line in dist.get_metadata_lines('INSTALLER'):
+                if line.strip():
+                    installer = line.strip()
+                    break
+        package['installer'] = installer
+
         # @todo: Should pkg_resources.Distribution have a
         # `get_pkg_info` method?
         feed_parser = FeedParser()
@@ -124,6 +132,8 @@
         logger.info("Home-page: %s", dist.get('home-page'))
         logger.info("Author: %s", dist.get('author'))
         logger.info("Author-email: %s", dist.get('author-email'))
+        if dist['installer'] is not None:
+            logger.info("Installer: %s", dist['installer'])
         logger.info("License: %s", dist.get('license'))
         logger.info("Location: %s", dist['location'])
         logger.info("Requires: %s", ', '.join(dist['requires']))

{"golden_diff": "diff --git a/pip/commands/show.py b/pip/commands/show.py\n--- a/pip/commands/show.py\n+++ b/pip/commands/show.py\n@@ -85,6 +85,14 @@\n             entry_points = dist.get_metadata_lines('entry_points.txt')\n             package['entry_points'] = entry_points\n \n+        installer = None\n+        if dist.has_metadata('INSTALLER'):\n+            for line in dist.get_metadata_lines('INSTALLER'):\n+                if line.strip():\n+                    installer = line.strip()\n+                    break\n+        package['installer'] = installer\n+\n         # @todo: Should pkg_resources.Distribution have a\n         # `get_pkg_info` method?\n         feed_parser = FeedParser()\n@@ -124,6 +132,8 @@\n         logger.info(\"Home-page: %s\", dist.get('home-page'))\n         logger.info(\"Author: %s\", dist.get('author'))\n         logger.info(\"Author-email: %s\", dist.get('author-email'))\n+        if dist['installer'] is not None:\n+            logger.info(\"Installer: %s\", dist['installer'])\n         logger.info(\"License: %s\", dist.get('license'))\n         logger.info(\"Location: %s\", dist['location'])\n         logger.info(\"Requires: %s\", ', '.join(dist['requires']))\n", "issue": "Show INSTALLER from PEP376 in pip show\nNow that #1646 is implemented, it would interesting to show this information in `pip show`.\n\n", "before_files": [{"content": "from __future__ import absolute_import\n\nfrom email.parser import FeedParser\nimport logging\nimport os\n\nfrom pip.basecommand import Command\nfrom pip.status_codes import SUCCESS, ERROR\nfrom pip._vendor import pkg_resources\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass ShowCommand(Command):\n    \"\"\"Show information about one or more installed packages.\"\"\"\n    name = 'show'\n    usage = \"\"\"\n      %prog [options] <package> ...\"\"\"\n    summary = 'Show information about installed packages.'\n\n    def __init__(self, *args, **kw):\n        super(ShowCommand, self).__init__(*args, **kw)\n        self.cmd_opts.add_option(\n            '-f', '--files',\n            dest='files',\n            action='store_true',\n            default=False,\n            help='Show the full list of installed files for each package.')\n\n        self.parser.insert_option_group(0, self.cmd_opts)\n\n    def run(self, options, args):\n        if not args:\n            logger.warning('ERROR: Please provide a package name or names.')\n            return ERROR\n        query = args\n\n        results = search_packages_info(query)\n        if not print_results(results, options.files):\n            return ERROR\n        return SUCCESS\n\n\ndef search_packages_info(query):\n    \"\"\"\n    Gather details from installed distributions. Print distribution name,\n    version, location, and installed files. Installed files requires a\n    pip generated 'installed-files.txt' in the distributions '.egg-info'\n    directory.\n    \"\"\"\n    installed = dict(\n        [(p.project_name.lower(), p) for p in pkg_resources.working_set])\n    query_names = [name.lower() for name in query]\n    for dist in [installed[pkg] for pkg in query_names if pkg in installed]:\n        package = {\n            'name': dist.project_name,\n            'version': dist.version,\n            'location': dist.location,\n            'requires': [dep.project_name for dep in dist.requires()],\n        }\n        file_list = None\n        metadata = None\n        if isinstance(dist, pkg_resources.DistInfoDistribution):\n            # RECORDs should be part of .dist-info metadatas\n            if dist.has_metadata('RECORD'):\n                lines = dist.get_metadata_lines('RECORD')\n                paths = [l.split(',')[0] for l in lines]\n                paths = [os.path.join(dist.location, p) for p in paths]\n                file_list = [os.path.relpath(p, dist.location) for p in paths]\n\n            if dist.has_metadata('METADATA'):\n                metadata = dist.get_metadata('METADATA')\n        else:\n            # Otherwise use pip's log for .egg-info's\n            if dist.has_metadata('installed-files.txt'):\n                paths = dist.get_metadata_lines('installed-files.txt')\n                paths = [os.path.join(dist.egg_info, p) for p in paths]\n                file_list = [os.path.relpath(p, dist.location) for p in paths]\n\n            if dist.has_metadata('PKG-INFO'):\n                metadata = dist.get_metadata('PKG-INFO')\n\n        if dist.has_metadata('entry_points.txt'):\n            entry_points = dist.get_metadata_lines('entry_points.txt')\n            package['entry_points'] = entry_points\n\n        # @todo: Should pkg_resources.Distribution have a\n        # `get_pkg_info` method?\n        feed_parser = FeedParser()\n        feed_parser.feed(metadata)\n        pkg_info_dict = feed_parser.close()\n        for key in ('metadata-version', 'summary',\n                    'home-page', 'author', 'author-email', 'license'):\n            package[key] = pkg_info_dict.get(key)\n\n        # It looks like FeedParser can not deal with repeated headers\n        classifiers = []\n        for line in metadata.splitlines():\n            if not line:\n                break\n            # Classifier: License :: OSI Approved :: MIT License\n            if line.startswith('Classifier: '):\n                classifiers.append(line[len('Classifier: '):])\n        package['classifiers'] = classifiers\n\n        if file_list:\n            package['files'] = sorted(file_list)\n        yield package\n\n\ndef print_results(distributions, list_all_files):\n    \"\"\"\n    Print the informations from installed distributions found.\n    \"\"\"\n    results_printed = False\n    for dist in distributions:\n        results_printed = True\n        logger.info(\"---\")\n        logger.info(\"Metadata-Version: %s\", dist.get('metadata-version'))\n        logger.info(\"Name: %s\", dist['name'])\n        logger.info(\"Version: %s\", dist['version'])\n        logger.info(\"Summary: %s\", dist.get('summary'))\n        logger.info(\"Home-page: %s\", dist.get('home-page'))\n        logger.info(\"Author: %s\", dist.get('author'))\n        logger.info(\"Author-email: %s\", dist.get('author-email'))\n        logger.info(\"License: %s\", dist.get('license'))\n        logger.info(\"Location: %s\", dist['location'])\n        logger.info(\"Requires: %s\", ', '.join(dist['requires']))\n        logger.info(\"Classifiers:\")\n        for classifier in dist['classifiers']:\n            logger.info(\"  %s\", classifier)\n        if list_all_files:\n            logger.info(\"Files:\")\n            if 'files' in dist:\n                for line in dist['files']:\n                    logger.info(\"  %s\", line.strip())\n            else:\n                logger.info(\"Cannot locate installed-files.txt\")\n        if 'entry_points' in dist:\n            logger.info(\"Entry-points:\")\n            for line in dist['entry_points']:\n                logger.info(\"  %s\", line.strip())\n    return results_printed\n", "path": "pip/commands/show.py"}], "after_files": [{"content": "from __future__ import absolute_import\n\nfrom email.parser import FeedParser\nimport logging\nimport os\n\nfrom pip.basecommand import Command\nfrom pip.status_codes import SUCCESS, ERROR\nfrom pip._vendor import pkg_resources\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass ShowCommand(Command):\n    \"\"\"Show information about one or more installed packages.\"\"\"\n    name = 'show'\n    usage = \"\"\"\n      %prog [options] <package> ...\"\"\"\n    summary = 'Show information about installed packages.'\n\n    def __init__(self, *args, **kw):\n        super(ShowCommand, self).__init__(*args, **kw)\n        self.cmd_opts.add_option(\n            '-f', '--files',\n            dest='files',\n            action='store_true',\n            default=False,\n            help='Show the full list of installed files for each package.')\n\n        self.parser.insert_option_group(0, self.cmd_opts)\n\n    def run(self, options, args):\n        if not args:\n            logger.warning('ERROR: Please provide a package name or names.')\n            return ERROR\n        query = args\n\n        results = search_packages_info(query)\n        if not print_results(results, options.files):\n            return ERROR\n        return SUCCESS\n\n\ndef search_packages_info(query):\n    \"\"\"\n    Gather details from installed distributions. Print distribution name,\n    version, location, and installed files. Installed files requires a\n    pip generated 'installed-files.txt' in the distributions '.egg-info'\n    directory.\n    \"\"\"\n    installed = dict(\n        [(p.project_name.lower(), p) for p in pkg_resources.working_set])\n    query_names = [name.lower() for name in query]\n    for dist in [installed[pkg] for pkg in query_names if pkg in installed]:\n        package = {\n            'name': dist.project_name,\n            'version': dist.version,\n            'location': dist.location,\n            'requires': [dep.project_name for dep in dist.requires()],\n        }\n        file_list = None\n        metadata = None\n        if isinstance(dist, pkg_resources.DistInfoDistribution):\n            # RECORDs should be part of .dist-info metadatas\n            if dist.has_metadata('RECORD'):\n                lines = dist.get_metadata_lines('RECORD')\n                paths = [l.split(',')[0] for l in lines]\n                paths = [os.path.join(dist.location, p) for p in paths]\n                file_list = [os.path.relpath(p, dist.location) for p in paths]\n\n            if dist.has_metadata('METADATA'):\n                metadata = dist.get_metadata('METADATA')\n        else:\n            # Otherwise use pip's log for .egg-info's\n            if dist.has_metadata('installed-files.txt'):\n                paths = dist.get_metadata_lines('installed-files.txt')\n                paths = [os.path.join(dist.egg_info, p) for p in paths]\n                file_list = [os.path.relpath(p, dist.location) for p in paths]\n\n            if dist.has_metadata('PKG-INFO'):\n                metadata = dist.get_metadata('PKG-INFO')\n\n        if dist.has_metadata('entry_points.txt'):\n            entry_points = dist.get_metadata_lines('entry_points.txt')\n            package['entry_points'] = entry_points\n\n        installer = None\n        if dist.has_metadata('INSTALLER'):\n            for line in dist.get_metadata_lines('INSTALLER'):\n                if line.strip():\n                    installer = line.strip()\n                    break\n        package['installer'] = installer\n\n        # @todo: Should pkg_resources.Distribution have a\n        # `get_pkg_info` method?\n        feed_parser = FeedParser()\n        feed_parser.feed(metadata)\n        pkg_info_dict = feed_parser.close()\n        for key in ('metadata-version', 'summary',\n                    'home-page', 'author', 'author-email', 'license'):\n            package[key] = pkg_info_dict.get(key)\n\n        # It looks like FeedParser can not deal with repeated headers\n        classifiers = []\n        for line in metadata.splitlines():\n            if not line:\n                break\n            # Classifier: License :: OSI Approved :: MIT License\n            if line.startswith('Classifier: '):\n                classifiers.append(line[len('Classifier: '):])\n        package['classifiers'] = classifiers\n\n        if file_list:\n            package['files'] = sorted(file_list)\n        yield package\n\n\ndef print_results(distributions, list_all_files):\n    \"\"\"\n    Print the informations from installed distributions found.\n    \"\"\"\n    results_printed = False\n    for dist in distributions:\n        results_printed = True\n        logger.info(\"---\")\n        logger.info(\"Metadata-Version: %s\", dist.get('metadata-version'))\n        logger.info(\"Name: %s\", dist['name'])\n        logger.info(\"Version: %s\", dist['version'])\n        logger.info(\"Summary: %s\", dist.get('summary'))\n        logger.info(\"Home-page: %s\", dist.get('home-page'))\n        logger.info(\"Author: %s\", dist.get('author'))\n        logger.info(\"Author-email: %s\", dist.get('author-email'))\n        if dist['installer'] is not None:\n            logger.info(\"Installer: %s\", dist['installer'])\n        logger.info(\"License: %s\", dist.get('license'))\n        logger.info(\"Location: %s\", dist['location'])\n        logger.info(\"Requires: %s\", ', '.join(dist['requires']))\n        logger.info(\"Classifiers:\")\n        for classifier in dist['classifiers']:\n            logger.info(\"  %s\", classifier)\n        if list_all_files:\n            logger.info(\"Files:\")\n            if 'files' in dist:\n                for line in dist['files']:\n                    logger.info(\"  %s\", line.strip())\n            else:\n                logger.info(\"Cannot locate installed-files.txt\")\n        if 'entry_points' in dist:\n            logger.info(\"Entry-points:\")\n            for line in dist['entry_points']:\n                logger.info(\"  %s\", line.strip())\n    return results_printed\n", "path": "pip/commands/show.py"}]}