mirror of https://github.com/pypa/pip
Allow combination of pip list options
--editable with --outdated/--updtodate closes #933
This commit is contained in:
parent
ea566fd341
commit
795798f3f0
|
@ -65,6 +65,9 @@
|
|||
|
||||
* Drop PasteScript specific egg_info hack. (:pull:`3270`)
|
||||
|
||||
* Allow combination of pip list options --editable with --outdated/--updtodate.
|
||||
(:issue:`933`)
|
||||
|
||||
|
||||
**7.1.2 (2015-08-22)**
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
|||
import warnings
|
||||
|
||||
from pip.basecommand import Command
|
||||
from pip.exceptions import DistributionNotFound
|
||||
from pip.exceptions import CommandError, DistributionNotFound
|
||||
from pip.index import FormatControl, fmt_ctl_formats, PackageFinder, Search
|
||||
from pip.req import InstallRequirement
|
||||
from pip.utils import (
|
||||
|
@ -37,12 +37,12 @@ class ListCommand(Command):
|
|||
'-o', '--outdated',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='List outdated packages (excluding editables)')
|
||||
help='List outdated packages')
|
||||
cmd_opts.add_option(
|
||||
'-u', '--uptodate',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='List uptodate packages (excluding editables)')
|
||||
help='List uptodate packages')
|
||||
cmd_opts.add_option(
|
||||
'-e', '--editable',
|
||||
action='store_true',
|
||||
|
@ -112,13 +112,14 @@ class ListCommand(Command):
|
|||
"no longer has any effect.",
|
||||
RemovedInPip10Warning,
|
||||
)
|
||||
if options.outdated and options.uptodate:
|
||||
raise CommandError(
|
||||
"Options --outdated and --uptodate cannot be combined.")
|
||||
|
||||
if options.outdated:
|
||||
self.run_outdated(options)
|
||||
elif options.uptodate:
|
||||
self.run_uptodate(options)
|
||||
elif options.editable:
|
||||
self.run_editables(options)
|
||||
else:
|
||||
self.run_listing(options)
|
||||
|
||||
|
@ -137,8 +138,10 @@ class ListCommand(Command):
|
|||
index_urls = []
|
||||
|
||||
dependency_links = []
|
||||
for dist in get_installed_distributions(local_only=options.local,
|
||||
user_only=options.user):
|
||||
for dist in get_installed_distributions(
|
||||
local_only=options.local,
|
||||
user_only=options.user,
|
||||
editables_only=options.editable):
|
||||
if dist.has_metadata('dependency_links.txt'):
|
||||
dependency_links.extend(
|
||||
dist.get_metadata_lines('dependency_links.txt'),
|
||||
|
@ -151,7 +154,7 @@ class ListCommand(Command):
|
|||
installed_packages = get_installed_distributions(
|
||||
local_only=options.local,
|
||||
user_only=options.user,
|
||||
include_editables=False,
|
||||
editables_only=options.editable,
|
||||
)
|
||||
format_control = FormatControl(set(), set())
|
||||
wheel_cache = WheelCache(options.cache_dir, format_control)
|
||||
|
@ -189,14 +192,7 @@ class ListCommand(Command):
|
|||
installed_packages = get_installed_distributions(
|
||||
local_only=options.local,
|
||||
user_only=options.user,
|
||||
)
|
||||
self.output_package_listing(installed_packages)
|
||||
|
||||
def run_editables(self, options):
|
||||
installed_packages = get_installed_distributions(
|
||||
local_only=options.local,
|
||||
user_only=options.user,
|
||||
editables_only=True,
|
||||
editables_only=options.editable,
|
||||
)
|
||||
self.output_package_listing(installed_packages)
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ def test_uptodate_flag(script, data):
|
|||
expect_stderr=True,
|
||||
)
|
||||
assert 'simple (1.0)' not in result.stdout # 3.0 is latest
|
||||
assert 'pip-test-package' not in result.stdout # editables excluded
|
||||
assert 'pip-test-package (0.1.1,' in result.stdout # editables included
|
||||
assert 'simple2 (3.0)' in result.stdout, str(result)
|
||||
|
||||
|
||||
|
@ -75,7 +75,8 @@ def test_outdated_flag(script, data):
|
|||
)
|
||||
script.pip(
|
||||
'install', '-e',
|
||||
'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package'
|
||||
'git+https://github.com/pypa/pip-test-package.git'
|
||||
'@0.1#egg=pip-test-package'
|
||||
)
|
||||
result = script.pip(
|
||||
'list', '-f', data.find_links, '--no-index', '--outdated',
|
||||
|
@ -83,7 +84,9 @@ def test_outdated_flag(script, data):
|
|||
)
|
||||
assert 'simple (Current: 1.0 Latest: 3.0 [sdist])' in result.stdout
|
||||
assert 'simplewheel (Current: 1.0 Latest: 2.0 [wheel])' in result.stdout
|
||||
assert 'pip-test-package' not in result.stdout # editables excluded
|
||||
assert (
|
||||
'pip-test-package (Current: 0.1 Latest: 0.1.1 [sdist])'
|
||||
in result.stdout)
|
||||
assert 'simple2' not in result.stdout, str(result) # 3.0 is latest
|
||||
|
||||
|
||||
|
@ -102,3 +105,46 @@ def test_editables_flag(script, data):
|
|||
assert os.path.join('src', 'pip-test-package') in result.stdout, (
|
||||
str(result)
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.network
|
||||
def test_uptodate_editables_flag(script, data):
|
||||
"""
|
||||
test the behavior of --editable --uptodate flag in the list command
|
||||
"""
|
||||
script.pip('install', '-f', data.find_links, '--no-index', 'simple==1.0')
|
||||
result = script.pip(
|
||||
'install', '-e',
|
||||
'git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package'
|
||||
)
|
||||
result = script.pip(
|
||||
'list', '-f', data.find_links, '--no-index',
|
||||
'--editable', '--uptodate',
|
||||
expect_stderr=True,
|
||||
)
|
||||
assert 'simple (1.0)' not in result.stdout, str(result)
|
||||
assert os.path.join('src', 'pip-test-package') in result.stdout, (
|
||||
str(result)
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.network
|
||||
def test_outdated_editables_flag(script, data):
|
||||
"""
|
||||
test the behavior of --editable --outdated flag in the list command
|
||||
"""
|
||||
script.pip('install', '-f', data.find_links, '--no-index', 'simple==1.0')
|
||||
result = script.pip(
|
||||
'install', '-e',
|
||||
'git+https://github.com/pypa/pip-test-package.git'
|
||||
'@0.1#egg=pip-test-package'
|
||||
)
|
||||
result = script.pip(
|
||||
'list', '-f', data.find_links, '--no-index',
|
||||
'--editable', '--outdated',
|
||||
expect_stderr=True,
|
||||
)
|
||||
assert 'simple (1.0)' not in result.stdout, str(result)
|
||||
assert os.path.join('src', 'pip-test-package') in result.stdout, (
|
||||
str(result)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue