Skip to content

Commit

Permalink
fixing install_dependencies.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
tomarv2 committed May 21, 2021
1 parent b89045c commit 2508027
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.

This file was deleted.

33 changes: 17 additions & 16 deletions install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,41 @@

echo "Executing install_dependencies.sh..."

# Abort if a requierements file doesn't exist
FILE=$source_code_path/requirements.txt
if [ ! -e $FILE ]; then
echo "Error: $FILE does not exist!"
exit 1
fi

# Run from the specified directory
cd $path_cwd

# Abort if a requirements file doesn't exist
REQ_FILE=$source_code_path/requirements.txt
if [ ! -e $REQ_FILE ]; then
echo "Error: $REQ_FILE does not exist!"
exit 1
fi

# Create a temp directory if it doesn't exist
dir_name=/tmp/lambda_dist_pkg/
if [ -d $dir_name ];
echo "Reusing package staging directory ($dir_name)"
pkg_dir=/tmp/lambda_dist_pkg/
if [ -d $pkg_dir ]; then
echo "Reusing package staging directory ($pkg_dir)"
else
echo "Creating package staging directory ($dir_name)"
mkdir $dir_name || exit 2
echo "Creating package staging directory ($pkg_dir)"
mkdir $pkg_dir || exit 2
fi

# Create and activate virtual environment...
virtualenv -p $runtime env_$function_name || exit 3
source env_$function_name/bin/activate || exit 4

# Installing python dependencies...
echo "Installing dependencies from $FILE..."
pip install -r "$FILE" || exit 5
echo "Installing dependencies from $REQ_FILE..."
pip install -r "$REQ_FILE" || exit 5

# Deactivate virtual environment...
deactivate

# Create deployment package...
echo "Creating deployment package..."
( cd env_$function_name/lib/$runtime/site-packages/ && cp -r * $dir_name) || exit 6
( cd env_$function_name/lib/$runtime/site-packages/ && cp -r * $pkg_dir) || exit 6

cp -r $source_code_path/ $dir_name || exit 7
cp -r $source_code_path/* $pkg_dir || exit 7

# Removing virtual environment folder...
echo "Removing virtual environment folder..."
Expand Down

0 comments on commit 2508027

Please sign in to comment.