Skip to content

Commit 094dac8

Browse files
committed
Remove 'pip search'
1 parent bc45b93 commit 094dac8

File tree

13 files changed

+29
-294
lines changed

13 files changed

+29
-294
lines changed

docs/html/cli/index.md

Lines changed: 0 additions & 7 deletions
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

Lines changed: 1 addition & 46 deletions
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

Lines changed: 0 additions & 23 deletions
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

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/man/index.rst

Lines changed: 0 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ markers =
6666
svn: VCS: Subversion
6767
mercurial: VCS: Mercurial
6868
git: VCS: git
69-
search: tests for 'pip search'
7069

7170
[coverage:run]
7271
branch = True

src/pip/_internal/commands/__init__.py

Lines changed: 0 additions & 5 deletions
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

Lines changed: 22 additions & 1 deletion
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__)
@@ -137,3 +139,22 @@ def get_available_package_versions(self, options: Values, args: List[Any]) -> No
137139
write_output("{} ({})".format(query, latest))
138140
write_output("Available versions: {}".format(", ".join(formatted_versions)))
139141
print_dist_installation_info(query, latest)
142+
143+
144+
def print_dist_installation_info(name: str, latest: str) -> None:
145+
env = get_default_environment()
146+
dist = env.get_distribution(name)
147+
if dist is not None:
148+
with indent_log():
149+
if dist.version == latest:
150+
write_output("INSTALLED: %s (latest)", dist.version)
151+
else:
152+
write_output("INSTALLED: %s", dist.version)
153+
if parse_version(latest).pre:
154+
write_output(
155+
"LATEST: %s (pre-release; install"
156+
" with `pip install --pre`)",
157+
latest,
158+
)
159+
else:
160+
write_output("LATEST: %s", latest)

src/pip/_internal/commands/search.py

Lines changed: 0 additions & 174 deletions
This file was deleted.

tests/conftest.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,13 @@ def pytest_addoption(parser: Parser) -> None:
6464
default=False,
6565
help="use venv for virtual environment creation",
6666
)
67-
parser.addoption(
68-
"--run-search",
69-
action="store_true",
70-
default=False,
71-
help="run 'pip search' tests",
72-
)
7367

7468

7569
def pytest_collection_modifyitems(config: Config, items: List[pytest.Item]) -> None:
7670
for item in items:
7771
if not hasattr(item, "module"): # e.g.: DoctestTextfile
7872
continue
7973

80-
if item.get_closest_marker("search") and not config.getoption("--run-search"):
81-
item.add_marker(pytest.mark.skip("pip search test skipped"))
82-
8374
if "CI" in os.environ:
8475
# Mark network tests as flaky
8576
if item.get_closest_marker("network") is not None:

0 commit comments

Comments
 (0)