Last active
June 3, 2019 13:51
-
-
Save dropwhile/7744519 to your computer and use it in GitHub Desktop.
python-2.7.14 and python-3.7.0 -- for centos7 (rpm fpm recipes)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BUILD_VER=2.7.14 | |
| # strip symbols to slightly reduce runtime memory footprint | |
| STRIP="yes" | |
| # use altinstall to NOT symlink python and python2 to the python2.7 executable | |
| ALTINSTALL="yes" | |
| PY_BUILD_VER="${BUILD_VER%.*}" | |
| PY_SHORT="${PY_BUILD_VER//.}" | |
| 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 compilers, devtools | |
| yum groupinstall -y "development tools" | |
| # install build deps | |
| yum -y install \ | |
| bzip2-devel \ | |
| db4-devel \ | |
| expat-devel \ | |
| gdbm-devel \ | |
| ncurses-devel \ | |
| openssl-devel \ | |
| readline-devel \ | |
| sqlite-devel \ | |
| xz-devel \ | |
| zlib-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 LDFLAGS="-Wl,-rpath /usr/local/lib" | |
| ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-ipv6 LDFLAGS="-Wl,-rpath /usr/local/lib" | |
| # build | |
| make -j2 | |
| if [ "$ALTINSTALL" = "yes" ]; then | |
| make altinstall DESTDIR=/tmp/installdir | |
| else | |
| make install DESTDIR=/tmp/installdir | |
| fi | |
| if [ "$STRIP" = "yes" ]; then | |
| for f in /tmp/installdir/usr/local/lib/libpython*; do | |
| [ ! -L "$f" ] && strip "$f" | |
| done | |
| strip /tmp/installdir/usr/local/bin/python${PY_BUILD_VER} | |
| strip /tmp/installdir/usr/local/bin/python${PY_BUILD_VER}m | |
| fi | |
| echo '/sbin/ldconfig' > /tmp/installdir/run-ldconfig.sh | |
| fpm -s dir -t rpm -n python${PY_SHORT} -v ${BUILD_VER} -C /tmp/installdir \ | |
| --after-install /tmp/installdir/run-ldconfig.sh \ | |
| -d 'bzip2' \ | |
| -d 'db4' \ | |
| -d 'expat' \ | |
| -d 'gdbm' \ | |
| -d 'ncurses' \ | |
| -d 'openssl' \ | |
| -d 'readline' \ | |
| -d 'sqlite' \ | |
| -d 'xz' \ | |
| -d 'zlib' \ | |
| --directories=/usr/local/lib/python${PY_BUILD_VER}/ \ | |
| --directories=/usr/local/include/python${PY_BUILD_VER}/ \ | |
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BUILD_VER=3.6.3 | |
| # strip symbols to slightly reduce runtime memory footprint | |
| STRIP="yes" | |
| # use altinstall to NOT symlink python3 to the python3.x executable (note: does not symlink python->python3.x either way) | |
| ALTINSTALL="no" | |
| PY_BUILD_VER="${BUILD_VER%.*}" | |
| PY_SHORT="${PY_BUILD_VER//.}" | |
| 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 compilers, devtools | |
| yum groupinstall -y "development tools" | |
| # install build deps | |
| yum -y install \ | |
| bzip2-devel \ | |
| db4-devel \ | |
| expat-devel \ | |
| gdbm-devel \ | |
| ncurses-devel \ | |
| openssl-devel \ | |
| readline-devel \ | |
| sqlite-devel \ | |
| xz-devel \ | |
| zlib-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-optimizations --enable-ipv6 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
| ./configure --prefix=/usr/local --enable-optimizations --enable-ipv6 LDFLAGS="-Wl,-rpath /usr/local/lib" | |
| # build | |
| make -j2 | |
| if [ "$ALTINSTALL" = "yes" ]; then | |
| make altinstall DESTDIR=/tmp/installdir | |
| else | |
| make install DESTDIR=/tmp/installdir | |
| fi | |
| if [ "$STRIP" = "yes" ]; then | |
| for f in /tmp/installdir/usr/local/lib/libpython*; do | |
| [ ! -L "$f" ] && strip "$f" | |
| done | |
| strip /tmp/installdir/usr/local/bin/python${PY_BUILD_VER} | |
| strip /tmp/installdir/usr/local/bin/python${PY_BUILD_VER}m | |
| fi | |
| echo '/sbin/ldconfig' > /tmp/installdir/run-ldconfig.sh | |
| fpm -s dir -t rpm -n python${PY_SHORT} -v ${BUILD_VER} -C /tmp/installdir \ | |
| --after-install /tmp/installdir/run-ldconfig.sh \ | |
| --provides "python(abi) = ${PY_SHORT}" \ | |
| --provides "python${PY_SHORT} = ${BUILD_VER}" \ | |
| -d 'bzip2' \ | |
| -d 'db4' \ | |
| -d 'expat' \ | |
| -d 'gdbm' \ | |
| -d 'ncurses' \ | |
| -d 'openssl' \ | |
| -d 'readline' \ | |
| -d 'sqlite' \ | |
| -d 'xz' \ | |
| -d 'zlib' \ | |
| --directories=/usr/local/lib/python${PY_BUILD_VER}/ \ | |
| --directories=/usr/local/include/python${PY_BUILD_VER}m/ \ | |
| 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