Skip to content

Commit 7c53c07

Browse files
Feature/clean up local setup (#114)
1 parent b59223c commit 7c53c07

File tree

16 files changed

+115
-167
lines changed

16 files changed

+115
-167
lines changed

.devcontainer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ python -m ipykernel install --user --name=python-venv --display-name='Python (.v
200200
source /workspaces/Apim-Samples/.venv/bin/activate &&
201201
pip install -r requirements.txt &&
202202
pip install pytest pytest-cov coverage &&
203-
python setup/setup_python_path.py --generate-env &&
203+
python setup/local_setup.py --generate-env &&
204204
az config set core.login_experience_v2=off &&
205205
az extension add --name containerapp --only-show-errors &&
206206
az extension add --name front-door --only-show-errors
@@ -342,7 +342,7 @@ python -m ipykernel install --user --name=python-venv --display-name="Python (.v
342342
**Symptom**: Import errors or path issues
343343
**Solution**: Regenerate the `.env` file:
344344
```bash
345-
python setup/setup_python_path.py --generate-env
345+
python setup/local_setup.py --generate-env
346346
```
347347

348348
### Debug Commands

.devcontainer/python312/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"updateContentCommand": [
6464
"bash",
6565
"-c",
66-
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/setup_python_path.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
66+
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/local_setup.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
6767
],
6868
"postStartCommand": [
6969
"bash",

.devcontainer/python313/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"updateContentCommand": [
6464
"bash",
6565
"-c",
66-
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/setup_python_path.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
66+
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/local_setup.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
6767
],
6868
"postStartCommand": [
6969
"bash",

.devcontainer/python314/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"updateContentCommand": [
6464
"bash",
6565
"-c",
66-
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/setup_python_path.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
66+
"echo '📦 Installing/updating Python packages from requirements.txt...' && source /workspaces/Apim-Samples/.venv/bin/activate && pip install -r requirements.txt && pip install pytest pytest-cov coverage && echo '✅ Python packages installed/updated' && python setup/local_setup.py --generate-env && echo '✅ Environment configuration updated' && echo '⚙️ Configuring Azure CLI...' && az config set core.login_experience_v2=off 2>/dev/null || true && az extension add --name containerapp --only-show-errors 2>/dev/null || true && az extension add --name front-door --only-show-errors 2>/dev/null || true && echo '✅ Azure CLI configured for Codespaces'"
6767
],
6868
"postStartCommand": [
6969
"bash",

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232

3333
# Keep essential files for the build
3434
!requirements.txt
35-
!setup/setup_python_path.py
35+
!setup/local_setup.py
3636
!shared/python/**

.vscode/settings.json

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,19 @@
11
{
2-
"jupyter.defaultKernel": "apim-samples",
3-
"jupyter.kernels.changeKernelIdForNotebookEnabled": false,
4-
"jupyter.preferredKernelIdForNotebook": {
5-
"*.ipynb": "apim-samples"
6-
},
7-
"jupyter.kernels.trusted": [
8-
"./.venv/Scripts/python.exe"
9-
],
10-
"jupyter.kernels.excludePythonEnvironments": [
11-
"apim-samples"
12-
],
13-
"search.exclude": {
14-
"**/.venv": true,
15-
"**/.venv/**": true
16-
},
17-
"files.watcherExclude": {
18-
"**/.venv/**": true
19-
},
20-
"files.exclude": {
21-
"**/.venv": true
22-
},
232
"python.analysis.exclude": [
3+
"**/.*",
4+
"**/.venv",
5+
"**/venv",
6+
"**/env",
247
"**/node_modules",
258
"**/__pycache__",
26-
".git",
27-
"**/build",
28-
"env/**",
29-
"**/.venv/**"
9+
"env/**"
3010
],
3111
"files.trimTrailingWhitespace": true,
3212
"files.insertFinalNewline": true,
3313
"files.trimFinalNewlines": true,
3414
"files.eol": "\n",
3515
"editor.renderWhitespace": "trailing",
3616
"python.defaultInterpreterPath": "./.venv/Scripts/python.exe",
37-
"python.pythonPath": "./.venv/Scripts/python.exe",
3817
"python.envFile": "${workspaceFolder}/.env",
3918
"[python]": {
4019
"editor.codeActionsOnSave": {
@@ -43,8 +22,7 @@
4322
},
4423
"editor.formatOnSave": true
4524
},
46-
"notebook.defaultLanguage": "python",
47-
"notebook.kernelPickerType": "mru",
25+
4826
"terminal.integrated.defaultProfile.windows": "PowerShell",
4927
"plantuml.render": "Local",
5028
"plantuml.exportFormat": "svg",
@@ -53,7 +31,5 @@
5331
"plantuml.exportOutDir": "assets/diagrams/out",
5432
"python.terminal.activateEnvironment": true,
5533
"python.terminal.activateEnvInCurrentTerminal": true,
56-
"python.testing.pytestEnabled": true,
57-
"python.linting.enabled": true,
58-
"python.linting.pylintEnabled": true
59-
}
34+
"python.testing.pytestEnabled": true
35+
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "shell",
77
"command": "${config:python.pythonPath}",
88
"args": [
9-
"setup/setup_python_path.py",
9+
"setup/local_setup.py",
1010
"--generate-env"
1111
],
1212
"group": "build",

README.md

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,76 @@ This menu-driven interface provides quick access to:
9797
Example output from option 2 (Verify local setup):
9898
```
9999
🔍 APIM Samples Local Environment Verification
100+
==================================================
101+
102+
📋 Virtual Environment
103+
----------------------
100104
✅ Virtual environment is active
101-
✅ All required packages installed
102-
✅ Shared modules can be imported
103-
✅ .env file configured
104-
⚠️ Jupyter kernel not found
105-
✅ VS Code settings configured
105+
106+
📋 Required Packages
107+
--------------------
108+
✅ requests is installed
109+
✅ ipykernel is installed
110+
✅ jupyter is installed
111+
✅ python-dotenv is installed
112+
113+
📋 Shared Modules
114+
-----------------
115+
✅ All shared modules can be imported
116+
117+
📋 Environment File
118+
-------------------
119+
✅ .env file is configured correctly
120+
121+
📋 Azure CLI
122+
------------
123+
✅ Azure CLI is installed (azure-cli 2.81.0)
124+
125+
📋 Azure Bicep CLI
126+
------------------
127+
✅ Azure Bicep CLI is installed (az bicep version: Bicep CLI version 0.39.26 (1e90b06e40))
128+
129+
📋 Azure Providers
130+
------------------
131+
Registered providers:
132+
- Microsoft.ApiManagement
133+
- Microsoft.App
134+
- Microsoft.Authorization
135+
- Microsoft.CognitiveServices
136+
- Microsoft.ContainerRegistry
137+
- Microsoft.KeyVault
138+
- Microsoft.Maps
139+
- Microsoft.ManagedIdentity
140+
- Microsoft.Network
141+
- Microsoft.OperationalInsights
142+
- Microsoft.Resources
143+
- Microsoft.Storage
144+
✅ All required Azure providers are registered
145+
146+
📋 Jupyter Kernel
147+
-----------------
148+
✅ APIM Samples Jupyter kernel is registered
149+
150+
📋 VS Code Settings
151+
-------------------
152+
✅ VS Code settings are configured correctly
153+
154+
📋 Summary
155+
----------
156+
✅ Virtual Environment : PASS
157+
✅ Required Packages : PASS
158+
✅ Shared Modules : PASS
159+
✅ Environment File : PASS
160+
✅ Azure CLI : PASS
161+
✅ Azure Bicep CLI : PASS
162+
✅ Azure Providers : PASS
163+
✅ Jupyter Kernel : PASS
164+
✅ VS Code Settings : PASS
165+
166+
📊 Overall: 9/9 checks passed
167+
168+
🎉 All checks passed! Your local environment is ready for APIM Samples.
169+
💡 You can now open any notebook and it should work seamlessly.
106170
```
107171

108172
---
@@ -132,11 +196,11 @@ If you're setting up locally without the dev container:
132196
1. **Create Python Environment**: In VS Code, use Ctrl+Shift+P → "Python: Create Environment" → "Venv" → Select Python version → Check requirements.txt
133197
2. **Complete Environment Setup**: Run the automated setup script:
134198
```bash
135-
python setup/setup_python_path.py --complete-setup
199+
python setup/local_setup.py --complete-setup
136200
```
137201
For help and available options, run without arguments:
138202
```bash
139-
python setup/setup_python_path.py
203+
python setup/local_setup.py
140204
```
141205
3. **Restart VS Code** to apply all settings
142206
4. **Sign in to Azure**: `az login --tenant <your-tenant-id>` and `az account set --subscription <your-subscription>`
@@ -164,9 +228,9 @@ If you prefer manual setup or the automated script doesn't work:
164228
1. Verify the virtual environment is set up. You should see a new _.venv_ directory with a _pyveng.cfg_ file and the Python version you selected earlier.
165229
1. Set up the project environment:
166230
```bash
167-
python setup/setup_python_path.py --generate-env
168-
python setup/setup_python_path.py --setup-kernel
169-
python setup/setup_python_path.py --setup-vscode
231+
python setup/local_setup.py --generate-env
232+
python setup/local_setup.py --setup-kernel
233+
python setup/local_setup.py --setup-vscode
170234
```
171235
1. **Restart VS Code** to ensure all environment settings are loaded properly.
172236

@@ -178,7 +242,7 @@ If you encounter import errors (e.g., `ModuleNotFoundError: No module named 'req
178242

179243
1. **Fix Python path configuration**:
180244
```bash
181-
python setup/setup_python_path.py --generate-env
245+
python setup/local_setup.py --generate-env
182246
```
183247

184248
2. **Verify setup**:

TROUBLESHOOTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ ModuleNotFoundError: No module named 'utils'
152152
**Solution:**
153153
Use the provided setup script:
154154
```bash
155-
python setup/setup_python_path.py --generate-env
155+
python setup/local_setup.py --generate-env
156156
```
157157

158158
### Working Directory Issues

setup/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Configures cross-platform PYTHONPATH for APIM Samples and provides streamlined l
77
For complete local environment setup that matches the dev container experience:
88

99
```shell
10-
python setup/setup_python_path.py --complete-setup
10+
python setup/local_setup.py --complete-setup
1111
```
1212

1313
This will:
@@ -23,22 +23,22 @@ If you prefer to run setup steps individually:
2323

2424
```shell
2525
# Generate .env file only
26-
python setup/setup_python_path.py --generate-env
26+
python setup/local_setup.py --generate-env
2727

2828
# Register Jupyter kernel only
29-
python setup/setup_python_path.py --setup-kernel
29+
python setup/local_setup.py --setup-kernel
3030

3131
# Configure VS Code settings only
32-
python setup/setup_python_path.py --setup-vscode
32+
python setup/local_setup.py --setup-vscode
3333

3434
# Force kernel consistency (fix kernel switching issues)
35-
python setup/setup_python_path.py --force-kernel
35+
python setup/local_setup.py --force-kernel
3636

3737
# Basic PYTHONPATH setup for current session
38-
python setup/setup_python_path.py --run-only
38+
python setup/local_setup.py --run-only
3939

4040
# Show help and available options
41-
python setup/setup_python_path.py
41+
python setup/local_setup.py
4242
```
4343

4444
## Verification
@@ -62,13 +62,13 @@ This checks:
6262

6363
To ensure notebooks always use the correct kernel ("APIM Samples Python 3.12" instead of ".venv" or "python3"):
6464

65-
1. **Run the complete setup**: `python setup/setup_python_path.py --complete-setup`
65+
1. **Run the complete setup**: `python setup/local_setup.py --complete-setup`
6666
2. **Restart VS Code** completely
6767
3. **Verify with**: `python setup/verify_setup.py`
6868

6969
If you still see incorrect kernel names, run:
7070
```shell
71-
python setup/setup_python_path.py --force-kernel
71+
python setup/local_setup.py --force-kernel
7272
```
7373

7474
## Troubleshooting

0 commit comments

Comments
 (0)