Skip to content

Commit 136b6cd

Browse files
Merge pull request #3 from RonWang/master
Check the existence of .venv and SITE before copying source code.
2 parents 21a1602 + 3ef02a2 commit 136b6cd

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

hooks/post_new_hook.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ create_env () {
2626
return 0
2727
else
2828
# No venv script present (< Py 3.3). Install using virtualenv
29-
return create_using_virtualenv $PYTHON
29+
create_using_virtualenv $PYTHON
30+
return $?
3031
fi
3132
else
3233
# Python2 environment. Install using virtualenv
3334
PYTHON=python
34-
return create_using_virtualenv $PYTHON
35+
create_using_virtualenv $PYTHON
36+
return $?
3537
fi
3638
return 1
3739
}

hooks/pre_deploy_hook.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ echo "###########################"
2727
echo "##### pre-deploy hook #####"
2828
echo "###########################"
2929

30+
31+
RET=0
3032
if [[ $TARGET == "all" || $TARGET == "lambda" ]]; then
3133
grep "sourceDir" ./skill.json | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | while read -r SOURCE_DIR; do
3234
# Step 1: Decide source path and upload path
@@ -49,10 +51,22 @@ if [[ $TARGET == "all" || $TARGET == "lambda" ]]; then
4951

5052
# Step 4: Find virtual environment site packages, copy contents to lambda_upload
5153
echo "Copying dependencies installed in $SKILL_NAME/.venv/$SKILL_ENV_NAME to $SKILL_NAME/$UPLOAD_DIR"
54+
if [[ ! "$(ls -A .venv/$SKILL_ENV_NAME/bin/python)" ]]; then
55+
echo "Failed to get virtual env Python runtime"
56+
RET=1
57+
break;
58+
fi
59+
5260
SITE=$(.venv/$SKILL_ENV_NAME/bin/python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
53-
cp -r $SITE/* $UPLOAD_DIR
61+
if [[ "$(ls -A $SITE/*)" ]]; then
62+
cp -r $SITE/* $UPLOAD_DIR
63+
else
64+
echo "Failed to get the SITE package path"
65+
RET=1
66+
break;
67+
fi
5468

55-
# Step 4: Update the "manifest.apis.custom.endpoint.sourceDir" value in skill.json if necessary
69+
# Step 5: Update the "manifest.apis.custom.endpoint.sourceDir" value in skill.json if necessary
5670
if ! [[ $SOURCE_DIR == */lambda_upload ]]; then
5771
echo "Updating sourceDir to point to lambda_upload folder in skill.json"
5872
RAW_SOURCE_DIR_LINE="\"sourceDir\": \"$SOURCE_DIR\""
@@ -63,4 +77,4 @@ if [[ $TARGET == "all" || $TARGET == "lambda" ]]; then
6377
echo "###########################"
6478
fi
6579

66-
exit 0
80+
exit $RET

0 commit comments

Comments
 (0)