Permalink
Browse files

Add dependencies information to 'show' command.

  • Loading branch information...
1 parent 35d704d commit 28aeb03b0893323acef26c082035ab6bd7ec8010 @carljm carljm committed Sep 21, 2012
Showing with 15 additions and 12 deletions.
  1. +3 −3 docs/usage.txt
  2. +6 −5 pip/commands/show.py
  3. +6 −4 tests/test_show.py
View
6 docs/usage.txt
@@ -26,8 +26,8 @@ local or remote::
.. _setuptools extras: http://peak.telecommunity.com/DevCenter/setuptools#declaring-extras-optional-features-with-their-own-dependencies
-Edit mode
-*********
+Editable mode
+*************
Packages normally_ install under ``site-packages``, but when you're
making changes, it makes more sense to run the package straight from the
@@ -151,7 +151,7 @@ Checking installed package status
---------------------------------
To get info about an installed package, including its location and included
-files, run ``pip status ProjectName``.
+files, run ``pip show ProjectName``.
Bundles
View
11 pip/commands/show.py
@@ -35,17 +35,17 @@ def search_packages_info(query):
pip generated 'installed-files.txt' in the distributions '.egg-info'
directory.
"""
- installed_packages = dict([(p.project_name.lower(), p.project_name) \
- for p in pkg_resources.working_set])
+ installed_packages = dict(
+ [(p.project_name.lower(), p) for p in pkg_resources.working_set])
for name in query:
normalized_name = name.lower()
if normalized_name in installed_packages:
- dist = pkg_resources.get_distribution( \
- installed_packages[normalized_name])
+ dist = installed_packages[normalized_name]
package = {
'name': dist.project_name,
'version': dist.version,
- 'location': dist.location
+ 'location': dist.location,
+ 'requires': [dep.project_name for dep in dist.requires()],
}
filelist = os.path.join(
dist.location,
@@ -65,6 +65,7 @@ def print_results(distributions, list_all_files):
logger.notify("Name: %s" % dist['name'])
logger.notify("Version: %s" % dist['version'])
logger.notify("Location: %s" % dist['location'])
+ logger.notify("Requires: %s" % ', '.join(dist['requires']))
if list_all_files:
logger.notify("Files:")
if 'files' in dist:
View
10 tests/test_show.py
@@ -12,11 +12,12 @@ def test_show():
reset_env()
result = run_pip('show', 'pip')
lines = result.stdout.split('\n')
- assert len(lines) == 5
+ assert len(lines) == 6
assert lines[0] == '---', lines[0]
assert lines[1] == 'Name: pip', lines[1]
assert lines[2] == 'Version: %s' % __version__, lines[2]
assert lines[3].startswith('Location: '), lines[3]
+ assert lines[4] == 'Requires: '
def test_show_with_files_not_found():
@@ -28,13 +29,14 @@ def test_show_with_files_not_found():
reset_env()
result = run_pip('show', '-f', 'pip')
lines = result.stdout.split('\n')
- assert len(lines) == 7
+ assert len(lines) == 8
assert lines[0] == '---', lines[0]
assert lines[1] == 'Name: pip', lines[1]
assert lines[2] == 'Version: %s' % __version__, lines[2]
assert lines[3].startswith('Location: '), lines[3]
- assert lines[4] == 'Files:', lines[4]
- assert lines[5] == 'Cannot locate installed-files.txt', lines[5]
+ assert lines[4] == 'Requires: '
+ assert lines[5] == 'Files:', lines[4]
+ assert lines[6] == 'Cannot locate installed-files.txt', lines[5]
def test_show_with_all_files():

0 comments on commit 28aeb03

Please sign in to comment.