Skip to content

Commit

Permalink
Fixed detection of pythonbrew installation. pythonbrew is now also in…
Browse files Browse the repository at this point in the history
…stalled as part of the python essentials.
  • Loading branch information
thedrow committed Apr 10, 2012
1 parent 273708e commit df587e0
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@ set -o pipefail

# Pythonbrew utilities

# Sets the PYTHONBREW_PATH to default if it does not exist
if [[ -z "$PYTHONBREW_PATH" ]]
then
readonly PYTHONBREW_PATH="$HOME/.pythonbrew/"
fi

readonly PYTHONBREW_ETC="${PYTHONBREW_PATH}etc/bashrc"
echo $PYTHONBREW_ETC
# Detects if pythonbrew is installed
if [[ -s $PYTHONBREW_PATH ]]
if [[ -s $PYTHONBREW_ROOT ]]
then
readonly IS_PYTHONBREW_INSTALLED=1
elif [[ -s $HOME/.pythonbrew/etc/bashrc ]]
then
readonly IS_PYTHONBREW_INSTALLED=1
readonly PYTHONBREW_ROOT='$HOME/.pythonbrew'
else
readonly IS_PYTHONBREW_INSTALLED=0
readonly PYTHONBREW_ROOT='$HOME/.pythonbrew'
fi

[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/*
readonly PYTHONBREW_ETC="${PYTHONBREW_ROOT}/etc"

[[ -s $PYTHONBREW_ETC ]] && source $PYTHONBREW_ETC/*

function deactivate_pythonbrew()
{
if [ $IS_PYTHONBREW_INSTALLED == 1 ]
then
echo "Pythonbrew installation found at $PYTHONBREW_PATH"
echo "Pythonbrew installation found at $PYTHONBREW_ROOT"

pythonbrew_version="$(pythonbrew --version 2>&1)"
echo "Pythonbrew $pythonbrew_version found."
Expand All @@ -42,6 +41,16 @@ function deactivate_pythonbrew()
fi
}

function install_pythonbrew()
{
if [ $IS_PYTHONBREW_INSTALLED == 0 ]
then
curl -kL http://xrl.us/pythonbrewinstall | bash
append_if_not_found "[[ -s $PYTHONBREW_ROOT/etc/bashrc ]] && source $PYTHONBREW_ROOT/etc/*"
append_if_not_found 'export PYTHONBREW_ROOT=$HOME/.pythonbrew/'
fi
}

# Bootstrap utilities

function get_filename_from_url()
Expand Down Expand Up @@ -172,6 +181,9 @@ append_if_not_found 'export PIP_RESPECT_VIRTUALENV=true'
append_if_not_found 'export PIP_REQUIRE_VIRTUALENV=true'
append_if_not_found 'export PIP_VIRTUALENV_BASE=$WORKON_HOME'
append_if_not_found 'source /usr/local/bin/virtualenvwrapper.sh'

install_pythonbrew

source ~/.bashrc
mkdir -p $WORKON_HOME

Expand Down

0 comments on commit df587e0

Please sign in to comment.