Skip to content

๐Ÿ“ฆ UV & Python Makefile Example

UV = uv

HF_HOME = /sgoinfre/sarfreit/hf_cache
FUNCTIONS = data/input/functions_definition.json
INPUT = data/input/function_calling_tests.json
OUTPUT = data/output/function_calling_results.json

export HF_HOME

all: install run

# INSTALL ALL REQUIREMENTS
install:
    @if command -v uv >/dev/null 2>&1; then \
        echo "โœ… uv is already installed ($$(uv --version))"; \
    elif [ -f "$$HOME/.local/bin/uv" ]; then \
        echo "โœ… uv found in $$HOME/.local/bin"; \
    else \
        echo "๐Ÿ“ฆ uv not found. Installing..."; \
        curl -LsSf https://astral.sh/uv/install.sh | sh; \
    fi
    @echo "๐Ÿ“ฆ Syncing dependencies..."
    @PATH="$$HOME/.local/bin:$$PATH" uv sync
    @echo "โœ… Dependencies ready"

# RUN THE PROGRAM
run:
    @$(UV) run python -m src \
        --functions_definition $(FUNCTIONS) \
        --input $(INPUT) \
        --output $(OUTPUT)

run-verbose:
    @$(UV) run python -m src \
        --functions_definition $(FUNCTIONS) \
        --input $(INPUT) \
        --output $(OUTPUT) \
        --verbose

# DEBUG AND HELP
debug:
    @$(UV) run python -m pdb -m src \
        --functions_definition $(FUNCTIONS) \
        --input $(INPUT) \
        --output $(OUTPUT)

help:
    @echo ""
    @echo "โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—"
    @echo "โ•‘              Call Me Maybe โ€” Make Commands           โ•‘"
    @echo "โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"
    @echo ""
    @echo "  ๐Ÿ“ฆ make install       Install project dependencies"
    @echo "  โ–ถ๏ธ  make run           Run with default settings"
    @echo "  ๐Ÿ” make run-verbose   Run with detailed generation trace"
    @echo "  ๐Ÿž make debug         Run with Python's pdb debugger"
    @echo ""
    @echo "  โœ… make lint          Run flake8 and mypy checks"
    @echo "  ๐Ÿง  make lint-strict   Run stricter mypy checks"
    @echo ""
    @echo "  ๐Ÿงน make clean         Remove cache files"
    @echo "  ๐Ÿ’ฃ make fclean        Remove cache + Output files + virtual environment"
    @echo "  ๐Ÿ” make re            Full clean and reinstall"
    @echo ""
    @echo "  โ„น๏ธ  Program-specific options running with run python -m src ... (--model, --verbose, etc.):"
    @echo ""
    @$(UV) run python -m src --help

# CHECK FOR NORM ERRORS
lint:
    @echo "๐Ÿ” Running flake8 and mypy..."
    @$(UV) run flake8 .
    @$(UV) run mypy . \
        --warn-return-any \
        --warn-unused-ignores \
        --ignore-missing-imports \
        --disallow-untyped-defs \
        --check-untyped-defs
    @echo "โœ… Lint completed"

lint-strict:
    @echo "๐Ÿง  Running strict checks..."
    @$(UV) run flake8 .
    @$(UV) run mypy . --strict
    @echo "โœ… Strict lint completed"

# CLEANERS
# CLEANERS
clean:
    @echo "\n๐Ÿงน Cleaning cache files..."
    @find . -type d -name "__pycache__" -exec rm -rf {} +
    @find . -type f -name "*.pyc" -delete
    @echo "\n๐Ÿงน Cleaning generated output..."
    @rm -f data/output/*.json
    @echo "\nโœ… Partial clean complete\n"

fclean: clean
    @echo "\n๐Ÿ’ฃ Removing virtual environment..."
    @rm -rf .venv
    @echo "\nโœ… Full clean complete\n"

re: fclean install

.PHONY: all install run debug lint lint-strict clean fclean re