-
-
Save pabloh007/e9f1f5371fe716382be0 to your computer and use it in GitHub Desktop.
Install Python 2.x and 3.x with enable-shared
This file contains 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
#!/bin/bash | |
### Python | |
# Setup python from source, for multiple versions of it. This only works with whole version numbers, not alpha releases. | |
# CentOS requires these packages: | |
# sudo yum -y install gcc automake autoconf | |
# yum groupinstall -y "Development tools" | |
# yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline | |
# yum install -y tar | |
# sudo yum -y install readline-devel ncurses-devel openssl-devel sqlite-devel tk-devel gdbm-devel bzip2-devel | |
# Ubuntu requires: | |
# sudo apt-get install libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev | |
# Some people will prefer this to be /usr/local or /var/local, or whatever. | |
PREFIX=/opt | |
cd /tmp | |
for VERSION in 2.7.9 3.5.1 | |
do | |
wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz | |
tar zxvf Python-$VERSION.tgz | |
cd Python-$VERSION | |
./configure --with-signal-module --with-threads --prefix=${PREFIX}/python-$VERSION --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" | |
make -j 8 && \ | |
sudo make altinstall && \ | |
if [ ${VERSION:0:1} = "2" ]; then | |
echo "/opt/python-$VERSION/lib" >> /etc/ld.so.conf | |
ldconfig | |
curl https://bootstrap.pypa.io/get-pip.py | sudo ${PREFIX}/python-$VERSION/bin/python${VERSION:0:1} | |
# (Optional) | |
sudo ${PREFIX}/python-$VERSION/bin/pip install supervisor | |
elif [ ${VERSION:0:1} = "3" ]; then | |
echo "/opt/python-$VERSION/lib" >> /etc/ld.so.conf | |
ldconfig | |
fi | |
sudo ${PREFIX}/python-$VERSION/bin/pip${VERSION:0:1} install virtualenv | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment