So I wanted to try my hand at some Unity Lens writing again (the first time being unity-lens-vm). After thinking all day Sunday for what kind of lens I wanted, I eventually came up with a lens for PyPi. For those that don’t know, PyPi is the python package index, which allows users to find and install almost any python module. You can search either on the site (http://pypi.python.org) or by using pip search.
Now, instead of going through all that trouble, you can simply search for available or installed modules from the Unity Dash. One thing that I was particularly concerned about was speed, especially with the slow pypi site, and ‘pip search simple’ taking 6 seconds on my machine. To do this as quickly as possible, I pull the list of modules from a pypi mirror (http://g.pypi.python.org/simple/) and perform the searching myself. To make it even quicker, the data is only pulled from the web on the first search ( the first search of each unity session), and then re-used. Again due to speed, the results are limited to 100 results, as this is about searching more than browsing. Clicking on a result will open it’s description page on PyPi.
Check out the lens in action!
Unity-lens-pypi was written using Quickly and Singlet, on Ubuntu 12.04. It is available in ppa:scopes-packagers/ppa.
I’m actually quite proud of this lens, as I find it more useful than pip search or using the site. It’s certainly faster in most cases.
To install the lens:
sudo add-apt-repository ppa:scopes-packagers/ppa
sudo apt-get update
sudo apt-get install unity-lens-pypi