Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # This script will download NodeJS, NPM and lessc, and install them into your Python
- # virtualenv.
- #
- # Based on a post by Natim:
- # http://stackoverflow.com/questions/8986709/how-to-install-lessc-and-nodejs-in-a-python-virtualenv
- NODEJS="http://nodejs.org/dist/v0.10.20/node-v0.10.20.tar.gz"
- # Check dependencies
- for dep in gcc wget curl tar make; do
- which $dep > /dev/null || { echo "ERROR: $dep not found. Install $dep and run script again."; 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; }
- cd `basename "$fname" .tar.gz` || { echo "ERROR: entering source directory failed"; exit 4; }
- echo "- Configure"
- ./configure --prefix="$VIRTUAL_ENV" || { echo "ERROR: configure failed"; exit 5; }
- echo "- Make"
- make || { echo "ERROR: build failed"; exit 6; }
- echo "- Install "
- make install || { echo "ERROR: install failed"; exit 7; }
- echo
- echo "2) Installing npm"
- echo
- curl -L https://npmjs.org/install.sh | sh || { echo "ERROR: install failed"; exit 7; }
- echo
- echo "3) Installing lessc with npm"
- echo
- npm install less -g || { echo "ERROR: lessc install failed"; exit 8; }
- echo "Congratulations! lessc is now installed in your virtualenv"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement