@@ -76,12 +76,32 @@ function retry {
76
76
function ensure_openstack_client {
77
77
if ! command -v openstack;
78
78
then
79
- apt-get install -y python3-dev
80
- # install PyYAML first because otherwise we get an error because pip3 doesn't upgrade PyYAML to the correct version
81
- # ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which
82
- # files belong to it which would lead to only a partial uninstall.
83
- pip3 install --ignore-installed PyYAML
84
- pip3 install python-cinderclient python-glanceclient python-keystoneclient python-neutronclient python-novaclient python-openstackclient python-octaviaclient
79
+ # We are running in a Debian Buster image with python 3.7. Python 3.7
80
+ # is starting to show its age in upstream support. Ideally we would
81
+ # move to a newer image with a newer python version.
82
+ #
83
+ # Until then, this script tries to carefully navigate around current
84
+ # issues running openstack client on python 3.7.
85
+ #
86
+ # We explicitly pin the yoga version of openstackclient. This is the
87
+ # last version of openstackclient which will support python 3.7.
88
+
89
+ # Install virtualenv to install the openstack client and curl to fetch
90
+ # the build constraints.
91
+ apt-get install -y python3-virtualenv curl
92
+ python3 -m virtualenv -p $( which python3) /tmp/openstack-venv
93
+ VIRTUAL_ENV_DISABLE_PROMPT=1 source /tmp/openstack-venv/bin/activate
94
+
95
+ # openstackclient has never actually supported python 3.7, only 3.6 and
96
+ # 3.8. Here we download the yoga constraints file and modify all the
97
+ # 3.8 constraints to be 3.7 constraints.
98
+ curl -L https://releases.openstack.org/constraints/upper/yoga -o /tmp/yoga-constraints
99
+ sed -i " s/python_version=='3.8'/python_version=='3.7'/" /tmp/yoga-constraints
100
+
101
+ pip install -c /tmp/yoga-constraints \
102
+ python-openstackclient python-cinderclient \
103
+ python-glanceclient python-keystoneclient \
104
+ python-neutronclient python-novaclient python-octaviaclient
85
105
fi
86
106
}
87
107
0 commit comments