What publishing a python module taught me

· Read in about 2 min · (304 words) ·

Programming in Python

So I’ve mostly used python for one off scripts and tools and at one point for a serious foray into Django - but never came into a situation where I’d thought of publishing anything.

Hmm - crossed that bridge over this weekend - and its been a fun journey. I’m writing this post with what I wrote :)

Things I’ve picked up

  1. Better understanding into Python modules, classes and code organization for libraries.

  2. Good unit tests

  3. Mocking in python

  1. Packaging with setup.py

  2. pip, setuptools, easy_install and their idiosyncracies

  3. Install a platform specific script

  4. PyPI - registering and publishing

    • Tutorial One point to note - if you create the .pypirc manually, you will need to manually do a python setup.py register. If you skip that, python setup.py sdist upload will fail with a 403.

  1. virtualenv - this link

  2. Testing platform specific scripts installed with tools above

  3. Coverage

Coding/Style/Syntax linting
  1. pyflakes, pylame, pep8 and integration in Vim with Syntastic

What I really, really liked

  1. That I didn’t miss a debugger

  2. That tests were short and sweet

  3. good code coverage out of the box

  4. pip

  5. Overall, how pleasant it was and how much I enjoyed it.

Where I had hiccups

  1. Mocks in python were a little hard to debug/understand

  2. Should have written the tests first - but it came as an afterthought after I decided to publish.

  3. Finding good documentation on packaging - for ex:, its hard to find a good walkthrough of how to publish

Just putting finishing touches and a little polish for a v0.9 release. Basically this post itself is nothing but a test. Should be out with it in a day or two.