question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pip search` returns results that only partially match the string

See original GitHub issue

STR: (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:

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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
daverickdunncommented, Jun 27, 2016

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…

0reactions
dstufftcommented, Mar 30, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found