Skip to content

Commit

Permalink
Use venv for shell scripts as well, fix local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelafox committed Jun 20, 2023
1 parent 1ea7c08 commit 26f37b1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ hooks:
postprovision:
windows:
shell: pwsh
run: ./scripts/auth_update.ps1;./scripts/prepdocs.ps1; $output = azd env get-values; Add-Content -Path .env -Value $output;
run: ./scripts/auth_update.ps1;./scripts/prepdocs.ps1;
interactive: true
continueOnError: false
posix:
shell: sh
run: ./scripts/auth_update.sh;./scripts/prepdocs.sh;azd env get-values > .env
run: ./scripts/auth_update.sh;./scripts/prepdocs.sh;
interactive: true
continueOnError: false
2 changes: 1 addition & 1 deletion scripts/auth_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
. ./scripts/loadenv.sh

echo 'Running "auth_init.py"'
python3 ./scripts/auth_init.py --appid "$AUTH_APP_ID"
./.venv/bin/python ./scripts/auth_init.py --appid "$AUTH_APP_ID"
2 changes: 1 addition & 1 deletion scripts/auth_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
. ./scripts/loadenv.sh

echo 'Running "auth_update.py"'
python3 ./scripts/auth_update.py --appid "$AUTH_APP_ID" --uri "$BACKEND_URI"
./.venv/bin/python ./scripts/auth_update.py --appid "$AUTH_APP_ID" --uri "$BACKEND_URI"
4 changes: 2 additions & 2 deletions scripts/loadenv.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $(azd env get-values)
EOF

echo 'Creating Python virtual environment ".venv" in root'
python -m venv .venv
python3 -m venv .venv

echo 'Installing dependencies from "requirements.txt" into virtual environment'
.venv/bin/python -m pip install -r requirements-dev.txt
./.venv/bin/python -m pip install -r requirements-dev.txt
2 changes: 1 addition & 1 deletion scripts/prepdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
. ./scripts/loadenv.sh

echo 'Running "prepdocs.py"'
python3 ./scripts/prepdocs.py --searchservice "$AZURE_SEARCH_SERVICE" --index "$AZURE_SEARCH_INDEX" --formrecognizerservice "$AZURE_FORMRECOGNIZER_SERVICE" --tenantid "$AZURE_TENANT_ID"
./.venv/bin/python ./scripts/prepdocs.py --searchservice "$AZURE_SEARCH_SERVICE" --index "$AZURE_SEARCH_INDEX" --formrecognizerservice "$AZURE_FORMRECOGNIZER_SERVICE" --tenantid "$AZURE_TENANT_ID"
6 changes: 4 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ if [ $? -ne 0 ]; then
exit $?
fi

cd ..
. ./scripts/loadenv.sh

echo ""
echo "Starting backend"
echo ""
cd ..
python3 -m flask run --port=5000 --host=127.0.0.1 --reload --debug
./.venv/bin/python -m flask run --port=5000 --host=127.0.0.1 --reload --debug
if [ $? -ne 0 ]; then
echo "Failed to start backend"
exit $?
Expand Down

0 comments on commit 26f37b1

Please sign in to comment.