Skip to content

Commit 353b9c9

Browse files
committed
Remove 'pip search'
1 parent b1a8539 commit 353b9c9

File tree

14 files changed

+29
-490
lines changed

14 files changed

+29
-490
lines changed

docs/html/cli/index.md

-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ pip_wheel
3131
pip_hash
3232
```
3333

34-
```{toctree}
35-
:maxdepth: 1
36-
:caption: Package Index information
37-
38-
pip_search
39-
```
40-
4134
```{toctree}
4235
:maxdepth: 1
4336
:caption: Managing pip itself

docs/html/cli/pip_search.rst

+1-46
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,4 @@
44
pip search
55
==========
66

7-
8-
9-
Usage
10-
=====
11-
12-
.. tab:: Unix/macOS
13-
14-
.. pip-command-usage:: search "python -m pip"
15-
16-
.. tab:: Windows
17-
18-
.. pip-command-usage:: search "py -m pip"
19-
20-
21-
Description
22-
===========
23-
24-
.. pip-command-description:: search
25-
26-
27-
Options
28-
=======
29-
30-
.. pip-command-options:: search
31-
32-
33-
Examples
34-
========
35-
36-
#. Search for "peppercorn"
37-
38-
.. tab:: Unix/macOS
39-
40-
.. code-block:: console
41-
42-
$ python -m pip search peppercorn
43-
pepperedform - Helpers for using peppercorn with formprocess.
44-
peppercorn - A library for converting a token stream into [...]
45-
46-
.. tab:: Windows
47-
48-
.. code-block:: console
49-
50-
C:\> py -m pip search peppercorn
51-
pepperedform - Helpers for using peppercorn with formprocess.
52-
peppercorn - A library for converting a token stream into [...]
7+
The ``pip search`` command has been removed.

docs/html/user_guide.rst

-23
Original file line numberDiff line numberDiff line change
@@ -428,29 +428,6 @@ For more information and examples, see the :ref:`pip list` and :ref:`pip show`
428428
reference pages.
429429

430430

431-
Searching for Packages
432-
======================
433-
434-
pip can search `PyPI`_ for packages using the ``pip search``
435-
command:
436-
437-
.. tab:: Unix/macOS
438-
439-
.. code-block:: shell
440-
441-
python -m pip search "query"
442-
443-
.. tab:: Windows
444-
445-
.. code-block:: shell
446-
447-
py -m pip search "query"
448-
449-
The query will be used to search the names and summaries of all
450-
packages.
451-
452-
For more information and examples, see the :ref:`pip search` reference.
453-
454431
.. _`Configuration`:
455432

456433

docs/man/commands/search.rst

-20
This file was deleted.

docs/man/index.rst

-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ pip-show(1)
4343
pip-check(1)
4444
Verify installed packages have compatible dependencies.
4545

46-
pip-search(1)
47-
Search PyPI for packages.
48-
4946
pip-wheel(1)
5047
Build wheels from your requirements.
5148

news/5216.removal.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the ``pip search`` command as it is basically a no-op with PyPI.

setup.cfg

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ markers =
6969
svn: VCS: Subversion
7070
mercurial: VCS: Mercurial
7171
git: VCS: git
72-
search: tests for 'pip search'
7372

7473
[coverage:run]
7574
branch = True

src/pip/_internal/commands/__init__.py

-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@
5858
"ConfigurationCommand",
5959
"Manage local and global configuration.",
6060
),
61-
"search": CommandInfo(
62-
"pip._internal.commands.search",
63-
"SearchCommand",
64-
"Search PyPI for packages.",
65-
),
6661
"cache": CommandInfo(
6762
"pip._internal.commands.cache",
6863
"CacheCommand",

src/pip/_internal/commands/index.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
from typing import Any, Iterable, List, Optional, Union
44

55
from pip._vendor.packaging.version import LegacyVersion, Version
6+
from pip._vendor.packaging.version import parse as parse_version
67

78
from pip._internal.cli import cmdoptions
89
from pip._internal.cli.req_command import IndexGroupCommand
910
from pip._internal.cli.status_codes import ERROR, SUCCESS
10-
from pip._internal.commands.search import print_dist_installation_info
1111
from pip._internal.exceptions import CommandError, DistributionNotFound, PipError
1212
from pip._internal.index.collector import LinkCollector
1313
from pip._internal.index.package_finder import PackageFinder
14+
from pip._internal.metadata import get_default_environment
1415
from pip._internal.models.selection_prefs import SelectionPreferences
1516
from pip._internal.models.target_python import TargetPython
1617
from pip._internal.network.session import PipSession
18+
from pip._internal.utils.logging import indent_log
1719
from pip._internal.utils.misc import write_output
1820

1921
logger = logging.getLogger(__name__)
@@ -136,3 +138,22 @@ def get_available_package_versions(self, options: Values, args: List[Any]) -> No
136138
write_output("{} ({})".format(query, latest))
137139
write_output("Available versions: {}".format(", ".join(formatted_versions)))
138140
print_dist_installation_info(query, latest)
141+
142+
143+
def print_dist_installation_info(name: str, latest: str) -> None:
144+
env = get_default_environment()
145+
dist = env.get_distribution(name)
146+
if dist is not None:
147+
with indent_log():
148+
if dist.version == latest:
149+
write_output("INSTALLED: %s (latest)", dist.version)
150+
else:
151+
write_output("INSTALLED: %s", dist.version)
152+
if parse_version(latest).pre:
153+
write_output(
154+
"LATEST: %s (pre-release; install"
155+
" with `pip install --pre`)",
156+
latest,
157+
)
158+
else:
159+
write_output("LATEST: %s", latest)

src/pip/_internal/commands/search.py

-174
This file was deleted.

tests/conftest.py

-9
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,13 @@ def pytest_addoption(parser):
5050
default=False,
5151
help="use venv for virtual environment creation",
5252
)
53-
parser.addoption(
54-
"--run-search",
55-
action="store_true",
56-
default=False,
57-
help="run 'pip search' tests",
58-
)
5953

6054

6155
def pytest_collection_modifyitems(config, items):
6256
for item in items:
6357
if not hasattr(item, "module"): # e.g.: DoctestTextfile
6458
continue
6559

66-
if item.get_closest_marker("search") and not config.getoption("--run-search"):
67-
item.add_marker(pytest.mark.skip("pip search test skipped"))
68-
6960
if "CI" in os.environ:
7061
# Mark network tests as flaky
7162
if item.get_closest_marker("network") is not None:

0 commit comments

Comments
 (0)