Last active
April 11, 2020 17:58
-
-
Save fawkesley/869df266ef36231014f434686202eb9f 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
Why test for venv/bin/activate when you have already deleted venv?