File size: 3,379 Bytes
3b993c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77dc531
 
 
 
 
 
 
 
3b993c4
 
 
 
 
 
 
 
 
 
 
 
 
 
77dc531
 
 
 
 
 
3b993c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Makefile for modern Python 3.12 project management
# Tools: uv, isort, black, mypy, hatchling, pytest

SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c

# Ensure uv is installed
ENSURE_UV := which uv > /dev/null || pip install uv

# Python version (update as needed)
PYTHON_VERSION := 3.12

# Default target
all: install format lint build test

.PHONY: help
help: ## Display this help message
	@echo "Usage: make [target]"
	@echo ""
	@echo "Targets:"
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: init
init: ## Initialize the project environment
	@$(ENSURE_UV)
	@echo "Creating virtual environment..."
	@uv venv

.PHONY: install
install: ## Install project dependencies
	@$(ENSURE_UV)
	@echo "Installing dependencies..."
	@uv pip install -e .[dev]

.PHONY: format
format: ## Format code using isort and black
	@$(ENSURE_UV)
	@echo "Formatting code..."
	@uv pip install isort black
	@if [ -n "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
		echo "Formatting $(filter-out $@,$(MAKECMDGOALS))..."; \
		uvx isort $(filter-out $@,$(MAKECMDGOALS)); \
		uvx black $(filter-out $@,$(MAKECMDGOALS)); \
	else \
		uvx isort src tests; \
		uvx black src tests; \
	fi

.PHONY: lint
lint: ## Run linters and type-checkers (ruff and mypy)
	@$(ENSURE_UV)
	@echo "Linting and type-checking..."
	@uv pip install ruff mypy
	@uvx ruff format src tests
	@uvx ruff check --fix src tests
	@uv run mypy src

.PHONY: test
test: ## Run tests using pytest
	@$(ENSURE_UV)
	@echo "Running tests..."
	@uv pip install pytest pytest-asyncio
	@if [ -n "$(filter-out $@,$(MAKECMDGOALS))" ]; then \
		uv run pytest -v $(filter-out $@,$(MAKECMDGOALS)); \
	else \
		uv run pytest; \
	fi

.PHONY: build
build: ## Build the project using hatchling
	@$(ENSURE_UV)
	@echo "Building project..."
	@uv pip install hatchling
	@uvx hatchling build

.PHONY: clean
clean: ## Clean up build artifacts and cache
	@echo "Cleaning up..."
	@rm -rf build dist .eggs *.egg-info
	@find . -type d -name '__pycache__' -exec rm -rf {} +
	@find . -type f -name '*.pyc' -exec rm -f {} +
	@find . -type f -name '*.pyo' -exec rm -f {} +
	@find . -type f -name '*~' -exec rm -f {} +

.PHONY: all
all: install format lint build test ## Run all main tasks (install, format, lint, build, test)

# AWS SSO configuration
AWS_PROFILE_NAME := Geometric-PowerUserAccess
AWS_SSO_START_URL := https://geometric.awsapps.com/start
AWS_SSO_REGION := us-east-1
AWS_ACCOUNT_ID := 339713096219
AWS_ROLE_NAME := PowerUserAccess
AWS_REGION := us-east-1

.PHONY: configure-aws-sso
configure-aws-sso: ## Configure AWS SSO
	@echo "Configuring AWS SSO..."
	@mkdir -p ~/.aws
	@echo "# AWS SSO Configuration" > ~/.aws/config
	@echo "" >> ~/.aws/config
	@echo "[profile $(AWS_PROFILE_NAME)]" >> ~/.aws/config
	@echo "sso_session = geometric" >> ~/.aws/config
	@echo "sso_account_id = $(AWS_ACCOUNT_ID)" >> ~/.aws/config
	@echo "sso_role_name = $(AWS_ROLE_NAME)" >> ~/.aws/config
	@echo "region = $(AWS_REGION)" >> ~/.aws/config
	@echo "" >> ~/.aws/config
	@echo "[sso-session geometric]" >> ~/.aws/config
	@echo "sso_start_url = $(AWS_SSO_START_URL)" >> ~/.aws/config
	@echo "sso_region = $(AWS_SSO_REGION)" >> ~/.aws/config
	@echo "sso_registration_scopes = sso:account:access" >> ~/.aws/config
	@echo "AWS SSO configuration complete."
	@aws sso login --profile $(AWS_PROFILE_NAME)