Skip to content

Instantly share code, notes, and snippets.

@timhughes
Last active April 21, 2025 14:09
Show Gist options
  • Select an option

  • Save timhughes/79f29c8704a251a2b70e266ce091731d to your computer and use it in GitHub Desktop.

Select an option

Save timhughes/79f29c8704a251a2b70e266ce091731d to your computer and use it in GitHub Desktop.
Python Makefile
#
# vim:ft=make
# Makefile
#
#
# For bash autocomplete add to `~/.bashrc`:
#
# complete -W "\`if [ -f Makefile ]; then grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'; elif [ -f makefile ]; then grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' makefile | sed 's/[^a-zA-Z0-9_-]*$//'; fi \`" make
.DEFAULT_GOAL := help
.PHONY: test help
_GREEN=$(shell tput setaf 2)
_BLUE=$(shell tput setaf 4)
_RED=$(shell tput setaf 1)
_RESET=$(shell tput sgr0)
_BOLD=$(shell tput bold)
COMMIT := $(shell git rev-parse HEAD)
SHORTCOMMIT := $(shell git rev-parse HEAD|cut -c-7)
help: ## these help instructions
@sed -rn 's/^([a-zA-Z0-9_-]+):.* ## (.*)$$/"\1" "\2"/p' < $(MAKEFILE_LIST)|xargs printf "$(_GREEN)make %-20s$(_RESET) # %s\n"
hidden: # undocumented, single '#' allows for comments on internal usage only tasks
@true
install: ## Runs poetry install
poetry install
lint: ## Runs bandit and black in check mode
poetry run black . --check --target-version=py36
poetry run bandit -r src
format: ## Formats you code with Black
poetry run black . --target-version=py36
test: hidden ## run pytest with coverage
poetry run pytest --cov test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment