Skip to content

Instantly share code, notes, and snippets.

@enaeseth
Created January 9, 2014 23:50
Show Gist options
  • Save enaeseth/8344340 to your computer and use it in GitHub Desktop.
Save enaeseth/8344340 to your computer and use it in GitHub Desktop.
Build Python 3 on RHEL 5 or CentOS 5
#!/bin/bash
# Requires fpm (path configurable via $FPM) and a working
# build environment.
set -e
version=$1
vendor=$2
if [ -z "$version" ]; then
echo "usage: $0 version" >&2
exit 1
fi
if [ -n "$vendor" ]; then
iteration="1.$vendor.el5"
else
iteration="1.el5"
fi
url="http://www.python.org/ftp/python/$version/Python-$version.tgz"
tarball=$(basename "$url")
src=$(basename "$tarball" .tgz)
dest="/tmp/python-$version-rpmbuild"
if [ ! -d "/tmp/$src" ]; then
[ -f "/tmp/$tarball" ] || wget -O "/tmp/$tarball" $url
cd /tmp && tar -xzf "$tarball"
fi
if [ ! -f "$dest/usr/bin/python3" ]; then
cd "/tmp/$src" && \
./configure --prefix=/usr --enable-ipv6 && \
make install DESTDIR="$dest"
fi
[ -z "$FPM" ] && FPM=fpm
options="-s dir -t rpm -v $version --iteration $iteration -C $dest"
$FPM -n python33 $options --conflicts python31.x86_64 \
-x 'usr/bin/*config*' \
usr/bin \
usr/lib \
usr/share
$FPM -n python33-devel $options --conflicts python31-devel.x86_64 \
usr/bin/python3-config \
usr/bin/python3.3-config \
usr/bin/python3.3m-config \
usr/include
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment