Sunday, September 2, 2012

Quick Fix: Upgrading Zope Interface so you can work on Twisted trunk post-12.2 release

Immediately after the recent 12.2 release, Twisted has upgraded its required version of Zope Interface.  Some platforms ship with a system-installed version of Zope Interface that is slightly too old for this change.  You may have noticed an unhelpful error message if you happened to svn up before learning about this change.

Upgrading system-installed Python packages without doing harm can be a challenge, so in this post we'll provide simple instructions for users who:
  • have a system-installed version of Zope Interface
  • are on a Unix-y platform, like Linux, BSD, or OS X (if you're on Windows, just upgrade to the latest on your system installation)
  • are not using a tool like virtualenv or Combinator to manage Zope Interface (if you are, you should already know what to do!)
  • don't want to upgrade anything system-wide, so as to avoid disturbing other users or software on their system
  • have easy_install already available in their environment.  (While Pip is generally better, it is pre-installed less often, and Pip doesn't seem to deal as well as easy_install with the case of parallel installation of user and system installed dependencies; it assumes you are using virtualenv for that. Update: as of the most recent release,  pip deals just fine with parallel user/system installation; so, if you've got pip installed, "pip install zope.interface==4.0.2" – possibly with a --user option if that's appropriate to your environment – will work just fine.  Thanks, Pip maintainers!)
This set of attributes describes many Linux and OS X developers who are likely to encounter this version skew issue, so off we go.

Since easy_install can't be coerced to do the right thing by command-line options, you'll need to give it a configuration file that it can read.  The easiest way to do this is to create a temporary directory, cd into it, and create a file called setup.cfg.  For Linux and BSD, setup.cfg looks like this:
For OS X, the file looks like this:
Once you've created that file, just  easy_install --upgrade zope.interface from that directory and you should be ready to start developing with Twisted again!  All the older versions of Twisted that I've tried still work with the newest Zope Interface so this shouldn't disturb your ability to test your code against older versions of Twisted as well, if you're managing it with something like Combinator or virtualenv.

No comments: