unstructured/scripts/consistent-deps.sh
Roman Isecke d6f2841ff4
feat: update dependencies and remove constraint on pydantic (#2841)
### Description
* The `consistent-deps.sh` was fixed to take into account the ingest
dependencies, causing some errors to show up. New constriants were added
to make that script pass.
* Update all requirements without constraint on pydantic, allowing the
latest version to be pulled in.
* `pikepdf` is causing a conflict but there's a fix on their `main`
branch, just need for the next release to be published. Opened up a
question here to see if we can get that out any sooner: [Do releases
happen on a
schedule?](https://github.com/pikepdf/pikepdf/discussions/574). For now
added `lxml<5` to the constraints.

A couple optimizations: 
* `constraints.in` renamed to `constraints.txt` since the whole point is
all dependencies are already pinned and the file never gets compiled
* `constraints.txt` moved to a `requirements/deps` directory as this
never gets compiled by `pip-compile`
* Other dependency files updated to reference the new location of
`base.in` and `constraints.txt`
* make file updated since it was originally written to avoid the
`base.in` and `constraints.in` file
2024-04-04 19:58:23 +00:00

47 lines
1.4 KiB
Bash
Executable File

#!/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 {
local d=${1-} f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
}
# NOTE(alan): Add any dependency files here we don't want to include in the resolution.
excludefiles=("requirements//build.txt")
# Build an array of requirements files.
shopt -s nullglob
reqfiles=()
while IFS= read -r -d $'\0'; do
reqfiles+=("$REPLY")
done < <(find requirements/ -type f -name '*.txt' -print0)
# Remove the excluded files from the array of requirements files.
for excludefile in "${excludefiles[@]}"; do
for i in "${!reqfiles[@]}"; do
if [[ ${reqfiles[i]} = "$excludefile" ]]; then
unset 'reqfiles[i]'
fi
done
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}"
if $pipcommand >>/dev/null; then
echo "Everything looks fine!"
else
exit 1
fi