Last active
June 17, 2022 05:49
-
-
Save MaiLinhGroup/5b311a77d0f053f63d3381b616b31376 to your computer and use it in GitHub Desktop.
Example Makefile for a Python project
This file contains 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
.PHONY: today list | |
objects = $(wildcard *.in) | |
outputs := $(objects:.in=.txt) | |
setup: | |
@pip install -r requirements.txt --no-cache-dir | |
@echo 'Installed all requirements to (virtual) environment' | |
install: add compile update check | |
@echo "Installed $(package_name) to (virtual) environment" | |
add: | |
@echo >> requirements.in && echo $(package_name) >> requirements.in | |
@sed -i "" '/^\s*$$/d' requirements.in | |
compile: $(outputs) | |
%.txt: %.in | |
@CUSTOM_COMPILE_COMMAND="make compile" \ | |
pip-compile --allow-unsafe --generate-hashes -v --output-file $@ $< | |
update: | |
@echo "Update (virtual) environment to match the content of requirements.txt" | |
@pip-sync requirements.txt | |
check: | |
@pip check | |
@which pip-compile > /dev/null | |
clean: check | |
- rm *.txt | |
refresh: clean compile update check | |
concom: | |
@git add . | |
@cz commit | |
today: | |
@date | |
list: | |
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \ | |
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \ | |
| sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | |
sanitise_env: | |
@echo "match content of .env.sample with .env one but sanitise it to remove secrets" | |
@sed -r 's/^([^#]+=)([[:digit:]][[:digit:]]*|\".*\")$$/\1/' .env > .env.sample | |
@echo >> .env.sample | |
run: | |
@uvicorn src.app:api --host 0.0.0.0 --port 8000 --reload --log-level info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment