-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from smorin/feature/Justfile
Justfile addition
- Loading branch information
Showing
4 changed files
with
432 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ uv.lock # remove if you want to pin versions. | |
.venv | ||
|
||
#secrets | ||
.env | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
# Set project-wide variables | ||
py_package_name := "py_launch_blueprint" | ||
command_name := "py-projects" | ||
args := " " | ||
|
||
|
||
# Text colors | ||
BLACK := '\033[30m' | ||
RED := '\033[31m' | ||
GREEN := '\033[32m' | ||
YELLOW := '\033[33m' | ||
BLUE := '\033[34m' | ||
MAGENTA := '\033[35m' | ||
CYAN := '\033[36m' | ||
WHITE := '\033[37m' | ||
GRAY := '\033[90m' | ||
|
||
# Background colors | ||
BG_BLACK := '\033[40m' | ||
BG_RED := '\033[41m' | ||
BG_GREEN := '\033[42m' | ||
BG_YELLOW := '\033[43m' | ||
BG_BLUE := '\033[44m' | ||
BG_MAGENTA := '\033[45m' | ||
BG_CYAN := '\033[46m' | ||
BG_WHITE := '\033[47m' | ||
|
||
# Text styles | ||
BOLD := '\033[1m' | ||
DIM := '\033[2m' | ||
ITALIC := '\033[3m' | ||
UNDERLINE := '\033[4m' | ||
|
||
# Reset all styles | ||
NC := '\033[0m' | ||
|
||
# Display a symbol | ||
CHECK := "$(GREEN)✓$(NC)" | ||
CROSS := "$(RED)✗$(NC)" | ||
DASH := "$(GRAY)-$(NC)" | ||
|
||
|
||
# List all available recipes | ||
@default: | ||
just --list --unsorted | ||
|
||
# Check if required tools are installed | ||
@check-deps: | ||
@#!/usr/bin/env sh | ||
if ! command -v uv >/dev/null 2>&1; then echo "uv is not installed"; exit 1; fi | ||
if ! command -v python3 >/dev/null 2>&1; then echo "python3 is not installed"; exit 1; fi | ||
if ! command -v just >/dev/null 2>&1; then echo "just is not installed"; exit 1; fi | ||
if ! command -v pre-commit >/dev/null 2>&1; then echo "{{YELLOW}}WARNING: pre-commit is not installed{{NC}}"; fi | ||
echo "All required tools are installed" | ||
|
||
alias c := check-deps | ||
|
||
# Install package in editable mode with dev dependencies | ||
@install-dev: check-deps | ||
uv pip install --editable ".[dev]" | ||
|
||
# Format code | ||
@format: | ||
echo "Running formatters..." | ||
echo " ruff format" | ||
uvx --with-editable . ruff format {{py_package_name}}/ | ||
echo " ruff isort" | ||
uvx --with-editable . ruff check --select I --fix {{py_package_name}}/ | ||
|
||
alias f := format | ||
|
||
# Run linter (code style and quality checks) | ||
@lint: | ||
echo "Running linter..." | ||
echo " ruff" | ||
uvx --with-editable . ruff check {{py_package_name}}/ | ||
|
||
alias l := lint | ||
|
||
# Run type checker | ||
@typecheck: | ||
echo "Running type checker..." | ||
echo " mypy" | ||
uvx --with-editable . mypy {{py_package_name}}/ | ||
|
||
alias tc := typecheck | ||
|
||
# Run tests | ||
@test *options: | ||
uvx --with-editable . pytest {{options}} | ||
|
||
alias t := test | ||
|
||
# Run all checks | ||
@check: test lint typecheck | ||
echo "All checks passed!" | ||
|
||
alias ca := check | ||
|
||
# Run package command. | ||
@run cmd=command_name *args=args: | ||
uvx --with-editable . {{cmd}} {{args}} | ||
|
||
# Build package | ||
@build: check | ||
uvx --with-editable . build | ||
|
||
alias b := build | ||
|
||
# Set up pre-commit hooks | ||
@pre-commit-setup: | ||
uvx --with-editable . pre-commit install | ||
|
||
# Run all pre-commit Hooks | ||
@pre-commit-run: | ||
uvx --with-editable . pre-commit run --all | ||
|
||
alias pc := pre-commit-run | ||
|
||
# Check installed package version | ||
@version cmd=command_name: | ||
{{cmd}} --version | ||
|
||
# Clean up temporary files and caches | ||
@clean: | ||
rm -rf .pytest_cache | ||
rm -rf .mypy_cache | ||
rm -rf .ruff_cache | ||
rm -rf .coverage | ||
rm -rf htmlcov | ||
rm -rf dist | ||
rm -rf build | ||
rm -rf *.egg-info | ||
|
||
# Alternative commands when virtual environment is activated: | ||
# These commands can be used after running 'source .venv/bin/activate' | ||
|
||
# Setup virtual environment | ||
@setup-venv: | ||
python3 -m venv .venv | ||
echo "Note: After setup, activate the virtual environment with:" | ||
echo " source .venv/bin/activate # On Unix/macOS" | ||
echo " .venv\Scripts\activate # On Windows" | ||
|
||
# Install in development mode | ||
@install-dev-pip: | ||
pip install --editable ".[dev]" | ||
|
||
# Format code (includes ruff format and import sorting) | ||
@format-pip: | ||
echo "Running linter..." | ||
echo " ruff" | ||
ruff format {{py_package_name}}/ | ||
|
||
# Run linter (code style and quality checks) | ||
@lint-pip: | ||
ruff check {{py_package_name}}/ | ||
ruff check --select I --fix {{py_package_name}}/ | ||
|
||
# Run type checker | ||
@typecheck-pip: | ||
echo "Running type checker..." | ||
echo " mypy" | ||
mypy {{py_package_name}}/ | ||
|
||
# Run tests | ||
@test-pip *options: | ||
pytest {{options}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
SHELL := /bin/zsh | ||
|
||
# Text colors | ||
BLACK := \033[30m | ||
RED := \033[31m | ||
GREEN := \033[32m | ||
YELLOW := \033[33m | ||
BLUE := \033[34m | ||
MAGENTA := \033[35m | ||
CYAN := \033[36m | ||
WHITE := \033[37m | ||
GRAY := \033[90m | ||
|
||
# Background colors | ||
BG_BLACK := \033[40m | ||
BG_RED := \033[41m | ||
BG_GREEN := \033[42m | ||
BG_YELLOW := \033[43m | ||
BG_BLUE := \033[44m | ||
BG_MAGENTA := \033[45m | ||
BG_CYAN := \033[46m | ||
BG_WHITE := \033[47m | ||
|
||
# Text styles | ||
BOLD := \033[1m | ||
DIM := \033[2m | ||
ITALIC := \033[3m | ||
UNDERLINE := \033[4m | ||
|
||
# Reset | ||
NC := \033[0m | ||
|
||
CHECK := $(GREEN)✓$(NC) | ||
CROSS := $(RED)✗$(NC) | ||
DASH := $(GRAY)-$(NC) | ||
|
||
.PHONY: all check install-uv install-just set-path help | ||
|
||
all: help | ||
|
||
## `make check` Example Output | ||
|
||
### Success case | ||
# Checking dependencies... | ||
# === System Requirements Status === | ||
# [✓] Just | ||
# [✓] uv | ||
# All dependencies are installed! | ||
|
||
### Failure case | ||
# Checking dependencies... | ||
# === System Requirements Status === | ||
# [✓] just | ||
# [✗] uv (make install-uv) | ||
|
||
# Found 1 missing deps: uv | ||
# make: *** [check] Error 1 | ||
|
||
check: ## Check system requirements | ||
@echo "Checking dependencies..." | ||
@echo "=== System Requirements Status ===" | ||
@ERROR_COUNT=0; \ | ||
CHECK_CMD_NAME="just"; \ | ||
CHECK_CMD_INSTALL="install-just"; \ | ||
if [ $(shell command -v just >/dev/null 2>&1 && echo "0" || echo "1" ) -eq 0 ] ; then \ | ||
printf "[$(CHECK)] $${CHECK_CMD_NAME}\n"; \ | ||
else \ | ||
printf "[$(CROSS)] $${CHECK_CMD_NAME} ($(GREEN)make $${CHECK_CMD_INSTALL}$(NC))\n"; \ | ||
ERROR_COUNT=$$((ERROR_COUNT + 1)); \ | ||
MISSING_DEPS="$${CHECK_CMD_NAME}$${MISSING_DEPS:+,} $${MISSING_DEPS}"; \ | ||
fi; \ | ||
CHECK_CMD_NAME="uv"; \ | ||
CHECK_CMD_INSTALL="install-uv"; \ | ||
if [ $(shell command -v uv >/dev/null 2>&1 && echo "0" || echo "1" ) -eq 0 ] ; then \ | ||
printf "[$(CHECK)] $${CHECK_CMD_NAME}\n"; \ | ||
else \ | ||
printf "[$(CROSS)] $${CHECK_CMD_NAME} ($(GREEN)make $${CHECK_CMD_INSTALL}$(NC))\n"; \ | ||
ERROR_COUNT=$$((ERROR_COUNT + 1)); \ | ||
MISSING_DEPS="$${CHECK_CMD_NAME}$${MISSING_DEPS:+,} $${MISSING_DEPS}"; \ | ||
fi; \ | ||
if [ "$${ERROR_COUNT}" = "0" ]; then \ | ||
echo -e "$(GREEN)All dependencies are installed!$(NC)"; \ | ||
else \ | ||
echo ""; \ | ||
echo -e "$(RED)Found $$ERROR_COUNT missing deps: $${MISSING_DEPS}$(NC)"; \ | ||
exit 1; \ | ||
fi | ||
|
||
install-just: ## Print install just command and where to find install options | ||
@echo "just installation command:" | ||
@echo -e "${CYAN}curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin${NC}" | ||
@echo "NOTE:change ~/bin to the desired installation directory" | ||
@echo "Find other install options here: https://github.com/casey/just" | ||
@echo "To setup just PATH, run: SET_PATH=$(HOME)/bin make set-path" | ||
|
||
install-uv: ## Print install uv command and where to find install options | ||
@echo "uv installation command:" | ||
@echo -e "${CYAN}curl -LsSf https://astral.sh/uv/install.sh | sh${NC}" | ||
@echo "Find other install options here: https://docs.astral.sh/uv/getting-started/installation/" | ||
@echo "To setup uv PATH, run: SET_PATH=$(HOME)/.local/binmake set-path" | ||
|
||
set-path: ## Add SET_PATH to PATH in .zshenv if not already present | ||
@if [ -z "$(SET_PATH)" ]; then \ | ||
echo -e "$(RED)Error: SET_PATH must be set$(NC)"; \ | ||
echo -e "Usage: $(BLUE)make test2 SET_PATH=/your/path$(NC)"; \ | ||
exit 1; \ | ||
fi; \ | ||
if ! awk -v path="$(SET_PATH)" ' \ | ||
BEGIN {found=0} \ | ||
/^export PATH=/ { \ | ||
if (index($$0, path) > 0) { \ | ||
found=1; \ | ||
exit; \ | ||
} \ | ||
} \ | ||
END {exit !found}' "$(HOME)/.zshenv"; then \ | ||
echo "export PATH=\"\$$PATH:$(SET_PATH)\"" >> "$(HOME)/.zshenv"; \ | ||
echo -e "$(GREEN)Added PATH entry:$(NC) \$$PATH:$(SET_PATH)"; \ | ||
echo -e "Run $(BLUE)source $(HOME)/.zshenv$(NC) to apply changes"; \ | ||
else \ | ||
echo -e "$(CHECK) PATH already contains $(SET_PATH)"; \ | ||
fi | ||
|
||
help: ## The help command - this command | ||
@echo "" | ||
@echo "Purpose of this Makefile:" | ||
@echo -e " To make it easy to check for and install" | ||
@echo -e " the main dependencies because almost everyone has $(GREEN)make$(NC)" | ||
@echo "" | ||
@echo "Usage: make [target]" | ||
@echo "" | ||
@echo "Targets:" | ||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(CYAN)%-30s$(NC) %s\n", $$1, $$2}' | ||
@echo "" | ||
|
Oops, something went wrong.