`pip search` returns results that only partially match the string
See original GitHub issueSTR: (Using pip v7.1.2 with Python 2.7.10 under MSYS2.)
pip search "treeherder-client"
Expected: One result, the same as when just the string “treeherder” is used instead, eg:
[~/src]$ pip search "treeherder"
treeherder-client - Python library to retrieve and submit data to the Treeherder API
Actual:
[~/src]$ pip search "treeherder-client" | wc -l
311
[~/src]$ pip search "treeherder-client" | tail -n 5
basket-client - A Python client for Mozilla's basket service.
OnPage-HUB-API-Client - Send Page to pager using OnPage HUB API
egenix-mxodbc-connect-client - eGenix mxODBC Connect Client for Python
hapi-client - HyperDNS HAPI Client Libraries and CLI Tools
medeox-provider-client - A Medeox provider client library
These results contain the string “client” but not “treeherder”.
It would appear pip search is splitting strings on hyphens and then finding any results that match any of the resultant substrings. This is:
- not documented in the output of
pip search -hor https://pip.pypa.io/en/stable/reference/pip_search/ - not the behaviour that makes the most sense (IMO)
PyPI’s own search does return many results too, but at least that’s sorted by weight: https://pypi.python.org/pypi?%3Aaction=search&term=treeherder-client&submit=search
Perhaps the output from pip search could:
- sort by how precise a match it is
- offer pagination (311 results is not overly helpful)
- either default to exact-match (particularly if there are hundreds of results), or at least offer that as an option
Many thanks 😃
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Accessing A series value based on partial match of a string
1 Answer 1 · problem is I am matching the pattern via a string 's' above. · You can split the user input...
Read more >String comparison in Python (exact/partial match, etc.)
Use the in operator for partial matches, i.e., whether one string contains the other string. x in y returns True if x is...
Read more >String - Robot Framework
Returns a list of all non-overlapping matches in the given string. string is the string to find matches from and pattern is the...
Read more >Python Regex – How to Match the Start of Line (^) and End of ...
The re.search(pattern, string, flags=0) method returns a match object of the first match. Read more in our blog tutorial. The re.match(pattern, string, flags=0) ......
Read more >re – Regular Expressions - Python Module of the Week
search () takes the pattern and text to scan, and returns a Match object when ... be escaped in normal Python strings, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Sorry to bump this aging thread, but has this been considered for future updates? Seems like a very simple to implement, yet extremely useful feature; just a simple option to do a strict match. It’s irrelevant if the PyPI API is no longer maintained, all a user needs are the results filtered. One is often forced to pipe into grep to find what they want, but that of course doesn’t help Windows users…
Closing this since pip is just using the PyPI search interface and thus it has no mechanism to really control it’s searching mechanism. However if we implement something like #395 then we could work on something like this.