Skip to content

Instantly share code, notes, and snippets.

@marcuscaisey
Last active February 19, 2021 19:23
Show Gist options
  • Save marcuscaisey/973205f06c0c4559d33e0b4b420ed7ae to your computer and use it in GitHub Desktop.
Save marcuscaisey/973205f06c0c4559d33e0b4b420ed7ae to your computer and use it in GitHub Desktop.
Makefile for managing Python requirements.txt with pip-tools (based on https://jamescooke.info/a-successful-pip-tools-workflow-for-managing-python-package-requirements.html)
objects = $(wildcard *.in)
outputs = $(objects:.in=.txt)
sync-targets = $(objects:%.in=sync-%)
upgrade-targets = $(objects:%.in=upgrade-%)
.PHONY: all check clean $(sync-targets) $(upgrade-targets)
all: $(outputs)
%.txt: %.in
@pip-compile -v --output-file $@ $<
dev.txt: main.txt
check:
@which pip-compile > /dev/null
clean: check
-@rm *.txt
$(sync-targets): sync-%: %.txt
@pip-sync $<
$(upgrade-targets): upgrade-%: %.in
@pip-compile --upgrade $<
upgrade-dev: upgrade-main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment