2023-05-24 17:29:35 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
####################################################################################################
|
|
|
|
# Check depedency consistency by forcing pip to resolve all the requirement .txt files at once
|
|
|
|
# (without installing).
|
|
|
|
####################################################################################################
|
|
|
|
|
|
|
|
echo "Checking consistency of dependencies..."
|
|
|
|
|
|
|
|
# Joins an array of strings using the specified delimiter.
|
|
|
|
function join_by {
|
2023-12-18 23:48:21 -08:00
|
|
|
local d=${1-} f=${2-}
|
|
|
|
if shift 2; then
|
|
|
|
printf %s "$f" "${@/#/$d}"
|
|
|
|
fi
|
2023-05-24 17:29:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# NOTE(alan): Add any dependency files here we don't want to include in the resolution.
|
2024-10-15 11:01:34 -04:00
|
|
|
excludefiles=("requirements/ingest/ingest.txt")
|
2023-05-24 17:29:35 -05:00
|
|
|
|
|
|
|
# Build an array of requirements files.
|
|
|
|
shopt -s nullglob
|
2024-04-04 15:58:23 -04:00
|
|
|
reqfiles=()
|
|
|
|
while IFS= read -r -d $'\0'; do
|
|
|
|
reqfiles+=("$REPLY")
|
|
|
|
done < <(find requirements/ -type f -name '*.txt' -print0)
|
2023-05-24 17:29:35 -05:00
|
|
|
|
|
|
|
# Remove the excluded files from the array of requirements files.
|
|
|
|
for excludefile in "${excludefiles[@]}"; do
|
2023-12-18 23:48:21 -08:00
|
|
|
for i in "${!reqfiles[@]}"; do
|
|
|
|
if [[ ${reqfiles[i]} = "$excludefile" ]]; then
|
|
|
|
unset 'reqfiles[i]'
|
|
|
|
fi
|
|
|
|
done
|
2023-05-24 17:29:35 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
# Turn the requirement files array into pip -r flags.
|
|
|
|
reqstring=$(join_by ' -r ' "${reqfiles[@]}")
|
|
|
|
reqstring="-r ${reqstring}"
|
|
|
|
# This pip command will attempt to resolve the dependencies without installing anything.
|
|
|
|
pipcommand="pip install --dry-run --ignore-installed ${reqstring}"
|
2024-10-15 11:01:34 -04:00
|
|
|
echo "dry run install of the following req files:"
|
|
|
|
echo "${pipcommand}"
|
2023-12-11 20:04:15 -05:00
|
|
|
if $pipcommand >>/dev/null; then
|
2023-12-18 23:48:21 -08:00
|
|
|
echo "Everything looks fine!"
|
2023-05-24 17:29:35 -05:00
|
|
|
else
|
2023-12-18 23:48:21 -08:00
|
|
|
exit 1
|
2023-05-24 17:29:35 -05:00
|
|
|
fi
|