Skip to content

Instantly share code, notes, and snippets.

@Fedalto
Last active December 27, 2015 05:09
Show Gist options
  • Save Fedalto/7271762 to your computer and use it in GitHub Desktop.
Save Fedalto/7271762 to your computer and use it in GitHub Desktop.
Install python virtualenv, creates a virtualenv and install requirements passed as arguments.

I work with differents python projects and I usually create a vagrant VM to work on them.

This script is an attempt to easy the process of starting a new environment.

On Vagrantfile, put this section:

  config.vm.provision "shell" do |sh|
    sh.path = "https://gist.github.com/Fedalto/7271762/raw/setup_virtualenv.sh"
  end
#!/bin/bash
apt-get -y update
apt-get -y install python-virtualenv git
su -l vagrant <<'EOF'
VENV_DIR=~/venv
if [ ! -d ${VENV_DIR} ]; then
mkdir ${VENV_DIR}
virtualenv ${VENV_DIR}
fi
if ! grep "source ${VENV_DIR}/bin/activate" ~/.bashrc; then
echo "source ${VENV_DIR}/bin/activate" >> ~/.bashrc
fi
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment