Python packaging is a common theme on which to complain, and rightly so. It’s no one’s first love, so it tends not to get the devoted attention of say, Numpy. And it’s a hard problem to solve well. So we have a mish-mash of tools that each do about 75% of the job.
But there’s one small aspect of Python packaging that could easily be solved well if people just attended to it: Not enough Python projects clearly state what versions of Python they run on.
For example, suppose you are in the market for a mock object library for your tests. There’s no shortage. Less than a minute at PyPI produces mock, MiniMock, mocktest, Mocky, pmock, mocker, mockito, and ludibrio. Some of those PyPI pages have extensive documentation. Not a single one explicitly mentions the versions of Python supported. And I don’t mean 2.x vs. 3.x. I want to know if it will run on 2.4 or not. Ludibrio and Mocky offer a slight clue in that they are available for download as an egg, for 2.5 and 2.4 respectively. pMock mentions >= 2.3 support on the home page linked from the PyPI page.
On top of all the other well-known difficulties people have with Python packaging, at the very least, we should be able to manage this: clearly state what versions of Python you support. This is a simple three-step process:
- Decide what versions you want to support.
- Test your code on those versions.
- Add a sentence like this to your PyPI documentation: “SpockMocker runs on Python 2.5 and 2.6”.
The Python community will thank you.