Spaces:
Running
Running
.PHONY: install venv run test clean lint format help | |
# Variables | |
PYTHON_VERSION := 3.12 | |
PYTHON := python$(PYTHON_VERSION) | |
PIP := pip3 | |
VENV_NAME := venv | |
VENV_BIN := $(VENV_NAME)/bin | |
VENV_PYTHON := $(VENV_BIN)/python | |
VENV_PIP := $(VENV_BIN)/pip | |
PORT := 8501 | |
# Default target | |
.DEFAULT_GOAL := help | |
help: ## Show this help message | |
@echo 'Usage:' | |
@echo ' make <target>' | |
@echo '' | |
@echo 'Targets:' | |
@awk -F ':|##' '/^[^\t].+?:.*?##/ { printf " %-20s %s\n", $$1, $$NF }' $(MAKEFILE_LIST) | |
check-python: ## Verify Python version | |
@which $(PYTHON) > /dev/null || (echo "Python $(PYTHON_VERSION) not found. Please install it first." && exit 1) | |
$(VENV_NAME): check-python ## Create virtual environment if it doesn't exist | |
$(PYTHON) -m venv $(VENV_NAME) | |
$(VENV_PIP) install --upgrade pip | |
install-dev: $(VENV_NAME) ## Install development dependencies | |
$(VENV_PIP) install -r requirements/dev.txt | |
install-prod: $(VENV_NAME) ## Install production dependencies | |
$(VENV_PIP) install -r requirements/prod.txt | |
run: ## Run Streamlit application | |
PYTHONPATH=. $(VENV_BIN)/streamlit run main.py --server.port $(PORT) | |
clean: ## Clean cache files and remove virtual environment | |
find . -type d -name "__pycache__" -exec rm -rf {} + | |
find . -type d -name ".pytest_cache" -exec rm -rf {} + | |
find . -type f -name "*.pyc" -delete | |
rm -rf $(VENV_NAME) | |
lint: ## Run linter | |
$(VENV_PIP) install pylint | |
$(VENV_BIN)/pylint src | |
format: ## Format code using black | |
$(VENV_PIP) install black | |
$(VENV_BIN)/black src | |
test: ## Run tests | |
$(VENV_BIN)/pytest tests | |
setup-dev: clean $(VENV_NAME) install-dev ## Clean existing setup and create fresh development installation | |
setup-prod: clean $(VENV_NAME) install-prod ## Clean existing setup and create fresh production installation |