1

Monday 10th March 2008

Local Packages

From Fedora 9, python packages include an egg-info file that is installed directly under %{python_sitelib} or %{python_sitearch} for architecture-independent and architecture-specific packages respectively. This can present a problem when trying to maintain a single spec file that can be used to build a package for multiple target distribution releases. The approach taken in the official Fedora package for python-twisted-core is to use a distribution-based conditional in the %files list:

%files
...
%if 0%{?fedora} >= 9
  %{python_sitearch}/Twisted-%{version}-py2.5.egg-info
%endif

I'm not keen on this approach because it requires the presence of the %{fedora} macro to build successfully on Fedora 9 onwards (not a bad assumption really since it is defined from a file included in the fedora-release package, which everyone will have), but more importantly it will require a further edit to support different distributions such as Red Hat Enterprise Linux 6 when that appears. My preferred approach is to test directly for the actual significant differences between releases that affect a package, and handle things according to the results of this testing. This leads to a more portable source package. My approach to the egg-info issue in python-twisted-core is to check to see if an egg-info file has been generated, and include it in the %files list if present:

%install
...
# See if there's an egg-info file
if [ -f %{buildroot}%{python_sitearch}/Twisted-*.egg-info ]; then
        echo %{buildroot}%{python_sitearch}/Twisted-*.egg-info |
                sed -e 's|^%{buildroot}||'
fi > egg-file

%files -f egg-file