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

Commit

Permalink
Merge pull request #43 from c9/python
Browse files Browse the repository at this point in the history
Try to always use python 2.7
  • Loading branch information
Ruben Daniels committed Apr 8, 2015
2 parents 24165ad + 0a32b45 commit bb1fcc4
Showing 1 changed file with 24 additions and 17 deletions.
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

0 comments on commit bb1fcc4

Please sign in to comment.