tactical vim

nerdy bits & pieces

compile python bytecode at RPM build time

leave a comment »

From the world of quick hacks – I needed to rebuild the Puppet RPM from the EPEL folks for a customer, they need it deployed at kickstart time with custom configs (hundreds of servers). Using the EPEL source RPM the “yumhelper.py” file wasn’t getting compiled into .pyc and .pyo objects on a standard RHEL 5 system (which I’ve seen before with MySQL-python RPMs).

The quick hack was to simply run Python’s compileall module on it:

%install
rm -rf %{buildroot}
ruby install.rb --destdir=%{buildroot} --quick --no-rdoc

# Precompile python modules to avoid selinux issues later
python -mcompileall %{buildroot}%{ruby_sitelibdir}/puppet/provider/package
python -O -mcompileall %{buildroot}%{ruby_sitelibdir}/puppet/provider/package

Is it ugly and dirty? Yes. Does it work? Yes. Problem solved, walk away and get other work done.

Written by troyengel

2011-06-30 at 10:01

Posted in Linux, Servers

Tagged with , , , , ,

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.