Skip to content

Commit 5bf7238

Browse files
committed
Merge branch 'feature/fix-pywin32-windows-build' into 'develop'
Fix Windows build issues and improve dev setup See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!265
2 parents dcff572 + 6431ff4 commit 5bf7238

File tree

4 files changed

+718
-52
lines changed

4 files changed

+718
-52
lines changed

docs/setup-development-env-win.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Windows Development Environment Setup
2+
3+
This guide provides instructions for setting up a complete development environment for the GenAI IDP accelerator on Windows systems using the automated setup script.
4+
5+
## Prerequisites
6+
7+
Before running the setup script, ensure you have:
8+
9+
- **Windows 10 or Windows 11** with latest updates
10+
- **Administrator privileges** on your machine
11+
- **Internet connectivity** for downloading packages
12+
- **PowerShell** (included with Windows)
13+
- **At least 10GB free disk space** for all development tools
14+
15+
## Running the Setup Script
16+
17+
### Step 1: Run as Administrator
18+
19+
1. Right-click on **Command Prompt** or **PowerShell**
20+
2. Select **"Run as administrator"**
21+
3. Navigate to the project directory:
22+
```cmd
23+
cd path\to\genaiic-idp-accelerator
24+
```
25+
4. Execute the setup script:
26+
```cmd
27+
scripts\dev_setup.bat
28+
```
29+
30+
### Step 2: Follow Interactive Prompts
31+
32+
The script will guide you through:
33+
34+
1. **AWS Credentials Configuration**:
35+
```
36+
Enter AWS Access Key ID:
37+
Enter AWS Secret Access Key:
38+
Enter AWS Default Region (e.g., us-east-1):
39+
```
40+
41+
2. **GitLab Project Setup**:
42+
- SSH URL (uses default if not specified)
43+
- Local parent directory name (defaults to "idp")
44+
- Branch selection (defaults to "develop")
45+
- Project will be cloned to `C:\Projects\<parent-dir>\genaiic-idp-accelerator`
46+
47+
3. **Build Configuration**:
48+
- S3 bucket name for artifacts
49+
- S3 prefix (defaults to "idp")
50+
- AWS region (defaults to "us-east-1")
51+
- Build options: Standard, Verbose, or Skip build
52+
53+
## What Gets Installed
54+
55+
The script automatically installs and configures:
56+
57+
### Development Tools
58+
- **Python 3.12** - Required runtime for the project
59+
- **Node.js** - For React UI development
60+
- **Git** - Version control
61+
- **AWS CLI** - AWS service interaction
62+
- **AWS SAM CLI** - Serverless application deployment
63+
- **Docker Desktop** - Container support
64+
- **Chocolatey** - Windows package manager
65+
66+
### Python Dependencies
67+
- **boto3** - AWS SDK for Python
68+
- **numpy 2.3.2** - Numerical computing
69+
- **typer** - CLI framework
70+
- **rich** - Rich text and beautiful formatting
71+
- **editdistance** - String similarity calculations
72+
- **python-docx** - Word document processing
73+
74+
## Troubleshooting
75+
76+
### Common Issues
77+
78+
#### Administrator Privileges Error
79+
**Problem**: Script fails with "must be run as Administrator"
80+
**Solution**:
81+
- Close current command prompt
82+
- Right-click Command Prompt → "Run as administrator"
83+
- Navigate back to project directory and retry
84+
85+
#### Python Version Issues
86+
**Problem**: "Python version is too old. Need Python 3.12 or later"
87+
**Solution**: The script will automatically install Python 3.12
88+
89+
#### Chocolatey Installation Fails
90+
**Problem**: PowerShell execution policy restrictions
91+
**Solution**: The script handles this automatically, but if issues persist:
92+
```powershell
93+
Set-ExecutionPolicy Bypass -Scope Process -Force
94+
```
95+
96+
#### AWS CLI Configuration Test Fails
97+
**Problem**: "AWS configuration test failed"
98+
**Solution**:
99+
- Verify your AWS credentials are correct
100+
- Check internet connectivity
101+
- Ensure your AWS account has necessary permissions
102+
103+
#### Docker Installation Issues
104+
**Problem**: Docker Desktop installation fails or requires restart
105+
**Solution**:
106+
- Complete the script execution
107+
- Restart your computer when prompted
108+
- Docker Desktop may require manual startup after restart
109+
110+
#### Build Failures (pywin32 Error)
111+
**Problem**: `Error: PythonPipBuilder:ResolveDependencies - {pywin32==311(wheel)}`
112+
**Solution**: This is a known issue with Windows-specific dependencies:
113+
```cmd
114+
# Clean build cache and retry
115+
rmdir /s /q .aws-sam
116+
python publish.py <bucket> <prefix> <region>
117+
118+
# Or use container build (requires Docker)
119+
sam build --use-container
120+
```
121+
122+
#### SAM CLI Version Requirements
123+
**Problem**: Build fails due to SAM CLI version
124+
**Solution**: The script installs SAM CLI >= 1.129.0 automatically. If issues persist:
125+
```cmd
126+
# Check version
127+
sam --version
128+
129+
# Update if needed
130+
choco upgrade aws-sam-cli -y
131+
```
132+
133+
## Validation
134+
135+
After successful installation, the script automatically validates:
136+
137+
- ✓ Python 3.12+ installation
138+
- ✓ Node.js installation
139+
- ✓ AWS CLI installation and configuration
140+
- ✓ Git installation
141+
- ✓ Docker installation (may show warning if not running)
142+
- ✓ SAM CLI installation
143+
- ✓ Python package installations (boto3, numpy, typer, rich)
144+
145+
## Next Steps
146+
147+
After successful setup:
148+
149+
1. **Review the validation output** to ensure all components installed correctly
150+
2. **Restart your computer** if Docker Desktop was installed
151+
3. **Your development environment is ready** - the script has already built the project if you selected that option
152+
4. **Use the provided CloudFormation template URL** to deploy the stack to AWS
153+
154+
## Build Options Explained
155+
156+
The script offers three build options:
157+
158+
1. **Standard build (recommended)**: Builds the project with normal output
159+
2. **Verbose build**: Provides detailed output for debugging build issues
160+
3. **Skip build**: Only sets up the environment without building the project
161+
162+
## Support
163+
164+
If you encounter issues:
165+
166+
1. Check the script output for specific error messages
167+
2. Review the validation results at the end of the script
168+
3. Consult the project's main [Troubleshooting Guide](./troubleshooting.md)
169+
4. Contact the development team with detailed error logs
170+
171+
---
172+
173+
**Note**: The setup process may take 30-60 minutes depending on your internet connection. A system restart may be required after Docker Desktop installation.

lib/idp_common_pkg/tests/unit/test_publish.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,11 @@ def test_clean_and_build_success(self, mock_rmtree, mock_exists, mock_run):
951951
"sam",
952952
"build",
953953
"--template-file",
954-
"patterns/pattern-1/template.yaml",
954+
"template.yaml", # Now uses basename
955955
"--cached",
956956
"--parallel",
957957
],
958-
cwd="patterns/pattern-1",
958+
cwd=os.path.abspath("patterns/pattern-1"), # Now uses absolute path
959959
)
960960

961961
@patch("subprocess.run")
@@ -1048,13 +1048,17 @@ def test_run_minimal_success_flow(self):
10481048
patch.object(publisher, "setup_artifacts_bucket") as mock_setup_bucket,
10491049
patch.object(publisher, "clean_temp_files"),
10501050
patch.object(publisher, "clean_lib"),
1051+
patch.object(
1052+
publisher, "ensure_idp_common_library_ready"
1053+
) as mock_ensure_lib,
10511054
patch.object(publisher, "needs_rebuild", return_value=False),
10521055
patch.object(
10531056
publisher, "build_patterns_concurrently", return_value=True
10541057
) as mock_build_patterns,
10551058
patch.object(
10561059
publisher, "build_options_concurrently", return_value=True
10571060
) as mock_build_options,
1061+
patch.object(publisher, "validate_lambda_builds") as mock_validate_builds,
10581062
patch.object(publisher, "upload_config_library") as mock_upload_config,
10591063
patch.object(
10601064
publisher, "package_ui", return_value="test-ui.zip"
@@ -1075,8 +1079,10 @@ def test_run_minimal_success_flow(self):
10751079
mock_check_prereq.assert_called_once()
10761080
mock_ensure_sam.assert_called_once()
10771081
mock_setup_bucket.assert_called_once()
1082+
mock_ensure_lib.assert_called_once()
10781083
mock_build_patterns.assert_called_once()
10791084
mock_build_options.assert_called_once()
1085+
mock_validate_builds.assert_called_once()
10801086
mock_upload_config.assert_called_once()
10811087
mock_package_ui.assert_called_once()
10821088
mock_build_main.assert_called_once_with("test-ui.zip")
@@ -1127,6 +1133,7 @@ def test_run_pattern_build_failure(self):
11271133
patch.object(publisher, "setup_artifacts_bucket"),
11281134
patch.object(publisher, "clean_temp_files"),
11291135
patch.object(publisher, "clean_lib"),
1136+
patch.object(publisher, "ensure_idp_common_library_ready"),
11301137
patch.object(publisher, "needs_rebuild", return_value=False),
11311138
patch.object(publisher, "build_patterns_concurrently", return_value=False),
11321139
patch.object(publisher.console, "print") as mock_print,
@@ -1169,7 +1176,9 @@ def test_sam_build_linux(self, mock_run, mock_system):
11691176
"--cached",
11701177
"--parallel",
11711178
]
1172-
mock_run.assert_called_with(expected_cmd, cwd=".")
1179+
# The method now uses absolute paths for thread safety
1180+
expected_cwd = os.path.abspath(".")
1181+
mock_run.assert_called_with(expected_cmd, cwd=expected_cwd)
11731182

11741183
@patch("platform.system")
11751184
@patch("subprocess.run")
@@ -1193,7 +1202,9 @@ def test_sam_build_windows(self, mock_run, mock_system):
11931202
"--cached",
11941203
"--parallel",
11951204
]
1196-
mock_run.assert_called_with(expected_cmd, cwd=".")
1205+
# The method now uses absolute paths for thread safety
1206+
expected_cwd = os.path.abspath(".")
1207+
mock_run.assert_called_with(expected_cmd, cwd=expected_cwd)
11971208

11981209
@patch("platform.system")
11991210
@patch("subprocess.run")
@@ -1216,7 +1227,9 @@ def test_sam_build_macos(self, mock_run, mock_system):
12161227
"--cached",
12171228
"--parallel",
12181229
]
1219-
mock_run.assert_called_with(expected_cmd, cwd=".")
1230+
# The method now uses absolute paths for thread safety
1231+
expected_cwd = os.path.abspath(".")
1232+
mock_run.assert_called_with(expected_cmd, cwd=expected_cwd)
12201233

12211234
@patch("platform.system")
12221235
def test_path_handling_windows(self, mock_system):

0 commit comments

Comments
 (0)