Last active
August 18, 2017 14:58
-
-
Save allanlewis/1211989ef4a397c9f385086f0abd5837 to your computer and use it in GitHub Desktop.
A Makefile for managing Python requirements in a sane way without extra Python tools.
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
python ?= python3 | |
pip := pip --disable-pip-version-check | |
export PATH := .env/bin:$(PATH) | |
####################### | |
# Python environments # | |
####################### | |
.env: | |
$(python) -m venv .env | |
prod-env: requirements/prod.in | |
test-env: requirements/test.in | prod-env | |
prod-env test-env: | .env | |
$(pip) install -r $< | |
.PHONY: prod-env test-env | |
####################### | |
# Python requirements # | |
####################### | |
requirements/prod.txt: requirements/prod.in | clean-env prod-env | |
requirements/test.txt: requirements/test.in | test-env | |
requirements/prod.txt requirements/test.txt: | |
$(pip) freeze -r $@ > $@ | |
######### | |
# Clean # | |
######### | |
clean-all: clean-env clean-python | |
clean-env: | |
rm -rf .env | |
clean-python: | |
find -name '__pycache__' -type d -prune | xargs rm -rf | |
find -name '*.pyc' -type f -delete | |
.PHONY: clean-all clean-env clean-python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment