Improving and extending the search functionality of Python’s pip
If you are a Python developer chances are you use pip on a regular basis. The usage is easy and straightforward. But have you ever tried its search function? Ugly.
The main reason I’m in love with Python is the elegance and beauty of the design the language holds. Why not improve a bit on pip search to match the aesthetics? That’s why I created yip. At first, I only wanted to add some formatting and coloring to the mix and a menu (like the one yaourt has) to easily choose a package from the search results and install it. Something like this:
I was quite happy with the outcome so I put it on GitHub and shared it on Reddit. The response from the python community was very positive but suggested some that I should include some extra features as well. After looking into the PyPI API this seemed achievable. So instead of parsing pip’s search results I wrote my own frontend for PyPI with
- a custom ranking system
- extra info like size, upload date, license and homepage
- regex search
- optional configuration file
- nice options menu after selecting a package
I tried to make the syntax as user-friendly as possible:
yip <search_term> <optional_flags>
The flags you can apply to your search are:
-date: shows the upload the of the packages
-homepage: shows the homepage
-license: shows the license
-size: shows the size in a human readable format
-limit <number>: limits the results to the <number> most relevant
-regex: enable regex on the search term — important: this will automatically disable the limit flag!
So for example if you want to display the size and upload date of the 10 most relevant search result for the keyword ffmpeg, you do it like so:
yip ffmpeg -size -date -limit 10
There are some other things you can set from the config file:
- default search limit
- use any of the flags by default
- disable colors
- automatically install packages with sudo
Here it is in action:
If you found it interesting check it out on GitHub where you can find more information and installation instructions.
Any suggestion, idea, opinion, problem or feature request is very welcome! Thank you for reading it!