Makefile Targets for Setting up Virtualenvwrapper

I use Virtualenvwrapper to isolate individual python projects. I could never remember the commands to set up a new project, so I created a makefile to do the work.

Copy the code below, change "put-your-name-here" to whatever you want to call your virtual environment, set up a requirements.txt file with your pip dependencies and you are good to go. Type make setup and the makefile will do the rest.

SHELL:=/bin/bash
VIRTUAL_ENV_NAME:=put-your-name-here
VIRTUAL_ENV_INSTALL:=~/.virtualenvs/$(VIRTUAL_ENV_NAME)/bin/activate
PIP_INSTALL:=~/.virtualenvs/$(VIRTUAL_ENV_NAME)/bin/pip

$(VIRTUAL_ENV_INSTALL):
    ( \
    source $(VIRTUALENVWRAPPER_SCRIPT) ; \
    mkvirtualenv $(VIRTUAL_ENV_NAME) --python=/usr/bin/python3.5 ; \
    touch ~/.virtualenvs/$(VIRTUAL_ENV_NAME)/bin/activate ; \
    )


$(PIP_INSTALL): $(VIRTUAL_ENV_INSTALL) requirements.txt
    ( \
    source $(VIRTUALENVWRAPPER_SCRIPT) ; \
    workon $(VIRTUAL_ENV_NAME) ; \
    pip install -r requirements.txt ;\
    touch ~/.virtualenvs/$(VIRTUAL_ENV_NAME)/bin/pip ;\
    )

setup: $(PIP_INSTALL)