Skip to content

Instantly share code, notes, and snippets.

@soasme
Forked from dropwhile/py27.txt
Created June 18, 2017 19:51
Show Gist options
  • Save soasme/bc248b592c18584361e693929bab745d to your computer and use it in GitHub Desktop.
Save soasme/bc248b592c18584361e693929bab745d to your computer and use it in GitHub Desktop.
python-2.7.12 centos (rpm fpm recipe)
BUILD_VER=2.7.13
mkdir download /tmp/installdir; cd download;
curl -LO http://python.org/ftp/python/${BUILD_VER}/Python-${BUILD_VER}.tgz
tar xf Python-${BUILD_VER}.tgz
cd Python-${BUILD_VER}
# install build deps
yum -y install openssl-devel readline-devel bzip2-devel sqlite-devel zlib-devel ncurses-devel db4-devel expat-devel gdbm-devel
# note: if you want multiple minor version of python on the system, eg system python is 2.7.5 and you want 2.7.13,
# then remove --enable-shared from the configure line below.
# this will remove the ability to load python as a shared library (include python in other apps), but also avoides python
# loading the wrong minor library version depending on your libary path (and avoids messing with the system python)
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-ipv6 --enable-shared
# build
make -j2
# change make install to make altinstall if you do not want to symlink python and python2 to the python2.7 executable
make install DESTDIR=/tmp/installdir
echo '/sbin/ldconfig' > /tmp/installdir/run-ldconfig.sh
fpm -s dir -t rpm -n python27 -v ${BUILD_VER} -C /tmp/installdir \
--after-install /tmp/installdir/run-ldconfig.sh \
-d 'openssl' \
-d 'bzip2' \
-d 'zlib' \
-d 'expat' \
-d 'db4' \
-d 'sqlite' \
-d 'ncurses' \
-d 'readline' \
-d 'gdbm' \
--directories=/usr/local/lib/python2.7/ \
--directories=/usr/local/include/python2.7/ \
usr/local
# note: after install, you may need to do the following, depending no use of --enable-shared in the configure step:
# echo '/usr/local/lib' > /etc/ld.so.conf.d/usr-local.conf
# ldconfig -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment