Skip to content

Commit cf9b162

Browse files
committed
search: deprecate --index in favor of --index-url
Fix pypa#589
1 parent db2b2d3 commit cf9b162

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pip/commands/search.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import logging
44
import sys
55
import textwrap
6+
import warnings
67

8+
from pip import cmdoptions
79
from pip.basecommand import Command, SUCCESS
810
from pip.download import PipXmlrpcTransport
9-
from pip.index import PyPI
1011
from pip.utils import get_terminal_size
12+
from pip.utils.deprecation import RemovedInPip10Warning
1113
from pip.utils.logging import indent_log
1214
from pip.exceptions import CommandError
1315
from pip.status_codes import NO_MATCHES_FOUND
@@ -31,8 +33,8 @@ def __init__(self, *args, **kw):
3133
'--index',
3234
dest='index',
3335
metavar='URL',
34-
default=PyPI.pypi_url,
3536
help='Base URL of Python Package Index (default %default)')
37+
self.cmd_opts.add_option(cmdoptions.index_url())
3638

3739
self.parser.insert_option_group(0, self.cmd_opts)
3840

@@ -53,7 +55,14 @@ def run(self, options, args):
5355
return NO_MATCHES_FOUND
5456

5557
def search(self, query, options):
56-
index_url = options.index
58+
if options.index is not None:
59+
warnings.warn(
60+
"--index has been deprecated in favor of --index-url.",
61+
RemovedInPip10Warning,
62+
)
63+
index_url = options.index
64+
else:
65+
index_url = options.index_url
5766
with self._build_session(options) as session:
5867
transport = PipXmlrpcTransport(index_url, session)
5968
pypi = xmlrpc_client.ServerProxy(index_url, transport)

0 commit comments

Comments
 (0)