show: add PEP376 INSTALLER information

closes #3517
This commit is contained in:
Xavier Fernandez 2016-03-04 13:54:00 +01:00
parent f3b27b00cd
commit dc533f8469
3 changed files with 25 additions and 2 deletions

View File

@ -14,6 +14,8 @@
* Show classifiers in ``pip show``.
* Show PEP376 Installer in ``pip show`` (:issue:`3517`).
* Unhide completion command (:pull:`1810`).
* Decode requirement files according to their BOM if present (:pull:`3485`,

View File

@ -85,6 +85,14 @@ def search_packages_info(query):
entry_points = dist.get_metadata_lines('entry_points.txt')
package['entry_points'] = entry_points
installer = 'UNKNOWN'
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,7 @@ def print_results(distributions, list_all_files):
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'))
logger.info("Installer: %s", dist.get('installer'))
logger.info("License: %s", dist.get('license'))
logger.info("Location: %s", dist['location'])
logger.info("Requires: %s", ', '.join(dist['requires']))

View File

@ -10,7 +10,7 @@ def test_show(script):
"""
result = script.pip('show', 'pip')
lines = result.stdout.split('\n')
assert len(lines) == 30
assert len(lines) == 31
assert lines[0] == '---', lines[0]
assert 'Name: pip' in lines
assert 'Version: %s' % __version__ in lines
@ -27,7 +27,7 @@ def test_show_with_files_not_found(script, data):
script.pip('install', '-e', editable)
result = script.pip('show', '-f', 'SetupPyUTF8')
lines = result.stdout.split('\n')
assert len(lines) == 15
assert len(lines) == 16
assert lines[0] == '---', lines[0]
assert 'Name: SetupPyUTF8' in lines
assert 'Version: 0.0.0' in lines
@ -107,3 +107,15 @@ def test_show_with_classifiers(script, data):
assert 'Name: pip' in lines
assert re.search(r"Classifiers:\n( .+\n)+", result.stdout)
assert "Intended Audience :: Developers" in result.stdout
def test_show_installer(script, data):
"""
Test that the installer is shown (this currently needs a wheel install)
"""
wheel_file = data.packages.join('simple.dist-0.1-py2.py3-none-any.whl')
script.pip('install', '--no-index', wheel_file)
result = script.pip('show', 'simple.dist')
lines = result.stdout.split('\n')
assert 'Name: simple.dist' in lines
assert 'Installer: pip' in lines