Archive for the ‘python’ Category

Building and Packaging a Python command-line tool for Debian

October 27, 2017 Leave a comment

Python packaging has a chequered past.

Distutils was and still is the original tool included with the standard library. But then setuptools was created to overcome the limitations of distutils, gained wide adoption, subsequently stagnated, and a fork called distribute was created to address some of the issues. Distutils2 was an attempt to take the best of previous tools to support Python 3, but it failed. Then distribute grew to support Python 3, was merged back in to setuptools, and everything else became moot!

Unfortunately, it’s hard to find reliable information on python packaging, because many articles you might find in a Duckduckgo search were created before setuptools was reinvigorated. Many reflect practices that are sub-optimal today, and I would disregard anything written before the distribute merge, which happened in March 2013.

While which packaging tool to use was ambiguous in the past, it’s now much easier to recommend one. At the time of writing (September 2016), you should use setuptools. It’s what most packages use, is fully supported by pypi and pip, and works pretty well. For a summary of the subject of python packaging tools, this page summarises them all very well. For an authoritative reference, see

Categories: debian, Interesting, python

May 4, 2017 Leave a comment


How did you become a software developer/tester/engineer/lead, etc?
Odds are we all are missing some important information to do our jobs most effectively.

This podcast is an attempt to fill those education gaps.
I focus on testing and process questions like “How do I know it works?”, “How do I effectively test?”, and the like.

But really, anything in the software development realm is fair game.

Categories: Interesting, python Tags: ,

Writing functional python

March 29, 2017 Leave a comment

The recent buzz surrounding Functional Programming (FP for short) is well deserved. Languages like Haskell and Clojure in use by big name companies such as Barclays Captial, Atlassian, and Walmart have helped FP ideas gain a major foothold in the industry. I am a Clojure hobbyist who has been interested in FP for some time so this is great news to me. But what exactly is FP, and why should a Python/Django programmer care? First, understanding FP will help you bring these sought-after ideas into your Python development. Second, you will quite likely begin to recognize instances where you have already been using these concepts, unknowingly!

Read more here ->

pip failed to install package

March 17, 2017 Leave a comment

Note to future self:

When installing a python package in a virtualenv using pip ie

pip install -r requirements.txt

If it fails to build and gives an error about something or the other.
Do a pip freeze and do a diff between what was installed and what is listed in requirements.txt

If there is a diff. Upgrade your pip version.

sudo pip install --upgrade pip

Try running the install again.

Categories: python Tags:

How to Run Python Tests “Continuously” While Coding

March 17, 2017 Leave a comment

Last week I was doing some Test Driven Development training and overheard someone mention another programming language that had a test runner that you could set up to watch your project directory and run your tests when the files changed.

Categories: Interesting, python


December 21, 2016 Leave a comment


QuickFix is designed to display compiler errors — a list of errors is displayed and can be selected to jump to a specific file and line.

:cn — Go to the next location in the list
:cp — Go to the previous location
:ccl — Close the quickfix window

Depending on where your quickfix window is. You can use below keys to move in and out of the window. (If quickfix window is at the bottom part of your screen)
CTRL-w + j — Move into the quickfix window
CTRL-w + k — Move out of the quickfix window

The window commands will work here. See link in source section below for more details.


Categories: python, vim Tags:

pip – ValueError: (‘Expected version spec in’…

December 20, 2016 Leave a comment

I was not able to install a package from pip.

$ pip -V
pip 1.5.4 from /home/vagrant/envs/projects/local/lib/python2.7/site-packages (python 2.7)

$ less requirements.txt


$ pip -r requirements.txt
Traceback (most recent call last):
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/", line 122, in main
    status =, args)
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/commands/", line 262, in run
    for req in parse_requirements(filename, finder=finder, options=options, session=session):
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/", line 1631, in parse_requirements
    req = InstallRequirement.from_line(line, comes_from, prereleases=getattr(options, "pre", None))
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/", line 172, in from_line
    return cls(req, comes_from, url=url, prereleases=prereleases)
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/", line 70, in __init__
    req = pkg_resources.Requirement.parse(req)
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/_vendor/", line 2606, in parse
    reqs = list(parse_requirements(s))
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/_vendor/", line 2544, in parse_requirements
    line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
  File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/_vendor/", line 2512, in scan_list
    raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', '--trusted-host', 'at', '')

Storing debug log for failure in /home/vagrant/.pip/pip.log

1. Upgrade pip. The version I was using does not accept the extra parameters specified in requirements.txt

$ pip -U install pip

2. Now run pip install command again.

1. Using a vagrant box running ubuntu trusty.