Python Distutils and RPMs Targeting /opt

I think I’ve mentioned before that I’ve been writing more Python code lately. Python is very powerful and the modules available for it make lots of things very easy, including networked application programming.

Today, though, I want to share a little tidbit about creating Linux RPMs to distribute Python scripts/modules that install to a root other than /usr. In particular, a customer had a request to install under /opt. I’ll use /opt/riverace for this example.

Like many Python tasks, there’s already an easy way to generate a RPM. The Python distutils are very cool and it’s very easy to take a distutils-using setup and use python to generate the RPM. It’s as easy as:

python bdist_rpm

There are lots of blogs, doc pages, etc. that explain how to create your The thing I couldn’t find, though, is how to get the RPM to install into /opt.

It turned out to be simple. Just add this to your

import sys
sys.prefix = /opt/riverace



One Response to “Python Distutils and RPMs Targeting /opt”

  1. Tweets that mention Python Distutils and RPMs Targeting /opt « Steve Huston's Networked Programming Blog -- Says:

    […] This post was mentioned on Twitter by Python UK, Steve Huston. Steve Huston said: Python Distutils and RPMs Targeting /opt […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: