Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Try to always use python 2.7 #43

Merged
merged 2 commits into from
Apr 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ NODE=$C9_DIR/node/bin/node
export TMP=$C9_DIR/tmp
export TMPDIR=$TMP

PYTHON=python

start() {
if [ $# -lt 1 ]; then
start base
Expand Down Expand Up @@ -173,9 +175,26 @@ check_deps() {
fi
fi

check_python

if [ "$ERR" ]; then exit 1; fi
}

check_python() {
if which python2.7 &> /dev/null; then
PYTHONVERSION="2.7"
PYTHON="python2.7"
else
PYTHONVERSION=`python --version 2>&1`
PYTHON=python
fi

if [[ $PYTHONVERSION != *2.7* ]]; then
echo "Python version 2.7 is required to install pty.js. Please install python 2.7 and try again. You can find more information on how to install Python in the docs: https://docs.c9.io/ssh_workspaces.html"
exit 100
fi
}

# NodeJS

downlaod_virtualenv() {
Expand All @@ -189,24 +208,24 @@ downlaod_virtualenv() {
ensure_local_gyp() {
# when gyp is installed globally npm install pty.js won't work
# to test this use `sudo apt-get install gyp`
if [ `python -c 'import gyp; print gyp.__file__' 2> /dev/null` ]; then
if [ `"$PYTHON" -c 'import gyp; print gyp.__file__' 2> /dev/null` ]; then
echo "You have a global gyp installed. Setting up VirtualEnv without global pakages"
rm -rf virtualenv
rm -rf python
if has virtualenv; then
virtualenv "$C9_DIR/python"
else
downlaod_virtualenv
python virtualenv/virtualenv.py "$C9_DIR/python"
"$PYTHON" virtualenv/virtualenv.py "$C9_DIR/python"
fi
if [[ -f "$C9_DIR/python/bin/python2" ]]; then
"$NPM" config -g set python "$C9_DIR/python/bin/python2"
export PYTHON="$C9_DIR/python/bin/python2"
PYTHON="$C9_DIR/python/bin/python2"
else
echo "Unable to setup virtualenv"
exit 1
fi
fi
"$NPM" config -g set python "$PYTHON"
}

node(){
Expand Down Expand Up @@ -289,7 +308,7 @@ check_tmux_version(){
return 1
fi

if [ $(python -c "ok = 1 if 1.7<=$tmux_version else 0; print ok") -eq 1 ]; then
if [ $("$PYTHON" -c "print 1.7<=$tmux_version") == "True" ]; then
return 0
else
return 1
Expand Down Expand Up @@ -364,18 +383,6 @@ nak(){

ptyjs(){
echo :Installing pty.js

if which python2.7 &> /dev/null; then
PYTHONVERSION="2.7"
else
PYTHONVERSION=`python --version 2>&1`
fi

if [[ $PYTHONVERSION != *2.7* ]]; then
echo "Python version 2.7 is required to install pty.js. Please install python 2.7 and try again. You can find more information on how to install Python in the docs: https://docs.c9.io/ssh_workspaces.html"
exit 100
fi

"$NPM" install node-gyp
"$NPM" install [email protected]

Expand Down