Created
July 13, 2019 18:05
-
-
Save mv/a378f89689a051d25c9fa30cbd04f970 to your computer and use it in GitHub Desktop.
Makefile: Python
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
# vim:ft=make:ts=8:sts=8:sw=8:noet:tw=80:nowrap:list | |
### | |
### Reference Makefile for Python stuff | |
### | |
### Mv: ferreira.mv[ at ]gmail.com | |
### 2019-07 | |
### | |
# My vars: simple | |
_this := $(shell uname -sr) | |
_venv := venv | |
# My vars: recursive | |
_dt = $(warning 'Invoking shell')$(shell date +%Y-%m-%d.%H:%M:%S) | |
### | |
### targets/tasks | |
### | |
.DEFAULT_GOAL:= help | |
.PHONY: help show pip clean venv venv_help venv_clear act deact init | |
help: ## - Default goal: list of targets in Makefile | |
help: show | |
@grep -E '^[a-zA-Z][a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ | |
| awk 'BEGIN {FS = ":.*?## "}; {printf " make \033[01;33m%-10s\033[0m %s\n", $$1, $$2}' \ | |
| sort | |
@echo | |
show: ## - Show my vars | |
@echo | |
@echo " This: $(_this)" | |
@echo " Virtualenv: [$(_venv)]" | |
@echo | |
init: ## - Virtualenv install + pip install | |
init: venv pip | |
pip: ## - Install from requirements*.txt | |
. $(_venv)/bin/activate && \ | |
pip3 install -r requirements.txt && \ | |
pip3 install -r requirements-dev.txt | |
venv: ## - Create virtualenv | |
virtualenv $(_venv) | |
venv-clear: ## - Clear (and reinstall) virtualenv | |
@echo "Reinstalling..." | |
virtualenv $(_venv) --clear | |
pyact: ## - $ pyactivate | |
pyactivate | |
pydeact: ## - $ pydeactivate | |
pydeactivate | |
clean: ## - Cleanup: pycache stuff | |
find . -type d -name __py*cache__ -exec rm -rf {} \; 2>/dev/null | |
find . -type f | egrep -i '.pyc|.pyb' | xargs rm | |
rm -rf .pytest_cache | |
test: ## - Test: py.test -v | |
@if [ -f $(_config_default) ]; \ | |
then . $(_config_default) && pytest -v -s tests/ ; \ | |
else echo "Error: must define env vars in $(_config_default)" ; \ | |
fi | |
_test2: ## - Test2 is hidden | |
@echo Test2 | |
_test_3: ## - Test_3 | |
@echo Test_3 | |
_test-4: ## - Test-4 | |
@echo Test-4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment