<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">g.raphaelli's weblog</title>
  <id>http://g.raphaelli.com/tags/rpm/feed.atom</id>
  <updated>2009-08-07T23:48:13Z</updated>
  <link href="http://g.raphaelli.com/" />
  <link href="http://g.raphaelli.com/tags/rpm/feed.atom" rel="self" />
  <generator uri="http://zine.pocoo.org/" version="0.1.2">Zine</generator>
  <entry xml:base="http://g.raphaelli.com/tags/rpm/feed.atom">
    <title type="text">Packaging Python Modules</title>
    <id>tag:g.raphaelli.com,2009-01-01/entry:2009/1/1/packaging-python-modules</id>
    <updated>2009-08-07T23:48:13Z</updated>
    <published>2009-01-01T06:05:00Z</published>
    <link href="http://g.raphaelli.com/2009/1/1/packaging-python-modules" />
    <author>
      <name>g</name>
    </author>
    <content type="html">&lt;p&gt;Tools like &lt;a href="http://peak.telecommunity.com/DevCenter/EasyInstall"&gt;EasyInstall&lt;/a&gt; and &lt;a href="http://pypi.python.org/pypi/pip/"&gt;PIP&lt;/a&gt; are excellent for frequently changing environments.  I use virtualenv extensively in my development environments where I can easy_install or pip -E install away.  These tools, however, are not appropriate for production environments.  In production, repeatability and minimal dependency on development tools are essential.  When rolling out hundreds of servers, installing MySQL-python bindings with easy_install would require setting up a build environment on each host.  The operating system's package manager is sufficient for managing the installation of these modules.&lt;/p&gt;

&lt;p&gt;What if you need different versions of the same package on a particular host?  Assuming there are two applications running on a host that require different versions of the same package: move one of the applications to a separate host or VM.  If one application needs two versions of a particular package: fix the application.  In an emergency, running an application out of a temporary virtualenv can do the job at the expense of operational headaches.&lt;/p&gt;

&lt;p&gt;I run Redhat based systems so RPMs are the way to go for me.  python setup.py bdist_rpm is handy but there are a number of things I don't like about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Packages are not python-versioned.  pyOpenSSL-0.8-1.i386.rpm does not indicate which python it is built against.  Also, what if you want that package for both python2.4 and python2.5?&lt;/li&gt;
&lt;li&gt;Similarly, I prefer that python library packages be clearly identified in the list of installed packages. A 'python-' prefix is effective.  rrdtool-1.2.27-5.i386.rpm is the application package, python25-rrdtool.i386.rpm are the python2.5 bindings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since those things are not easy to override in the stock bdist_rpm, I use a lightly modified distutils/command/bdist_rpm.py arbitrarily named bdist_rpm_ver.py.  Building production packages is usually as easy as:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;easy_install --build-directory ~/rpm/BUILD/ --editable &amp;lt;pkg&amp;gt;&lt;/li&gt;
&lt;li&gt;cd ~/rpm/BUILD/&amp;lt;pkg&amp;gt;&lt;/li&gt;
&lt;li&gt;pythonXX setup.py bdist_rpm_ver --fix-python --binary-only&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This certainly is not perfect yet - sometimes I have to break down and do a --spec-only and tweak things by hand.  Fortunately, this happens once and only takes a few minutes to fix and then I have a stable package ready for deployment.  Also, I handle dependencies separately from the rpms currently but they can be added in step 3 with --requires, --conflicts, etc.&lt;/p&gt;

&lt;p&gt;I'm interested in hearing more about:
&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;I’ve been meaning to write a post on why I think using system packaging for libraries is counter-productive, but that’ll wait for another time.
&lt;br&gt;&lt;br&gt;Ian Bicking - &lt;a href="http://blog.ianbicking.org/2008/12/14/a-few-corrections-to-on-packaging/"&gt;A Few Corrections To “On Packaging”&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;/p&gt;

&lt;p&gt;In my experience, system packaging is the way to go for simple, repeatable installations to a single host or 1000s of hosts.&lt;/p&gt;</content>
  </entry>
</feed>

