Iterating on ancient versions of PythonΒΆ
Some of the failures that we encounter only arise in ancient versions of python. It can be non-trivial to install these versions on a production machine, and possibly not desirable. In these situations LXD comes to our aid.
Save the following cloud-init
file in python35_cloud_init.yaml
:
#cloud-config
runcmd:
- add-apt-repository --yes ppa:checkbox-dev/edge
- apt update -q -y
- apt install -q -y "python3.5" "python3.5-venv" "python3.5-dev" gcc "flake8" "shellcheck"
- python3.5 -m ensurepip
- python3.5 -m venv /root/venv
- PIP_TRUSTED_HOST="pypi.python.org pypi.org files.pythonhosted.org" /root/venv/bin/python3.5 -m pip install --upgrade "pip<21"
- git clone https://github.com/canonical/checkbox /root/checkbox
- PIP_TRUSTED_HOST="pypi.python.org pypi.org files.pythonhosted.org" /root/venv/bin/python3.5 -m pip install -e /root/checkbox/checkbox-ng
- PIP_TRUSTED_HOST="pypi.python.org pypi.org files.pythonhosted.org" /root/venv/bin/python3.5 -m pip install -e /root/checkbox/checkbox-support
- /root/venv/bin/python3.5 /root/checkbox/providers/resource/manage.py develop
- /root/venv/bin/python3.5 /root/checkbox/providers/base/manage.py develop
Use lxc
to launch a focal
container with the cloud-init
file
provided, log into it and wait for cloud-init
to finish preparing your
environment
$ lxc launch ubuntu:focal python35 --config=user.user-data="$(cat python35_cloud_init.yaml)"
$ lxc shell python35
root@python35:~# cloud-init status --wait
...........................................status: done
The cloud-init
file has prepared you a fresh clone of the Checkbox repo in
/root/checkbox
, it has created a venv you can use in /root/venv
with
Python3.5 and it has developed the resource
and base
provider. You
should now be able to iterate on your tests!
Note
Python 3.5 and Python 3.6 are no longer in the deadsnakes PPA. We have added them to the checkbox-dev PPA to still be able to run the tests.