File size: 2,624 Bytes
eca6215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
SHELL := /bin/bash
# Makefile for Llama3.1:8B Project

# Variables
PYTHON = python
PIP = pip
VENV_DIR = ./env
VENV_PYTHON = $(VENV_DIR)/bin/python
VENV_PIP = $(VENV_DIR)/bin/pip
REQUIREMENTS = requirements.txt

# Default target
.DEFAULT_GOAL := help

# Help target
help:
	@echo "Makefile for Llama3.1:8B Project"
	@echo ""
	@echo "Targets:"
	@echo "  help            - Show this help message"
	@echo "  setup           - Create virtual environment and install dependencies"
	@echo "  run             - Run the main application"
	@echo "  test            - Run unit tests"
	@echo "  lint            - Run linters"
	@echo "  clean           - Remove temporary files and directories"
	@echo "  clean-venv      - Remove virtual environment"
	@echo "  purge           - Clean and reinstall everything"
	@echo "  install         - Install or update dependencies"

# Check for Python and pip
check-deps:
	@echo "Checking for Python and pip..."
	@if ! command -v $(PYTHON) >/dev/null 2>&1; then \
		echo "Python is not installed. Please install Python3."; \
		exit 1; \
	fi
	@echo "Python is installed."
	@if ! command -v $(PIP) >/dev/null 2>&1; then \
		echo "pip is not installed. Installing pip..."; \
		sudo apt update && sudo apt install -y python3-pip; \
	fi
	@echo "pip is installed."

# Create virtual environment and install dependencies
setup: check-deps
	@echo "Setting up virtual environment..."
	@if [ ! -d "$(VENV_DIR)" ]; then \
		$(PYTHON) -m venv $(VENV_DIR); \
		echo "Virtual environment created."; \
	fi
	@echo "Installing dependencies..."
	$(VENV_PIP) install --upgrade pip
	$(VENV_PIP) install -r $(REQUIREMENTS)
	@echo "Setup completed."

# Run the main application
run:
	@echo "Running the application..."
	$(VENV_PYTHON) main.py

# Run tests
test:
	@echo "Running tests..."
	$(VENV_PYTHON) -m unittest discover tests

# Run linters
lint:
	@echo "Running linters..."
	$(VENV_PYTHON) -m flake8 src/ tests/

# Clean temporary files and directories
clean:
	@echo "Cleaning temporary files and directories..."
	find . -type f -name '*.pyc' -delete
	find . -type d -name '__pycache__' -exec rm -r {} +
	@echo "Cleanup completed."

# Clean virtual environment
clean-venv:
	@echo "Removing virtual environment..."
	rm -rf $(VENV_DIR)
	@echo "Virtual environment removed."

# Purge: remove all and reinstall environment
purge: clean clean-venv setup

# Install or update dependencies
install:
	@echo "Installing or updating dependencies..."
	$(VENV_PIP) install -r $(REQUIREMENTS)
	@echo "Dependencies installed or updated."