feat: Enhance Makefile with improved environment setup and cleanup commands
This commit is contained in:
85
Makefile
85
Makefile
@@ -11,15 +11,78 @@ PYTHON=$(VENV_DIR)/bin/python
|
||||
|
||||
help: ## Show this help
|
||||
@grep -E -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
clean: ## Clean up build artifacts and virtual environment
|
||||
@echo "Cleaning up build artifacts and virtual environment..."
|
||||
@rm -rf $(VENV_DIR)
|
||||
@rm -rf build/
|
||||
@rm -rf dist/
|
||||
@rm -rf htmlcov/
|
||||
@rm -rf .pytest_cache/
|
||||
@rm -rf .ruff_cache/
|
||||
@rm -rf src/__pycache__/
|
||||
@rm -rf tests/__pycache__/
|
||||
@rm -f .coverage
|
||||
@rm -f coverage.xml
|
||||
@echo "✅ Cleanup complete!"
|
||||
|
||||
reinstall: clean install ## Clean and reinstall the development environment
|
||||
|
||||
check-env: ## Check if the development environment is properly set up
|
||||
@echo "Checking development environment..."
|
||||
@bash -c 'if [ ! -d "$(VENV_DIR)" ]; then \
|
||||
echo "❌ Virtual environment not found at $(VENV_DIR)"; \
|
||||
echo " Run \"make install\" to set up the environment"; \
|
||||
exit 1; \
|
||||
fi'
|
||||
@bash -c 'if [ ! -f "$(PYTHON)" ]; then \
|
||||
echo "❌ Python executable not found at $(PYTHON)"; \
|
||||
echo " Run \"make install\" to set up the environment"; \
|
||||
exit 1; \
|
||||
fi'
|
||||
@echo "✅ Virtual environment: $(VENV_DIR)"
|
||||
@echo "✅ Python executable: $(PYTHON)"
|
||||
@$(PYTHON) --version
|
||||
@$(PYTHON) -c "import sys; print(f'✅ Python path: {sys.executable}')"
|
||||
@bash -c 'if cd /home/will/Code/thechart && $(PYTHON) -c "import sys; sys.path.insert(0, \"src\"); import main" 2>/dev/null; then \
|
||||
echo "✅ Main module imports successfully"; \
|
||||
else \
|
||||
echo "❌ Main module import failed"; \
|
||||
exit 1; \
|
||||
fi'
|
||||
@bash -c 'if $(PYTHON) -c "import pre_commit" 2>/dev/null; then \
|
||||
echo "✅ Pre-commit is installed"; \
|
||||
else \
|
||||
echo "⚠️ Pre-commit not found (run \"make install\" to fix)"; \
|
||||
fi'
|
||||
@echo "✅ Environment check completed successfully!"
|
||||
install: ## Set up the development environment
|
||||
@echo "Setting up the development environment..."
|
||||
# poetry env use 3.13
|
||||
# eval $(poetry env use 3.13) # bash/zsh/csh
|
||||
eval (poetry env activate)
|
||||
poetry install --no-root
|
||||
poetry run pre-commit install --install-hooks --overwrite
|
||||
poetry run pre-commit autoupdate
|
||||
poetry run pre-commit run --all-files
|
||||
@echo "Creating virtual environment..."
|
||||
@bash -c 'if [ -d "$(VENV_DIR)" ]; then \
|
||||
echo "Virtual environment already exists. Recreating..."; \
|
||||
rm -rf $(VENV_DIR); \
|
||||
fi'
|
||||
uv venv $(VENV_DIR) --python=python3.13
|
||||
@echo "Installing dependencies..."
|
||||
uv sync --dev --no-cache-dir
|
||||
@echo "Installing pre-commit hooks..."
|
||||
$(PYTHON) -m pre_commit install
|
||||
@echo "Verifying installation..."
|
||||
@$(PYTHON) --version
|
||||
@$(PYTHON) -c "import sys; print(f'Python executable: {sys.executable}')"
|
||||
@echo "Testing module imports..."
|
||||
@cd /home/will/Code/thechart && $(PYTHON) -c "import sys; sys.path.insert(0, 'src'); import main; print('✅ Main module imports successfully')"
|
||||
@echo "Development environment setup complete!"
|
||||
@echo ""
|
||||
@echo "🐟 For Fish shell users:"
|
||||
@echo " source $(VENV_DIR)/bin/activate.fish"
|
||||
@echo ""
|
||||
@echo "🐚 For Bash/Zsh shell users:"
|
||||
@echo " source $(VENV_ACTIVATE)"
|
||||
@echo ""
|
||||
@echo "To run the application: make run"
|
||||
@echo "To run tests: make test"
|
||||
build: ## Build the Docker image
|
||||
@echo "Building the Docker image..."
|
||||
docker buildx build --platform linux/amd64,linux/arm64 -t ${IMAGE} --push .
|
||||
@@ -32,6 +95,10 @@ deploy: ## Deploy the application as a standalone executable
|
||||
desktop-file-validate ${ROOT}/.local/share/applications/${TARGET}.desktop
|
||||
run: $(VENV_ACTIVATE) ## Run the application
|
||||
@echo "Running the application..."
|
||||
@bash -c 'if [ ! -f "$(VENV_ACTIVATE)" ]; then \
|
||||
echo "❌ Virtual environment not found. Run \"make install\" first."; \
|
||||
exit 1; \
|
||||
fi'
|
||||
$(PYTHON) src/main.py
|
||||
start: ## Start the application
|
||||
@echo "Starting the application..."
|
||||
@@ -85,7 +152,7 @@ attach: ## Open a shell in the container
|
||||
docker-compose exec -it ${TARGET} /bin/bash
|
||||
shell: ## Open a shell in the local environment
|
||||
@echo "Opening a shell in the local environment..."
|
||||
source ./.venv/bin/activate.${SHELL} && /bin/${SHELL}
|
||||
source .venv/bin/activate.${SHELL} && /bin/${SHELL}
|
||||
requirements: ## Export the requirements to a file
|
||||
@echo "Exporting requirements to requirements.txt..."
|
||||
poetry export --without-hashes -f requirements.txt -o requirements.txt
|
||||
@@ -95,4 +162,4 @@ commit-emergency: ## Emergency commit (bypasses pre-commit hooks) - USE SPARINGL
|
||||
@read -p "Enter commit message: " msg; \
|
||||
git add . && git commit --no-verify -m "$$msg"
|
||||
@echo "✅ Emergency commit completed. Please run tests manually when possible."
|
||||
.PHONY: install build attach deploy run start stop test lint format shell requirements commit-emergency test-dose-tracking test-scrollable-input test-edit-functionality test-edit-window test-dose-editing migrate-csv help
|
||||
.PHONY: install clean reinstall check-env build attach deploy run start stop test lint format shell requirements commit-emergency test-dose-tracking test-scrollable-input test-edit-functionality test-edit-window test-dose-editing migrate-csv help
|
||||
|
||||
Reference in New Issue
Block a user