SHARE
TWEET

Install nodejs, npm and lessc into your Python virtualenv

a guest Jul 23rd, 2012 702 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #
  3. # This script will download NodeJS, NPM and lessc, and install them into you Python
  4. # virtualenv.
  5. #
  6. # Based on a post by Natim:
  7. # http://stackoverflow.com/questions/8986709/how-to-install-lessc-and-nodejs-in-a-python-virtualenv
  8.  
  9. NODEJS="http://nodejs.org/dist/v0.8.3/node-v0.8.3.tar.gz"
  10.  
  11. # Check dependencies
  12. for dep in gcc wget curl tar make; do
  13.         which $dep > /dev/null || (echo "ERROR: $dep not found"; exit 10)
  14. done
  15.  
  16. # Must be run from virtual env
  17. if [ "$VIRTUAL_ENV" = "" ]; then
  18.         echo "ERROR: you must activate the virtualenv first!"
  19.         exit 1
  20. fi
  21.  
  22. echo "1) Installing nodejs in current virtual env"
  23. echo
  24.  
  25. cd "$VIRTUAL_ENV"
  26.  
  27. # Create temp dir
  28. if [ ! -d "tmp" ]; then
  29.         mkdir tmp
  30. fi
  31. cd tmp || (echo "ERROR: entering tmp directory failed"; exit 4)
  32.  
  33. echo -n "- Entered temp dir: "
  34. pwd
  35.  
  36. # Download
  37. fname=`basename "$NODEJS"`
  38. if [ -f "$fname" ]; then
  39.         echo "- $fname already exists, not downloading"
  40. else
  41.         echo "- Downloading $NODEJS"
  42.         wget "$NODEJS" || (echo "ERROR: download failed"; exit 2)
  43. fi
  44.  
  45. echo "- Extracting"
  46. tar -xvzf "$fname" || (echo "ERROR: tar failed"; exit 3)
  47. cd `basename "$fname" .tar.gz` || (echo "ERROR: entering source directory failed"; exit 4)
  48.  
  49. echo "- Configure"
  50. ./configure --prefix="$VIRTUAL_ENV" || (echo "ERROR: configure failed"; exit 5)
  51.  
  52. echo "- Make"
  53. make || (echo "ERROR: build failed"; exit 6)
  54.  
  55. echo "- Install "
  56. make install || (echo "ERROR: install failed"; exit 7)
  57.  
  58.  
  59. echo
  60. echo "2) Installing npm"
  61. echo
  62. curl http://npmjs.org/install.sh | sh || (echo "ERROR: install failed"; exit 7)
  63.  
  64.  
  65. echo
  66. echo "3) Installing lessc with npm"
  67. echo
  68. npm install less -g || (echo "ERROR: lessc install failed"; exit 8)
  69.  
  70. echo "Congratulations! lessc is now installed in your virtualenv"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top