Skip to content

Instantly share code, notes, and snippets.

@ricardogarfe
Last active September 13, 2022 08:17
Show Gist options
  • Save ricardogarfe/281bd6b5e8a0c412a1590dc366b4f015 to your computer and use it in GitHub Desktop.
Save ricardogarfe/281bd6b5e8a0c412a1590dc366b4f015 to your computer and use it in GitHub Desktop.
Makefile for python environments
ENVPATH ?= .venv
all: help
help: ## Show available targets message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
## Configure virtual environment and install dependencies
venv-configure: ## Configure virtual environment and install dependencies
@echo ">>> Configure virtual environment..."
python -m venv $(ENVPATH)
. $(ENVPATH)/bin/activate
@echo ">>> Activated virtual environment..."
venv-activate: ## Activate virtual-env
. $(ENVPATH)/bin/activate
@echo ">>> Activated virtual environment..."
install-dependencies: ## Install dependencies from requirements
. $(ENVPATH)/bin/activate
pip install -r requirements.txt
test-unit: ## Run unit tests
. $(ENVPATH)/bin/activate
pip install -r requirements_dev.txt
python -m pytest test/
install-linters: ## Install linter dependencies
. $(ENVPATH)/bin/activate
pip install -r requirements_lint.txt
black: ## Apply auto lint changes using black
black . --exclude .venv/
lint: ## Run linter analysis
black --check . --exclude .venv/
flake8 .
.PHONY: help venv-configure venv-activate install-dependencies test-unit install-linters lint black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment