Created
August 26, 2013 16:25
-
-
Save ryansb/6343441 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
# | |
# Install NPM in the current virtualenv. | |
# | |
# Based on a post by Natim: | |
# http://stackoverflow.com/questions/8986709/how-to-install-lessc-and-nodejs-in-a-python-virtualenv | |
set -e | |
NODEJS="http://nodejs.org/dist/v0.11.6/node-v0.11.6-linux-x64.tar.gz" | |
# Check dependencies | |
for dep in gcc wget curl tar make; do | |
which $dep > /dev/null || (echo "ERROR: $dep not found"; exit 10) | |
done | |
# Must be run from virtual env | |
if [ "$VIRTUAL_ENV" = "" ]; then | |
echo "ERROR: you must activate the virtualenv first!" | |
exit 1 | |
fi | |
echo "1) Installing nodejs in current virtual env" | |
echo | |
cd "$VIRTUAL_ENV" | |
# Create temp dir | |
if [ ! -d "tmp" ]; then | |
mkdir tmp | |
fi | |
cd tmp || (echo "ERROR: entering tmp directory failed"; exit 4) | |
echo -n "- Entered temp dir: " | |
pwd | |
# Download | |
fname=`basename "$NODEJS"` | |
if [ -f "$fname" ]; then | |
echo "- $fname already exists, not downloading" | |
else | |
echo "- Downloading $NODEJS" | |
wget "$NODEJS" || (echo "ERROR: download failed"; exit 2) | |
fi | |
echo "- Extracting" | |
tar -xvzf "$fname" || (echo "ERROR: tar failed"; exit 3) | |
rm -rf $VIRTUAL_ENV/node || (echo "No existing node install") | |
mv `basename "$fname" .tar.gz` ../node | |
rm -f $VIRTUAL_ENV/bin/node $VIRTUAL_ENV/bin/npm || (echo "No existing node symlinks") | |
ln -s $VIRTUAL_ENV/node/bin/node $VIRTUAL_ENV/bin/node | |
ln -s $VIRTUAL_ENV/node/bin/npm $VIRTUAL_ENV/bin/npm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment