Created
December 9, 2015 15:53
-
-
Save AlexJF/c5f796dc7130350d243d to your computer and use it in GitHub Desktop.
Local Python 2.7+Fabric installation
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
#! /usr/bin/env sh | |
BUILD_DIR="local-python-build" | |
INSTALL_PREFIX="~/.local" | |
SHELL_RC="~/.bashrc" | |
PYTHON_SOURCE="https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz" | |
OPENSSL_SOURCE="https://www.openssl.org/source/openssl-1.0.0t.tar.gz" | |
PIP_PACKAGES="fabric" | |
##################################### | |
function abs_path { | |
(cd "$(dirname '$1')" &>/dev/null && printf "%s/%s" "$PWD" "${1##*/}") | |
} | |
INSTALL_PREFIX=$(abs_path $INSTALL_PREFIX) | |
SHELL_RC=$(abs_path $SHELL_RC) | |
#rm -rf $BUILD_DIR | |
mkdir -p $BUILD_DIR | |
cd $BUILD_DIR | |
# Install OpenSSL | |
rm -rf openssl | |
mkdir openssl | |
wget -O openssl.tgz $OPENSSL_SOURCE | |
tar zxf openssl.tgz -C openssl --strip-components=1 | |
cd openssl | |
./config --prefix=$INSTALL_PREFIX shared | |
make | |
make install | |
cd .. | |
# Install Python2 (for Fabric) | |
rm -rf python | |
mkdir python | |
wget -O python.tgz $PYTHON_SOURCE | |
tar zxf python.tgz -C python --strip-components=1 | |
cd python | |
echo -e "SSL=$INSTALL_PREFIX\n_ssl _ssl.c -DUSE_SSL -I\$(SSL)/include -I\$(SSL)/include/openssl -L\$(SSL)/lib -lssl -lcrypto" >> Modules/Setup.dist | |
./configure --prefix=$INSTALL_PREFIX | |
make | |
make install | |
# Add $INSTALL_PREFIX/bin to $PATH | |
echo "export PATH=$INSTALL_PREFIX/bin:\$PATH" >> $SHELL_RC | |
source $SHELL_RC | |
# Install pip | |
wget https://bootstrap.pypa.io/get-pip.py | |
python get-pip.py | |
pip install $PIP_PACKAGES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment