Created
February 8, 2014 11:22
-
-
Save abhishekkr/8882277 to your computer and use it in GitHub Desktop.
get-python-pip-venv.sh
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 bash | |
export LANGUAGE="en_US.UTF-8" | |
export LC_ALL="en_US.UTF-8" | |
export LC_CTYPE="UTF-8" | |
export LANG="en_US.UTF-8" | |
##### Var | |
PIP='pip' | |
##### Functions | |
shout(){ | |
echo "***************************************************" | |
echo $1 | |
echo "***************************************************" | |
} | |
major_version(){ | |
export OS_VERSION=`cat $RELEASE_FILE | sed 's/[^0-9.]*//g'` | |
export OS_VERSION_MAJOR=`echo $OS_VERSION | awk -F'.' '{print $1}'` | |
} | |
# install EPEL repo for CentOS systems | |
get_epel_repo(){ | |
shout "enabling EPEL repo" | |
major_version | |
EPEL_URI='http://epel.mirror.net.in/epel' | |
if [ $OS_VERSION_MAJOR -eq 6 ]; then | |
EPEL_URI=$EPEL_URI"/6/i386/epel-release-6-8.noarch.rpm" | |
elif [ $OS_VERSION_MAJOR -eq 5 ]; then | |
EPEL_URI=$EPEL_URI"/5/i386/epel-release-5-4.noarch.rpm" | |
else | |
shout "This version isn't supported." | |
exit_now 1 | |
fi | |
EPEL_RPM='/tmp/epel-6.8.rpm' | |
curl -L -o $EPEL_RPM $EPEL_URI | |
rpm -ivh $EPEL_RPM && yum repolist | |
} | |
# for distros: RedHat, CentOS, Fedora | |
install_pre_requisite_redhat(){ | |
export RELEASE_FILE='/etc/redhat-release' | |
get_epel_repo | |
yum -y install python-pip | |
export PIP='python-pip' | |
} | |
# for distros: Debian, Ubuntu | |
install_pre_requisite_debian(){ | |
export RELEASE_FILE='/etc/debian_version' | |
apt-get -y install python-pip | |
} | |
# for distros: Gentoo | |
install_pre_requisite_gentoo(){ | |
export RELEASE_FILE='/etc/gentoo-release' | |
emerge dev-python/pip | |
} | |
# for distros: ArchLinux | |
install_pre_requisite_archlinux(){ | |
export RELEASE_FILE='/etc/arch-release' | |
pacman -Sc --noconfirm | |
pacman -Sy --noconfirm python-pip | |
} | |
install_pre_requisite(){ | |
if [ -f /etc/redhat-release ]; then | |
install_pre_requisite_redhat | |
elif [ -f /etc/debian_version ]; then | |
install_pre_requisite_debian | |
elif [ -f /etc/gentoo-release ]; then | |
install_pre_requisite_gentoo | |
elif [ -f /etc/arch-release ]; then | |
install_pre_requisite_archlinux | |
elif [ `which curl > /dev/null 2>&1 ; echo $?` -ne 0 ]; then | |
curl -LkO https://raw.github.com/pypa/pip/master/contrib/get-pip.py | |
python get-pip.py | |
elif [ `which easy_install > /dev/null 2>&1 ; echo $?` -ne 0 ]; then | |
easy_install pip | |
else | |
echo 'Un-Managed Distro.' | |
exit_now 1 | |
fi | |
} | |
##### PREPARATION | |
install_pre_requisite | |
`$PIP install virtualenv` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment