[Fedora-packaging] SPEC for multiple python versions

Jakov Sosic jsosic at srce.hr
Mon Nov 5 15:36:08 UTC 2012


Hi.

First of all I don't know if this is the right list to ask this question
- because I'm packaging primarily for CentOS/RHEL 5/6, and not Fedora...
 so if it's not please direct me to the right list.

And now to my main question. I want to write SPEC file for python
module, that should build on multiple versions of python and both CentOS
5 and 6.

I need two defines - pyver and pybasever. If I hardcode them in my spec
file -> I cannot override them from rpmbuild command line, so what's the
right approach for this problem?

I'm trying to write spec file for following combinations:

CentOS/RHEL 5 + native python (2.4)
CentOS/RHEL 5 + python26 (from EPEL)
CentOS/RHEL 6 + native python (2.6)
CentOS/RHEL 6 + python27 (my own RPM's)

and maybe some other combination too.

So far I've got this on top of my spec file:

%if ! 0%{?pybasever:1}
%define pybasever 2.6
%endif

%define __python /usr/bin/python%{pybasever}
%define pyver %(%{__python} -c "import sys ; print
sys.version[:3].replace('.','')")


If I build package with just:
  rpmbuild -ba my.spec'
then python 2.6 i used, and If I specify:
  rpmbuild -ba my.spec --define 'pybasever 2.x'
then python 2.x is used.


Is this by any means OK?


More information about the packaging mailing list