[Fedora-packaging] SPEC for multiple python versions
Garrett Holmstrom
gholms at fedoraproject.org
Tue Nov 6 06:52:03 UTC 2012
On 2012-11-05 7:36, Jakov Sosic wrote:
> 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?
If they all share the same source package, the standard in Fedora seems
to be building all of the binary packages in the same build. The python
packaging page on the wiki [1] has an example of this. So for EPEL you
could have your spec file choose which python versions to build with
based on the OS release, similar to how Fedora's packages can do so for
python 2 and 3.
Note that if you're on el5 you will also need to make %__os_install_post
use the correct version of python to compile the packages' .pyc files:
%global __os_install_post %__multiple_python_os_install_post
[1] http://fedoraproject.org/wiki/Packaging:Python#Building_more_than_once
More information about the packaging
mailing list