Subscribe to
Posts
Comments
Since FC6 ships with Python 2.4, you’re a bit stuck if you want to play with the new features of Python 2.5. Here’s a quick and easy way to build and install a cleanly-packaged version of Python 2.5 for FC6. First, you must ensure that you have a sufficient development environment available. Fortunately, you can do this in one step. Note: this is the only command you’ll need to run with root privileges until the time comes for you to install the Python RPM that you’ve built.
$ sudo yum install autoconf bzip2-devel db4-devel \
  expat-devel findutils gcc-c++ gdbm-devel glibc-devel gmp-devel \
  libGL-devel libX11-devel libtermcap-devel ncurses-devel \
  openssl-devel pkgconfig readline-devel sqlite-devel tar \
  tix-devel tk-devel zlib-devel 
(That’s one long line of input.) This will trundle along for a few minutes, after which you’ll have all of the bits you need installed. Except for Python itself, that is. Simply grab this, in source RPM form, from your nearest friendly Rawhide repository.
lftp ftp://mirrors.kernel.org/fedora/core/development/source/SRPMS
mget python-2*.src.rpm 
Next, install the Python source RPM into a temporary build directory of your choice. In this example, I’ll use “/tmp/mypy”.
mkdir -p /tmp/mypy/{BUILD,RPMS,SOURCES,SPECS}
rpm --define '_topdir /tmp' -ivh python-2*.src.rpm 
Now you’ll need to go into the SOURCES directory and frob a single file:
cd /tmp/mypy/SOURCES
sed -ie 's/DBLIBVER=4.5/DBLIBVER=4.3/' python-2.5-config.patch 
This tells the bsddb module to link against Berkeley DB 4.3 (the default on FC6), rather than 4.5 (which will presumably ship with Fedora 7). The next step is to build the Python RPM.
cd /tmp/mypy/SPECS
rpmbuild --define '_topdir /tmp/mypy' --define '__python_ver 25' -bb python.spec
This takes just a few minutes on my laptop, so it shouldn’t take long for you, either. Once you’re done, the binary RPMs will be present somewhere under /tmp/mypy/RPMS. On a 32-bit x86 machine, they’ll be in the i386 subdirectory, and on an x86_64 machine, they’ll be in the x86_64 subdirectory. You’ll have to become root to install them:
sudo rpm -ivh /tmp/mypy/RPMS/*/*.rpm 
A nice aspect of this way of building is that the packages it builds should not conflict with the system’s default Python, so you ought not to have any peculiar explosions in one of the many system packages that expect a specific Python version. Your new “python” package will be named “python25″, for example, and the interpreter will be named “python25″, too.

18 Responses to “How to build safe, clean Python 2.5 RPMs for Fedora Core 6”

  1. on 11 Mar 2007 at 01:38Kazuyoshi Furutaka

    Thanks for a nice/useful page.
    The _topdir for installation of the .src.rpm should be /tmp/mypy.
    Yours,
    Kazuyoshi

  2. on 18 Apr 2007 at 16:35Joe

    Thanks for the useful instructions which were quite instructive as well as easy to reproduce.

    Kazuyoshi, glad you caught that typo as well.
    Regards

  3. on 29 May 2007 at 14:53Steve

    Please excuse my ignorance, but in trying to follow these directions with an off-line machine, it appears the libGL-devel package checked for in the first step is really known as mesa-libGL-devel? I am going to forge ahead assuming this to be the case since I found no simple libGL-devel package to work with.

  4. on 29 May 2007 at 15:16Bryan O'Sullivan

    Steve, yes - you’re right. I think yum figures out the right package name for you from the provides tags.

  5. on 30 May 2007 at 08:52Steve

    All worked extremely well, you just saved me many, many hours of effort. Many thanks!

  6. on 13 Jun 2007 at 19:31Alfred Fazio

    Within my configuration, I also had to set the environment variable QA_RPATHS when executing rpmbuild so that standard and empty paths would be ignored (needed by the check-rpaths command). Therefore, the full rpmbuild command became:

    QA_RPATHS=$[ 0x0001|0x0010 ] rpmbuild –define ‘_topdir /tmp/mypy’ –define ‘__python_ver 25′ -bb python.spec

    I’m not sure why I had to do this where others did not… perhaps because of existing modules I had installed?

    Thank you very much for the helpful article!

  7. on 15 Jun 2007 at 11:42eXpressColo

    These directions also work for CentOS 5 (since CentOS 5 /RHEL 5 are based off Fedora Core 6).

    Thanks for this awesome write up.

  8. on 21 Aug 2007 at 08:39Cleiton Freere

    I just buit for CentOS 5 and RHEL 5, it worked perfectly!

    Thanks Bryan, it save me a lot of time (which I don’t have)!

  9. on 23 Aug 2007 at 08:23Joe Slone

    It worked for me as well on CentOS 5. One thing (obvious in hindsight, but it threw me for a moment) that was omited, you need to have installed rpm-build. Thanks much.

  10. on 31 Aug 2007 at 07:17Dave Gavin

    Thanks for a great write-up. One problem I found:

    rpm –define ‘_topdir /tmp’ -ivh python-2*.src.rpm

    loaded the SOURCES and SPECS in /tmp, not under /tmp/mypy.
    It worked when I changed the _topdir like this:

    rpm –define ‘_topdir /tmp/mypy’ -ivh python-2*.src.rpm

  11. on 17 Jan 2008 at 14:52Gary

    Thanks very much - I know this is now an old article, but I had to make a couple of other changes since I had fc9 src rpms.

    I used a different regex in the modding the patch file:

    sed -i ’s/DBLIBVER=4.[4-9]/DBLIBVER=4.3/’ python-2.5-config.patch

    In the .spec file I needed to change the db4-devel prereq requirement to be >= 4.3.

  12. on 30 Jan 2008 at 22:28scott

    Looks like the source rpm moved to here on the mirror:

    lftp mirrors.kernel.org:/fedora/development/source/SRPMS
    mget python-2*.src.rpm

  13. on 30 Jan 2008 at 22:36scott

    ****Note to new users****

    Be careful pasting lines of code from the comments above. The code ” quotes are formatted funky by the site and don’t retain clean ‘ quote as in the original posted code snippets that are properly formated.

    Paste them, but before executing them go in and change the quotes back to quote marks.

    Scott

  14. on 04 Feb 2008 at 23:46Jamie Quint

    lftp ftp://mirrors.kernel.org/fedora/core/development/source/SRPMS

    you will have to also replace “development” with “6″ here

  15. on 04 Feb 2008 at 23:51Jamie Quint

    actually ignore the above comment :) however that repository was not working for me, development was not showing up. Found the applicable file here: http://ftp.cse.yzu.edu.tw/pub/Linux/Fedora/core/development/source/SRPMS/python-2.5-12.fc7.src.rpm

  16. on 18 Mar 2008 at 09:08Amy

    Anyone else run into this when trying to build on cent5.1?

    gcc -pthread -shared Modules/_bsddb.o -L/usr/lib -ldb-4.5 -o Modules/_bsddb.so
    /usr/bin/ld: cannot find -ldb-4.5
    collect2: ld returned 1 exit status
    make: *** [Modules/_bsddb.so] Error 1
    error: Bad exit status from /var/tmp/rpm-tmp.33492 (%build)

  17. on 02 Apr 2008 at 18:17KiwiFrog

    Anyone getting the following error when building the rpm?

    [root@xxxx SPECS]# rpmbuild –define ‘_topdir /tmp/mypy’ –define ‘__python_ver 25′ -bb python.spec
    error: Failed build dependencies:
    readline-devel is needed by python25-2.5-12.i386
    openssl-devel is needed by python25-2.5-12.i386
    gmp-devel is needed by python25-2.5-12.i386
    ncurses-devel is needed by python25-2.5-12.i386
    gdbm-devel is needed by python25-2.5-12.i386
    zlib-devel is needed by python25-2.5-12.i386
    expat-devel is needed by python25-2.5-12.i386
    libGL-devel is needed by python25-2.5-12.i386
    tk is needed by python25-2.5-12.i386
    tix is needed by python25-2.5-12.i386
    libX11-devel is needed by python25-2.5-12.i386
    pkgconfig is needed by python25-2.5-12.i386
    tcl-devel is needed by python25-2.5-12.i386
    tk-devel is needed by python25-2.5-12.i386
    tix-devel is needed by python25-2.5-12.i386
    bzip2-devel is needed by python25-2.5-12.i386
    sqlite-devel is needed by python25-2.5-12.i386
    autoconf is needed by python25-2.5-12.i386
    db4-devel >= 4.3 is needed by python25-2.5-12.i386
    tcl is needed by python25-2.5-12.i386

    Any help would be greatly appreciated.
    Thanks.

  18. on 02 Apr 2008 at 18:52KiwiFrog

    Please ignore the above question. It was my newbie moment ;-).

    BTW, Thanks to the author of this post and all the contributors in the comments.

Leave a Reply