sphinx-wagtail-theme
sphinx-wagtail-theme copied to clipboard
Vercel preview deployments broken due to urllib3 issue
Our preview deployments in Vercel are broken because they run in Amazon Linux 2 images, which only have very dated versions of Python, which use old versions of OpenSSL no longer supported by urllib3. This is the following issue: https://github.com/urllib3/urllib3/issues/2168
Official guidance from urllib3: https://urllib3.readthedocs.io/en/latest/v2-migration-guide.html#common-upgrading-issues
I have contacted Vercel support to ask if they have plans to switch build images / make it configurable. Installing Python from source is also possible but didn’t feel like the right thing. It looked like this:
# What we needed updated
yum install openssl11 openssl11-devel
# Dependency for pyenv installer
yum install git
# Dependency for pyenv fetching of Python source
yum install tar
# Dependencies for Python build from source
yum install gcc make patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl11-devel tk-devel libffi-devel xz-devel
# pyenv installer
curl https://pyenv.run | bash
# pyenv initialisation
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# install desired Python version
pyenv install 3.11
# Switch to the new Python
pyenv shell 3.11
[… our actual project-specific installation steps …]
In the meantime, I’ve pinned our Vercel builds to use urllib3<2
.
In the meantime, I’ve pinned our Vercel builds to use
urllib3==1.26.16
.
Out of curiosity, how did you do this? I've never used Python on Vercel before.
Also, the urllib documentation mentions that we should pin urllib<2
instead of a specific version so that we continue getting security updates.
Good point! Here is the now-updated installation command:
npm install && python3 -m pip install -r requirements.txt && pip install "urllib3<2" && python3 -m pip install -e .
It looks like Vercel recently introduced support for defining build commands in their configuration file (or I somehow never saw it until now) – if we did this, here is what our full configuration would look like:
{
"installCommand": "npm install && python3 -m pip install -r requirements.txt && pip install urllib3<2 && python3 -m pip install -e .",
"buildCommand": "npm run build && python3 -m sphinx -M html docs/ _build",
"outputDirectory": "_build/html",
"github": {
"silent": true
}
}