Latest Version: 0.9.6.2
  Dashboard > Pylons Cookbook > Home > Installing Pylons With RPM
  Pylons Cookbook Log In | Sign Up   View a printable version of the current page.  
  Installing Pylons With RPM
Added by Mike Verdone, last edited by Mike Verdone on Sep 11, 2007
Labels: 
(None)

Why?

easy_install offers a simple and safe method of installing Pylons but there are certain cases where you may not want to use it:

  • your server may not have internet access or the ability to access the Python CheeseShop
  • you may want to control package versions using the rpm command-line tool
  • your IT department may have a policy of installing software only through RPM

If your distribution of choice does not come with prebuilt RPMs for Pylons you may have to roll your own. Fear not, creating RPM files for Pylons and its dependencies is a relatively simple and painless process thanks to the magic of setuptools. 

How

Download package sources

Download source tarballs for Pylons and all the packages you need to install with it. Source packages are available at the CheeseShop package index, and here: http://pylonshq.com/download/

It's tricky to determine the exact set of dependencies you will need, but there are a few ways. One method is to install Pylons with easy_install on a fresh Python install and watch the packages it installs. Another is to extract the Pylons tarball and look in the EGG-INFO/requires.txt file for a list of package dependencies. At minimum this set of packages seems to be required for a basic install of Pylons 0.9.6:

  • Pylons-0.9.6
  • Routes-1.7
  • WebHelpers-0.3.2
  • Beaker-0.7.5
  • Paste-1.4.1
  • PasteDeploy-1.3.1
  • PasteScript-1.3.6
  • decorator-2.2.0
  • FormEncode-0.7.1
  • Mako-0.1.8
  • nose-0.9.2
  • simplejson-1.7.1

Build RPMs with setup.py

 For each of the tarballs, repeat this procedure (or use the script below):

  1. Untar the package.
  2. cd into the package
  3. patch setup.cfg if necessary (see CentOS 5 note below)
  4. run python setup.py bdist_rpm
  5. copy the RPM file from the dist directory to wherever you want it
    Note that RPMs produced by this method will depend on the Python version used to build them, and will install into that Python's site-packages directory. This means that RPMs produced on Python 2.5 will not work with 2.4, and RPMs built by a Python executable in /usr/bin/ will fail if installed with a Python in /usr/local/bin.

CentOS 5 / RHEL 5 Note

Due to a bug in the RPM build scripts in Red Hat Enterprise Linux 5 / CentOS 5, the bdist_rpm target may fail complaining about unpackaged *.pyo files. If this happens, append the following to the setup.cfg file in the package's untarred directory:

[install]
optimize = 1

 Smart People Use Scripts!

The following script will build all tarballs in the src/ directory and produce source RPMs and binary RPMs in directories SRPMS/ and RPMS/ respectively.

#!/usr/bin/env python

import commands
import os
import re
import sys

_pkgName_re = re.compile(r'(.+)(\.tgz|\.tar\.gz)')

def run_or_die(cmd):
    status, output = commands.getstatusoutput(cmd)
    if status != 0:
        print >> sys.stderr, "Got a status of %s from command:" %(status)
        print >> sys.stderr, cmd
        print >> sys.stderr, "... in directory %s" %(os.getcwd())
        sys.exit(1)

def buildRPMs():
    os.system('mkdir -p RPMS')
    os.system('mkdir -p SRPMS')
    os.system('mkdir -p build')
    os.system('rm -rf RPMS/* SRPMS/* build/*')
    tgzs = [filename for filename in os.listdir('src')
            if filename.endswith('tar.gz') or filename.endswith('.tgz')]
    for tgz in tgzs:
        pkgName = _pkgName_re.match(tgz).groups()[0]
        os.system('rm -rf build/' + pkgName)
        os.system('tar -C build -xzf src/' + tgz)
        os.chdir('build/' + pkgName)

        # Bugfix/workaround for RPM screaming when .pyo files generated
        run_or_die('echo "\n[install]\noptimize = 1\n" | cat >> setup.cfg')

        print "Building", pkgName
        run_or_die(r'python setup.py bdist_rpm')
        os.chdir('../../')
        os.system('mv build/%s/dist/*.src.rpm SRPMS/' %(pkgName))
        os.system('mv build/%s/dist/*.rpm RPMS/' %(pkgName))

if __name__=='__main__':
    buildRPMs()
    print "Done."

Install the RPMs

RPMs can be installed with the standard RPM command:

rpm -Uv whatever.rpm

Note that RPMs produced by this process do not respect dependencies. If you install the RPM for Pylons it won't check dependencies for the other RPM packages we built. You must remember to install all the necessary RPMs.

Site running on a free Atlassian Confluence Open Source Project License granted to Pylons. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.3.3 Build:#645 Feb 13, 2007) - Bug/feature request - Contact Administrators
Top