Last active
September 13, 2022 08:17
-
-
Save ricardogarfe/281bd6b5e8a0c412a1590dc366b4f015 to your computer and use it in GitHub Desktop.
Makefile for python environments
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
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