create-venv: add role; use in install-borg

As noted inline, make a create-venv role that brings in appropriate
versions on Bionic.

This was noticed because pip is trying to install borgbackup with
setuptools_scm 7.0.5, which doesn't support Python 3.6.  We use this
new role to create the venv correctly.

Change-Id: I81fd268a9354685496a75e33a6f038a32b686352
This commit is contained in:
Ian Wienand 2022-08-09 14:30:05 +10:00
parent 1f7e89dcc8
commit ea08cdbd16
3 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,19 @@
Create a venv
You would think this role is unnecessary and roles could just install
a ``venv`` directly ... except sometimes pip/setuptools get out of
date on a platform and can't understand how to install compatible
things. For example the pip shipped on Bionic will upgrade itself to
a version that doesn't support Python 3.6 because it doesn't
understand the metadata tags the new version marks itself with. We've
seen similar problems with wheels. History has shown that whenever
this problem appears solved, another issue will appear. So for
reasons like this, we have this as a synchronization point for setting
up venvs.
**Role Variables**
.. zuul:rolevar:: create_venv_path
:default: unset
Required argument; the directory to make the ``venv``

View File

@ -0,0 +1,25 @@
- name: Check directory is specified
assert:
that: create_venv_path is defined
# Bionic's default pip will try to pull in packages that
# aren't compatible with 3.6. Cap them
- name: Setup bionic era venv
when: ansible_distribution_release == 'bionic'
pip:
name:
- pip<22
- setuptools<60
state: latest
virtualenv: '{{ create_venv_path }}'
virtualenv_command: '/usr/bin/python3 -m venv'
- name: Setup later era venv
when: ansible_distribution_release != 'bionic'
pip:
name:
- pip
- setuptools
state: latest
virtualenv: '{{ create_venv_path }}'
virtualenv_command: '/usr/bin/python3 -m venv'

View File

@ -17,6 +17,12 @@
- fuse
- pkg-config
- name: Create venv
include_role:
name: create-venv
vars:
create_venv_path: '/opt/borg'
- name: Install borg
pip:
# borg build deps are a little ... interesting, it needs cython
@ -25,4 +31,3 @@
- cython
- 'borgbackup[fuse]=={{ borg_version }}'
virtualenv: /opt/borg
virtualenv_command: /usr/bin/python3 -m venv