2022-01-10 16:23:22 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
################################################################################
|
|
|
|
########################### Install Python Dependancies ########################
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Set fail on error #
|
|
|
|
#####################
|
|
|
|
set -euo pipefail
|
|
|
|
|
2023-12-29 13:30:58 -05:00
|
|
|
apk add --no-cache --virtual .python-build-deps \
|
|
|
|
gcc \
|
|
|
|
linux-headers \
|
|
|
|
musl-dev \
|
|
|
|
python3-dev
|
|
|
|
|
2022-01-10 16:23:22 -05:00
|
|
|
############################
|
|
|
|
# Create staging directory #
|
|
|
|
############################
|
|
|
|
mkdir -p /venvs
|
|
|
|
|
|
|
|
########################################
|
|
|
|
# Install basic libs to run installers #
|
|
|
|
########################################
|
|
|
|
pip install virtualenv
|
|
|
|
|
2023-10-27 19:07:51 -04:00
|
|
|
#######################################################
|
|
|
|
# Iterate through requirments.txt to install binaries #
|
|
|
|
#######################################################
|
2022-01-10 21:25:37 -05:00
|
|
|
for DEP_FILE in *.txt; do
|
2022-01-10 16:23:22 -05:00
|
|
|
# split the package name from its version
|
2022-01-10 21:25:37 -05:00
|
|
|
PACKAGE_NAME=${DEP_FILE%.txt}
|
2022-01-10 16:23:22 -05:00
|
|
|
echo "-------------------------------------------"
|
|
|
|
mkdir -p "/venvs/${PACKAGE_NAME}"
|
2022-01-10 21:25:37 -05:00
|
|
|
cp "${DEP_FILE}" "/venvs/${PACKAGE_NAME}/requirements.txt"
|
2022-01-10 16:23:22 -05:00
|
|
|
echo "Generating virtualenv for: [${PACKAGE_NAME}]"
|
|
|
|
pushd "/venvs/${PACKAGE_NAME}"
|
|
|
|
virtualenv .
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
source bin/activate
|
2023-12-29 13:30:58 -05:00
|
|
|
pip install \
|
|
|
|
--no-cache-dir \
|
|
|
|
--requirement requirements.txt
|
2022-01-10 16:23:22 -05:00
|
|
|
# deactivate the python virtualenv
|
|
|
|
deactivate
|
|
|
|
# pop the stack
|
|
|
|
popd
|
2022-01-10 21:25:37 -05:00
|
|
|
done
|
2023-12-29 13:30:58 -05:00
|
|
|
|
|
|
|
apk del --no-network --purge .python-build-deps
|