Skip to content

Instantly share code, notes, and snippets.

@jamesbjackson
Forked from fawkesley/Makefile
Created May 17, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesbjackson/5965a20c61e094d17cafd9989bb7dc27 to your computer and use it in GitHub Desktop.
Save jamesbjackson/5965a20c61e094d17cafd9989bb7dc27 to your computer and use it in GitHub Desktop.
Makefile for activating a virtualenv and installing requirements. Uses requirements-to-freeze.txt / requirements.txt pattern
# Put *unversioned* requirements in `requirements-to-freeze.txt` as described below.
# `requirements.txt` will be automatically generated from `pip freeze`
# https://www.kennethreitz.org/essays/a-better-pip-workflow
venv/bin/activate: requirements-to-freeze.txt
rm -rf venv/
test -f venv/bin/activate || virtualenv -p $(shell which python3) venv
. venv/bin/activate ;\
pip install -Ur requirements-to-freeze.txt ;\
pip freeze | sort > requirements.txt
touch venv/bin/activate # update so it's as new as requirements-to-freeze.txt
.PHONY: run
run: venv/bin/activate
. venv/bin/activate ; \
python3 mycode.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment