In a thread here I asked about a problem I’m having with psycopg 3 support. As a workaround, I thought I’d create a file named requirements-vercel.txt, which will I use instead of the default requirements.txt.
The only difference between the two files, is that requirements-vercel requires an older version of psycopg, that’s it.
The buildfiles.sh contains reference to the appropriate file:
However, it seems that something along the way is still installing dependencies from requirements.txt. I don’t have any other explanation for what’s happening. I also disabled the build cache to be sure.
As a proof: if I change the contents of requirements.txt to be identical to the contents of requirements-vercel.txt, the app works and does not error.
OK, I’m pretty sure that I proved this, and pretty sure that this happens afterbuildfiles.sh is running. I added the following snippet to the start of the run:
echo "Uninstalling all packages from requirements.txt"
if [ -f requirements.txt ]; then
PACKAGES=$(python3 -m pip freeze | grep -F -f requirements.txt)
if [ -n "$PACKAGES" ]; then
echo "$PACKAGES" | xargs python3 -m pip uninstall -y
else
echo "No matching packages to uninstall."
fi
fi
And there were no packages installed.
So sometime after requirements are installed from python3 -m pip install -r requirements-vercel.txt, they are installed from requirements.txt. Which is undesirable in my case.
OK. It’s proved by this point. I added this to the start of buildfiles.sh:
echo "rename requirements-vercel.txt to requirements.txt"
mv requirements-vercel.txt requirements.txt
And the app is “magically” working again. Magically in the very negative sense of the word. I’ve spent more hours on this than I should have if this behavior was documented.