|
18 | 18 | InstallationError, CommandError, PreviousBuildDirError,
|
19 | 19 | )
|
20 | 20 | from pip import cmdoptions
|
21 |
| -from pip.utils import ensure_dir |
| 21 | +from pip.utils import ensure_dir, get_installed_version |
22 | 22 | from pip.utils.build import BuildDirectory
|
23 | 23 | from pip.utils.deprecation import RemovedInPip10Warning
|
24 | 24 | from pip.utils.filesystem import check_path_owner
|
@@ -341,16 +341,26 @@ def run(self, options, args):
|
341 | 341 | root=options.root_path,
|
342 | 342 | prefix=options.prefix_path,
|
343 | 343 | )
|
| 344 | + |
| 345 | + possible_lib_locations = get_lib_location_guesses( |
| 346 | + user=options.use_user_site, |
| 347 | + home=temp_target_dir, |
| 348 | + root=options.root_path, |
| 349 | + prefix=options.prefix_path, |
| 350 | + isolated=options.isolated_mode, |
| 351 | + ) |
344 | 352 | reqs = sorted(
|
345 | 353 | requirement_set.successfully_installed,
|
346 | 354 | key=operator.attrgetter('name'))
|
347 | 355 | items = []
|
348 | 356 | for req in reqs:
|
349 | 357 | item = req.name
|
350 | 358 | try:
|
351 |
| - if hasattr(req, 'installed_version'): |
352 |
| - if req.installed_version: |
353 |
| - item += '-' + req.installed_version |
| 359 | + installed_version = get_installed_version( |
| 360 | + req.name, possible_lib_locations |
| 361 | + ) |
| 362 | + if installed_version: |
| 363 | + item += '-' + installed_version |
354 | 364 | except Exception:
|
355 | 365 | pass
|
356 | 366 | items.append(item)
|
@@ -420,3 +430,8 @@ def run(self, options, args):
|
420 | 430 | )
|
421 | 431 | shutil.rmtree(temp_target_dir)
|
422 | 432 | return requirement_set
|
| 433 | + |
| 434 | + |
| 435 | +def get_lib_location_guesses(*args, **kwargs): |
| 436 | + scheme = distutils_scheme('', *args, **kwargs) |
| 437 | + return [scheme['purelib'], scheme['platlib']] |
0 commit comments