|
| 1 | +# Development Environment Setup Guide on MacOS |
| 2 | +# Introduction |
| 3 | +This guide configures a comprehensive local development environment on macOS systems for the GenAI IDP accelerator. |
| 4 | + |
| 5 | +Purpose: Delivers an automated, scripted installation of all required development tools optimized for Apple hardware, ensuring rapid setup with minimal manual configuration. This approach leverages native macOS performance while maintaining consistency with project requirements. |
| 6 | + |
| 7 | +When to use this guide: |
| 8 | +• You're setting up development on a Mac for the first time |
| 9 | +• You're experiencing configuration issues with your current macOS setup |
| 10 | +• You prefer automated installation over manual tool configuration |
| 11 | +• You want to ensure exact tool versions match project specifications |
| 12 | + |
| 13 | +# What you'll achieve: |
| 14 | +A fully functional local development environment with Python 3.13, AWS CLI, Docker Desktop, VS Code with AI extensions, and integrated development tools - all configured through a single automated setup script. This document provides a step-by-step guide to setting up a development environment on macOS. It covers installing essential tools such as VS Code, Python 3.13.x, AWS CLI, SAM CLI, Node.js, Docker Desktop, Miniconda, Cline for VS Code, and Amazon Q in Terminal. |
| 15 | + |
| 16 | +# Prerequisites |
| 17 | + |
| 18 | +- macOS 12+ (Monterey) recommended; Apple Silicon (M1/M2/M3) and Intel |
| 19 | + are both supported. |
| 20 | + |
| 21 | +- An admin account on the Mac (you may be prompted for your password). |
| 22 | + |
| 23 | +- Stable internet connection. |
| 24 | + |
| 25 | +### **Clone the Repository** |
| 26 | + |
| 27 | +To get the sample project locally, run: |
| 28 | +```bash |
| 29 | +git clone https://github.com/aws-solutions-library-samples/accelerated-intelligent-document-processing-on-aws.git |
| 30 | +``` |
| 31 | + |
| 32 | +Change your directory to access the mac_setup.sh file |
| 33 | + |
| 34 | +# Quickstart (One-Command Script) |
| 35 | + |
| 36 | +If you prefer to automate everything, download the script and run: |
| 37 | +```bash |
| 38 | +chmod +x mac_setup.sh |
| 39 | +./mac_setup.sh |
| 40 | +``` |
| 41 | + |
| 42 | + |
| 43 | +# Step-by-Step Instructions |
| 44 | + |
| 45 | +## 1) Install Xcode Command Line Tools (and Rosetta, if needed) |
| 46 | + |
| 47 | +Xcode Command Line Tools provide compilers and essential build tools. |
| 48 | +Rosetta is required for some Intel-only tools on Apple Silicon. |
| 49 | + |
| 50 | +```bash |
| 51 | +# Install Xcode Command Line Tools |
| 52 | +xcode-select --install 2>/dev/null || echo "Xcode CLT already installed or prompt will appear." |
| 53 | + |
| 54 | +# (Apple Silicon only) Install Rosetta if not installed |
| 55 | +if [[ "$(uname -m)" == "arm64" ]]; then |
| 56 | + if ! /usr/bin/pgrep oahd >/dev/null 2>&1; then |
| 57 | + softwareupdate --install-rosetta --agree-to-license || true |
| 58 | + fi |
| 59 | +fi |
| 60 | +``` |
| 61 | + |
| 62 | + |
| 63 | +## 2) Install Homebrew |
| 64 | + |
| 65 | +Homebrew is the package manager we will use to install most dependencies. |
| 66 | + |
| 67 | +```bash |
| 68 | +# Install Homebrew (skips if already installed) |
| 69 | +if ! command -v brew >/dev/null 2>&1; then |
| 70 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 71 | +fi |
| 72 | + |
| 73 | +# Add brew to PATH for current shell session |
| 74 | +eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv)" |
| 75 | +``` |
| 76 | + |
| 77 | + |
| 78 | +## 3) Install Visual Studio Code |
| 79 | + |
| 80 | +You can install VS Code via Homebrew (recommended) or manually from |
| 81 | +Microsoft. |
| 82 | + |
| 83 | +```bash |
| 84 | +\# Install VS Code via Homebrew Cask\ |
| 85 | +brew install \--cask visual-studio-code |
| 86 | +``` |
| 87 | + |
| 88 | + |
| 89 | +## 4) Python (pyenv + optional Miniconda) |
| 90 | + |
| 91 | +We'll install pyenv to manage Python versions and optionally Miniconda for data workflows. This replaces the Linux-specific alternatives/yum/dnf steps in your original script. |
| 92 | + |
| 93 | +```bash |
| 94 | +# Install pyenv and dependencies |
| 95 | +brew update |
| 96 | +brew install pyenv |
| 97 | + |
| 98 | +# Initialize pyenv for zsh |
| 99 | +if ! grep -q 'pyenv init' ~/.zshrc 2>/dev/null; then |
| 100 | + echo ' |
| 101 | +# pyenv setup' >> ~/.zshrc |
| 102 | + echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc |
| 103 | + echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc |
| 104 | + echo 'eval "$(pyenv init -)"' >> ~/.zshrc |
| 105 | +fi |
| 106 | + |
| 107 | +# Use pyenv to install and set Python 3.12 (adjust if you prefer 3.11, etc.) |
| 108 | +eval "$(pyenv init -)" |
| 109 | +pyenv install -s 3.12.5 |
| 110 | +pyenv global 3.12.5 |
| 111 | + |
| 112 | +# Upgrade pip and install virtualenv |
| 113 | +python -m pip install --upgrade pip |
| 114 | +python -m pip install virtualenv |
| 115 | + |
| 116 | +# (Optional) Miniconda via Homebrew |
| 117 | +# brew install --cask miniconda |
| 118 | +``` |
| 119 | + |
| 120 | +## 5) AWS CLI v2 |
| 121 | + |
| 122 | +On macOS, the simplest way is via Homebrew. |
| 123 | + |
| 124 | +```bash |
| 125 | +brew install awscli |
| 126 | + |
| 127 | +# Test |
| 128 | +aws --version |
| 129 | +``` |
| 130 | + |
| 131 | + |
| 132 | +## 6) AWS SAM CLI |
| 133 | + |
| 134 | +Install SAM CLI from AWS Homebrew tap. |
| 135 | + |
| 136 | +```bash |
| 137 | +brew tap aws/tap |
| 138 | +brew install aws-sam-cli |
| 139 | + |
| 140 | +# Test |
| 141 | +sam --version |
| 142 | +``` |
| 143 | + |
| 144 | + |
| 145 | +## 7) Node.js via nvm (Node 18 LTS) |
| 146 | + |
| 147 | +Use nvm to manage Node versions. This mirrors your Linux section but uses zsh-friendly profile updates. |
| 148 | + |
| 149 | +```bash |
| 150 | +# Install nvm |
| 151 | +if [ ! -d "$HOME/.nvm" ]; then |
| 152 | + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash |
| 153 | +fi |
| 154 | + |
| 155 | +# Load nvm for current shell |
| 156 | +export NVM_DIR="$HOME/.nvm" |
| 157 | +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" |
| 158 | + |
| 159 | +# Install Node 18 LTS |
| 160 | +nvm install 18 |
| 161 | +nvm alias default 18 |
| 162 | + |
| 163 | +# Test |
| 164 | +node -v |
| 165 | +npm -v |
| 166 | +``` |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | +## 8) Docker Desktop |
| 171 | + |
| 172 | +Docker Desktop is the recommended way to run containers on macOS. It includes a lightweight VM and provides Docker Engine & Compose. |
| 173 | + |
| 174 | +```bash |
| 175 | +brew install --cask docker |
| 176 | + |
| 177 | +# After installation, launch Docker.app from /Applications or via Spotlight. |
| 178 | +# Give it a minute to start the backend; then test: |
| 179 | +# docker version |
| 180 | +``` |
| 181 | + |
| 182 | + |
| 183 | +## 9) Open Interpreter (optional) |
| 184 | + |
| 185 | +Install with pip. You can later configure any model/provider you want (kept generic here). |
| 186 | + |
| 187 | +```bash |
| 188 | +python -m pip install --upgrade open-interpreter |
| 189 | + |
| 190 | +# Run with: interpreter |
| 191 | +``` |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | +## 10) Shell Quality-of-Life Settings (zsh) |
| 196 | + |
| 197 | +On macOS, zsh is the default shell. We'll add a small include folder to keep the main ~/.zshrc tidy. |
| 198 | + |
| 199 | +```bash |
| 200 | +# Create include directory for .zshrc snippets |
| 201 | +mkdir -p ~/.zshrc.d |
| 202 | + |
| 203 | +# Add an include line to ~/.zshrc if not already present |
| 204 | +if ! grep -q 'for f in ~/.zshrc.d/*.zsh' ~/.zshrc 2>/dev/null; then |
| 205 | + cat <<'EOF' >> ~/.zshrc |
| 206 | +
|
| 207 | +# Load custom zsh snippets |
| 208 | +if [ -d "$HOME/.zshrc.d" ]; then |
| 209 | + for f in $HOME/.zshrc.d/*.zsh; do |
| 210 | + [ -r "$f" ] && source "$f" |
| 211 | + done |
| 212 | +fi |
| 213 | +EOF |
| 214 | +fi |
| 215 | + |
| 216 | +# Create a generic preferences snippet |
| 217 | +cat <<'EOF' > ~/.zshrc.d/00-preferences.zsh |
| 218 | +# History settings |
| 219 | +setopt APPEND_HISTORY |
| 220 | +HISTSIZE=100000 |
| 221 | +SAVEHIST=100000 |
| 222 | +
|
| 223 | +# Prompt (simple) |
| 224 | +PROMPT='%F{green}%n@%m%f:%F{blue}%~%f$(git_prompt_info) $ ' |
| 225 | +
|
| 226 | +# Aliases |
| 227 | +alias python=python3 |
| 228 | +alias pip=pip3 |
| 229 | +
|
| 230 | +# (Optional) nvm autoload |
| 231 | +export NVM_DIR="$HOME/.nvm" |
| 232 | +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" |
| 233 | +EOF |
| 234 | +``` |
| 235 | + |
| 236 | +## 11) Verify Your Setup |
| 237 | + |
| 238 | +- VS Code: Open it from Applications. Install extensions as needed (e.g., Python, Docker, AWS Toolkit). |
| 239 | +- Python: run `python --version` and `pip3 --version`. |
| 240 | +- Node: run `node -v` and `npm -v`. |
| 241 | +- AWS CLI: run `aws --version`. |
| 242 | +- SAM CLI: run `sam --version`. |
| 243 | +- Docker: launch Docker.app, then run `docker version` in Terminal. |
| 244 | + |
| 245 | +## **12) Configure AWS CLI** |
| 246 | +### Refer this link for AWS configure |
| 247 | +https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html |
| 248 | +# Troubleshooting Tips |
| 249 | + |
| 250 | +- If `brew` is not found, add it to PATH: |
| 251 | +```bash |
| 252 | +eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv)" |
| 253 | +``` |
| 254 | + |
| 255 | +- If `pyenv` shims don't work, ensure its init lines are in `~/.zshrc` and open a new Terminal. |
| 256 | + |
| 257 | +- On Apple Silicon, some images/tools may need Rosetta. Install it with `softwareupdate --install-rosetta --agree-to-license`. |
| 258 | + |
| 259 | +- Docker needs to be running before `docker` commands succeed. Launch Docker.app and wait for the whale icon to be steady. |
| 260 | + |
| 261 | +## Cline & Q Developer installation |
| 262 | +### Cline |
| 263 | +What it is: An AI coding assistant that runs as a VS Code extension, powered by various LLMs (Claude, GPT, etc.) |
| 264 | + |
| 265 | +Key capabilities: |
| 266 | +- Autonomous code editing across multiple files |
| 267 | +- Executes terminal commands and reads file outputs |
| 268 | +- Can browse the web for documentation/research |
| 269 | +- Maintains context across entire codebases |
| 270 | +- Handles complex, multi-step development tasks |
| 271 | + |
| 272 | +Why it's helpful: Acts like an AI pair programmer that can actually write, test, and debug code independently while you supervise. |
| 273 | +- You can install it from "Extensions" tab on VSCode. |
| 274 | + |
| 275 | +### Amazon Q Developer |
| 276 | +What it is: AWS's AI coding assistant integrated into IDEs, specifically designed for AWS development |
| 277 | + |
| 278 | +Key capabilities: |
| 279 | +- Code suggestions and completions optimized for AWS services |
| 280 | +- Security vulnerability scanning and fixes |
| 281 | +- AWS best practices recommendations |
| 282 | +- Infrastructure as Code (CloudFormation, CDK) assistance |
| 283 | +- Direct integration with AWS documentation and services |
| 284 | + |
| 285 | +Why it's helpful: Specialized for AWS development with deep knowledge of AWS services, perfect for this GenAI-IDP project since it's |
| 286 | +built entirely on AWS. |
| 287 | +- You can install it from https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html |
0 commit comments