File size: 7,449 Bytes
2652f92 e41e94d 1e7e7d2 e41e94d 15d8abf 02c06f3 868e547 e41e94d 6a48ef2 e41e94d 6a48ef2 e41e94d 868e547 e41e94d fb3c066 e41e94d 7c6780b e41e94d fb3c066 02c06f3 15d8abf 02c06f3 e41e94d 15d8abf e41e94d 03e9bd3 e41e94d 6a48ef2 e41e94d 6a48ef2 e41e94d f5c42d5 2c0bacb 9697c9b f5c42d5 82d1a9d e41e94d 8df1b32 e41e94d 8df1b32 e41e94d 71a3f07 e41e94d | 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | .PHONY: setup venv install setup-lint clean run test test-unit test-e2e test-staged create-sample-pdf help lint format pre-commit-install pre-commit-run download-voicevox-core install-voicevox-core-module install-system-deps install-python-packages install-python-packages-lint requirements
#--------------------------------------------------------------
# Variables and Configuration
#--------------------------------------------------------------
# Python related
PYTHON = python
VENV_DIR = venv
VENV_PYTHON = $(VENV_DIR)/bin/python
VENV_PIP = $(VENV_DIR)/bin/pip
VENV_PRECOMMIT = $(VENV_DIR)/bin/pre-commit
# VOICEVOX related
VOICEVOX_CORE_VERSION = 0.16.1
VOICEVOX_MODELS_VERSION = 0.16.0
VOICEVOX_SKIP_IF_EXISTS ?= true
VOICEVOX_ACCEPT_AGREEMENT ?= false
VOICEVOX_DIR = voicevox_core
VOICEVOX_CHECK_MODULE = $(VENV_PYTHON) -c "import voicevox_core" 2>/dev/null
# Source code related
SRC_DIRS = yomitalk tests app.py
CACHE_DIRS = __pycache__ app/__pycache__ app/components/__pycache__ app/utils/__pycache__ \
tests/__pycache__ tests/unit/__pycache__ tests/e2e/__pycache__ tests/data/__pycache__ \
.pytest_cache
DATA_DIRS = data/temp/* data/output/*
# Default target
.DEFAULT_GOAL := help
#--------------------------------------------------------------
# Help and Basic Setup
#--------------------------------------------------------------
# Help message
help:
@echo "Paper Podcast Generator Makefile"
@echo ""
@echo "Usage:"
@echo "【Setup】"
@echo " make setup - Setup virtual environment and install packages"
@echo " make venv - Setup virtual environment only"
@echo " make install - Install dependency packages only"
@echo " make setup-lint - Install linting packages only"
@echo "【Development】"
@echo " make run - Run the application"
@echo " make lint - Run static code analysis (ruff check, mypy)"
@echo " make format - Auto-format and fix code issues (ruff format, ruff check --fix)"
@echo " make pre-commit-install - Install pre-commit hooks"
@echo " make pre-commit-run - Run pre-commit hooks manually"
@echo "【Testing】"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-e2e - Run E2E tests only"
@echo " make test-staged - Run unit tests for staged files only"
@echo "【VOICEVOX】"
@echo " make download-voicevox-core - Download and setup VOICEVOX Core"
@echo " make install-voicevox-core-module - Install VOICEVOX Core Python module"
@echo " VOICEVOX_ACCEPT_AGREEMENT=true - Set to auto-accept VOICEVOX license agreement"
@echo "【Cleanup】"
@echo " make clean - Remove virtual environment and generated files"
@echo ""
install-system-deps:
@echo "Installing system dependencies..."
sudo apt-get update
$(MAKE) download-voicevox-core
@echo "System dependencies installation completed!"
venv:
@if [ ! -d "$(VENV_DIR)" ]; then \
echo "Setting up virtual environment..."; \
$(PYTHON) -m venv $(VENV_DIR); \
echo "Virtual environment created at $(VENV_DIR)"; \
else \
echo "Virtual environment already exists at $(VENV_DIR)"; \
fi
install-python-packages: venv
@echo "Installing python packages..."
$(VENV_PIP) install --upgrade pip
$(VENV_PIP) install -r requirements.txt
$(MAKE) install-voicevox-core-module
@echo "Python packages installed"
install-python-packages-lint: venv
@echo "Installing linting packages..."
$(VENV_PIP) install --upgrade pip
$(VENV_PIP) install -r requirements-lint.txt
@echo "Linting packages installed"
setup-lint: venv install-python-packages-lint
@echo "Setup lint completed!"
setup: install-system-deps venv install-python-packages-lint install-python-packages pre-commit-install
@echo "Setup completed!"
#--------------------------------------------------------------
# VOICEVOX Related
#--------------------------------------------------------------
# Download and setup VOICEVOX Core
download-voicevox-core: venv
@echo "Running VOICEVOX Core download script..."
@scripts/download_voicevox.sh \
--core-version $(VOICEVOX_CORE_VERSION) \
--models-version $(VOICEVOX_MODELS_VERSION) \
--dir $(VOICEVOX_DIR) \
$(if $(filter true, $(VOICEVOX_SKIP_IF_EXISTS)), --skip-if-exists) \
$(if $(filter true, $(VOICEVOX_ACCEPT_AGREEMENT)), --accept-agreement)
@if [ $$? -ne 0 ]; then \
echo "Error: Failed to download VOICEVOX Core. Check logs for details."; \
exit 1; \
fi
# Install VOICEVOX Core Python module
install-voicevox-core-module: venv
@echo "Installing VOICEVOX Core Python module..."
@OS_TYPE="manylinux_2_34_x86_64"; \
WHEEL_URL="https://github.com/VOICEVOX/voicevox_core/releases/download/$(VOICEVOX_CORE_VERSION)/voicevox_core-$(VOICEVOX_CORE_VERSION)-cp310-abi3-$$OS_TYPE.whl"; \
$(VENV_PIP) install $$WHEEL_URL || echo "Failed to install wheel for $$OS_TYPE. Check available wheels at https://github.com/VOICEVOX/voicevox_core/releases/tag/$(VOICEVOX_CORE_VERSION)"
@echo "VOICEVOX Core Python module installed!"
#--------------------------------------------------------------
# Development Tools
#--------------------------------------------------------------
# Run the application
run: venv
@echo "Running application..."
$(VENV_PYTHON) app.py
# Run static analysis (lint)
lint: setup-lint
@echo "Running static code analysis..."
$(VENV_DIR)/bin/ruff check $(SRC_DIRS)
$(VENV_DIR)/bin/mypy $(SRC_DIRS)
@echo "Static analysis completed"
# Format code
format: setup-lint
@echo "Running code formatting and issue fixes..."
$(VENV_DIR)/bin/ruff check --fix $(SRC_DIRS)
$(VENV_DIR)/bin/ruff format $(SRC_DIRS)
@echo "Formatting completed"
# Install pre-commit hooks
pre-commit-install: setup-lint
@echo "Installing pre-commit hooks..."
$(VENV_PRECOMMIT) install
@echo "Pre-commit hooks installed"
# Run pre-commit hooks
pre-commit-run: setup-lint
@echo "Running pre-commit hooks..."
$(VENV_PRECOMMIT) run --all-files
@echo "Pre-commit hooks execution completed"
# Run linting checks for CI (check only, no modifications)
lint-ci: setup-lint
@echo "Running linting checks for CI (check only)..."
@echo "Ruff version: $$($(VENV_DIR)/bin/ruff --version)"
@echo "Current directory: $$(pwd)"
@echo "Python version: $$($(VENV_DIR)/bin/python --version)"
$(VENV_DIR)/bin/ruff check --ignore I001 $(SRC_DIRS)
$(VENV_DIR)/bin/ruff format --check $(SRC_DIRS)
@echo "Linting checks completed"
#--------------------------------------------------------------
# Testing
#--------------------------------------------------------------
# Run all tests
test: venv
@echo "Running tests..."
$(VENV_PYTHON) -m pytest tests/ --durations=10
# Run unit tests only
test-unit: venv
@echo "Running unit tests..."
$(VENV_PYTHON) -m pytest tests/unit/ --durations=10
# Run E2E tests only
test-e2e: venv
@echo "Running E2E tests..."
E2E_TEST_MODE=true $(VENV_PYTHON) -m pytest tests/e2e/ --durations=10
# Run tests for staged files only
test-staged: venv
@echo "Running tests for staged files..."
$(VENV_DIR)/bin/python .pre-commit-hooks/run_staged_tests.py
#--------------------------------------------------------------
# Cleanup
#--------------------------------------------------------------
# Clean up generated files
clean:
@echo "Removing generated files..."
rm -rf $(VENV_DIR)
rm -rf $(DATA_DIRS)
rm -rf $(CACHE_DIRS)
@echo "Cleanup completed"
requirements:
pip-compile -v requirements.in > requirements.txt
|