I'm a core maintainer of Django-Tastypie, the oldest REST framework for Django. It predates Django-Rest-Framework and comes from the very earliest days of Class-Based Views, from when they were still very controversial. It's still in use by a lot of developers and companies, though these days the primary development efforts are in keeping it up-to-date with Django releases and bugfixing. It's still in Beta for some legacy reasons, but it's exceptionally mature.

This post is about a task I do roughly once a year, and forget how to do correctly every time: cut a new release. Because release management is not part of my day job and because I only do it once or twice a year, I always get something wrong.

The Right Process (for tastypie)

1. Bump the version number in tastypie.VERSION

TastyPie's version is written in one and only one place in the code: tastypie.VERSION. Every other mention of the version in code imports from that, to keep things from getting out of sync.

2. Update the Release Notes

The release notes are included in the docs. Every new release gets a new notes file, which must also be linked from the release_notes/index.rst page.

Tracking everything that has changed since the last release is a difficult but necessary step. In a perfect world, you'd be tracking changes as they are made, but this is hard enough for a single-developer project much less a community-maintained project. Instead, GitHub provides some tools for this on the Releases page. By default, this page shows the last release and, crucially, a link to show all commits made to master since this release. I try to keep this to the broad strokes, keeping the nitty-gritty details confined to our Backwards-Incompatible Changes file.

3. Release to PyPI

Make sure everything is ready to go before this step. It's not possible to change a release once published to PyPI.

Every time I do this, the toolchain has changed. Most recently, the preferred tool has changed to Twine which was relatively painless (if arcane):

$ pip install twine
$ python setup.py sdist
$ twine upload dist/*

You can provide authentication for twine in a configuration file, but given the recent NPM credential debacle it is probably a good idea to avoid putting your PyPI password in any cleartext file.

4. Create a Github Release / Tag

"Releasing" a Python library on GitHub is a bit of an anachronism; most users will be deploying from PyPI. But it is a simple process (just create a new Draft Release from the Releases page, pointing at either master or a release tag.) and worth it for the rollup diffs and commit log alone. But also, bafflingly, some linux distros still build TastyPie as a package, and they rely on github tags/releases to know when to build a new package.

Go to the releases page to draft a new release, picking the same commit that was published to PyPI to create a tag and name the release similarly.


Detecting Incomplete or Missing Migrations with Django and CircleCI

Tue 04 October 2016 by George Dorn

Update (2017-06-15): Django 1.10 added --check and deprecated --exit. This makes the logic far more easy to follow. Just run this instead:

python manage.py makemigration --dry-run --no-input --check

And the same command will work in CircleCI (or your favorite CI service.)

Original, deprecated:

It's pretty easy to ...

read more

Auto Screenshot Selenium Test Failures (In Django)

Thu 22 September 2016 by George Dorn

These days, every codebase I work on runs tests under some form of third-party continuous integration. This is great, because people are lazy and don't always run all of their tests before pushing. But it's not so great when trying to debug why a test failed on the ...

read more

Multitouch on newer Elantech Touchpads in Linux

Sun 23 June 2013 by George Dorn

I'm running Linux Mint 14 XFCE on a Gigabyte U2442. The touchpad ends up recognized as a PS2 mouse and therefore lacks touchpad features. Several symptoms:

"Couldn't find synaptics properties. No synaptics driver loaded?" when running synclient.

The device showing up as "PS/2 Generic Mouse" when running ...

read more

Using Tastypie Inside Django

Wed 21 November 2012 by George Dorn

Make use of a Tastypie's API from within Django

Tastypie is an excellent way to generate a REST API with minimal coding. But often it exists as a separate means of accessing your data, with its own implementation of your business logic, while your views also implement business logic ...

read more

Legacy BooleanField in Django

Mon 29 November 2010 by George Dorn

A legacy BooleanField supporting all kinds of antiquated ways of storing boolean values.

Django's inspectdb is pretty good at providing models that will at least read and write from your legacy database. But to get real power out of the ORM, you may need to provide some custom mapping ...

read more

Using Django Auth with a legacy app

Tue 09 November 2010 by George Dorn

One strategy for integrating a legacy python application with Django.

At work, we're planning to switch to Django. Rather than doing a complete feature freeze for six months while we rewrite the site in Django, the decision has been made to run two codebases and migrate features to Django ...

read more

Django vs SQAlchemy (vs PyDO) Speed Tests

Fri 29 October 2010 by George Dorn

Speed tests for SQLAlchemy vs Django vs PyDO

At work, we're preparing to move away from a 6-year-old homebrew web framework to Django. In the process, I figured I'd do some speed tests of the old ORM (PyDO, version one, last updated in 2004 and with an author ...

read more

Hygienic unit testing with Solr.

Mon 13 September 2010 by George Dorn

Python unittest hygiene and Solr.

A sane methodology for testing an application that uses a database looks like this:

  1. Prop up an empty database, preferably using the same engine as production.
  2. Import some fixture data to play with (optional).
  3. Run tests that manipulate data in this database.
  4. Roll back the ...
read more

The State of WSGI and character encoding.

Tue 03 August 2010 by George Dorn

Imagine you've inherited a legacy codebase with urls that look like this:

http://host.com/music/{band_name}
http://host.com/music/{band_name}/{album_name}

Now imagine that you have over a million unique bands in your database, in dozens of languages with all sorts of weird punctuation. Ignoring the special ...

read more