File tree 4 files changed +23
-19
lines changed
4 files changed +23
-19
lines changed Original file line number Diff line number Diff line change 6
6
from pip .req import InstallRequirement
7
7
from pip .log import logger
8
8
from pip .basecommand import Command
9
- from pip .util import get_installed_distributions
10
- from pip ._vendor import pkg_resources
9
+ from pip .util import get_installed_distributions , recursive_dependencies
11
10
12
11
13
12
# packages to exclude from freeze output
14
13
freeze_excludes = stdlib_pkgs + ['setuptools' , 'pip' , 'distribute' ]
15
14
16
15
17
- def recursive_dependencies (query ):
18
- """Return list of dependencies of ``dists``, recursively."""
19
- dependencies = set ()
20
- installed = dict (
21
- [(p .project_name .lower (), p ) for p in pkg_resources .working_set ])
22
- query_names = [name .lower () for name in query ]
23
- for pkg in query_names :
24
- try :
25
- dist = installed [pkg ]
26
- for dep in dist .requires ():
27
- dependencies .add (dep .project_name )
28
- dependencies .update (recursive_dependencies ([dep .project_name ]))
29
- except KeyError :
30
- pass # pkg is not installed.
31
- return dependencies
32
-
33
-
34
16
class FreezeCommand (Command ):
35
17
"""
36
18
Output installed packages in requirements format.
Original file line number Diff line number Diff line change 2
2
3
3
from pip .basecommand import Command
4
4
from pip .log import logger
5
+ from pip .util import recursive_dependencies
5
6
from pip ._vendor import pkg_resources
6
7
7
8
@@ -78,6 +79,8 @@ def print_results(distributions, list_all_files):
78
79
logger .notify ("Version: %s" % dist ['version' ])
79
80
logger .notify ("Location: %s" % dist ['location' ])
80
81
logger .notify ("Requires: %s" % ', ' .join (dist ['requires' ]))
82
+ logger .notify ("Requires recursive: %s" % ', ' .join (
83
+ recursive_dependencies ([dist ['name' ]])))
81
84
if list_all_files :
82
85
logger .notify ("Files:" )
83
86
if dist ['files' ] is not None :
Original file line number Diff line number Diff line change @@ -400,6 +400,23 @@ def get_installed_distributions(local_only=True,
400
400
]
401
401
402
402
403
+ def recursive_dependencies (query ):
404
+ """Return list of dependencies of dists in ``query``, recursively."""
405
+ dependencies = set ()
406
+ installed = dict (
407
+ [(p .project_name .lower (), p ) for p in pkg_resources .working_set ])
408
+ query_names = [name .lower () for name in query ]
409
+ for pkg in query_names :
410
+ try :
411
+ dist = installed [pkg ]
412
+ for dep in dist .requires ():
413
+ dependencies .add (dep .project_name )
414
+ dependencies .update (recursive_dependencies ([dep .project_name ]))
415
+ except KeyError :
416
+ pass # pkg is not installed.
417
+ return dependencies
418
+
419
+
403
420
def egg_link_path (dist ):
404
421
"""
405
422
Return the path for the .egg-link file if it exists, otherwise, None.
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ def test_show(script):
15
15
assert lines [2 ] == 'Version: %s' % __version__ , lines [2 ]
16
16
assert lines [3 ].startswith ('Location: ' ), lines [3 ]
17
17
assert lines [4 ] == 'Requires: '
18
+ assert lines [5 ] == 'Requires recursive: '
18
19
19
20
20
21
def test_show_with_files_not_found (script , data ):
@@ -32,6 +33,7 @@ def test_show_with_files_not_found(script, data):
32
33
assert lines [2 ] == 'Version: 0.0.0' , lines [2 ]
33
34
assert lines [3 ].startswith ('Location: ' ), lines [3 ]
34
35
assert lines [4 ] == 'Requires: ' , lines [4 ]
36
+ assert lines [4 ] == 'Requires recursive: ' , lines [5 ]
35
37
assert lines [5 ] == 'Files:' , lines [5 ]
36
38
assert lines [6 ] == 'Cannot locate installed-files.txt' , lines [6 ]
37
39
You can’t perform that action at this time.
0 commit comments