Skip to content

Instantly share code, notes, and snippets.

@jbenner-radham
Last active July 17, 2017 21:51
Show Gist options
  • Save jbenner-radham/3f62f82a61ec0230ff07e790315a36ff to your computer and use it in GitHub Desktop.
Save jbenner-radham/3f62f82a61ec0230ff07e790315a36ff to your computer and use it in GitHub Desktop.
A Makefile to setup a Python 3 venv.
VENV_INSTALL_DIR = venv
# The first target listed acts as the default.
install:
@python3 -m venv ${VENV_INSTALL_DIR}
@. ${VENV_INSTALL_DIR}/bin/activate && pip3 install Flask > /dev/null && python3 -c \
"import subprocess; \
import re; \
flask_info = subprocess.run('pip3 show Flask', encoding='utf-8', shell=True, stdout=subprocess.PIPE).stdout; \
flask_version = re.compile('Version: ([0-9]+.[0-9]+)').search(flask_info)[1]; \
print('For Flask quickstart info visit: <http://flask.pocoo.org/docs/%s/quickstart/>.' % flask_version)"
@echo "Enter \`. ${VENV_INSTALL_DIR}/bin/activate\` to activate your virtual environment" \
"and when done enter \`deactivate\` to deactivate your virtual environment."
clean:
@rm -rf ${VENV_INSTALL_DIR} __pycache__
.PHONEY: install clean
VENV_INSTALL_DIR = venv
# The first target listed acts as the default.
# @see https://stackoverflow.com/questions/2924697/how-does-one-output-bold-text-in-bash#answer-2924755
install:
@python3 -m venv ${VENV_INSTALL_DIR}
@echo "Enter \`$(tput bold). ${VENV_INSTALL_DIR}/bin/activate$(tput sgr0)\` to activate your virtual environment." \
"And when done enter \`$(tput bold)deactivate$(tput sgr0)\` to deactivate your virtual environment."
clean:
@rm -rf ${VENV_INSTALL_DIR}
# @see http://blog.bottlepy.org/2012/07/16/virtualenv-and-makefiles.html
# venv: venv/bin/activate
# venv/bin/activate: requirements.txt
# test -d venv || virtualenv venv
# venv/bin/pip install -Ur requirements.txt
# touch venv/bin/activate
.PHONEY: install clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment