Pin setuptools<45.0.0 for setupOpenstackVirtualenv
* Unhardcode python version for setupOpenstackVirtualenv
Change-Id: I45c56c8d6dec98ee24e600d595c33a5e1a2641e6
Related-Prod: PRODX-2254
diff --git a/src/com/mirantis/mk/Openstack.groovy b/src/com/mirantis/mk/Openstack.groovy
index b11f628..277d839 100644
--- a/src/com/mirantis/mk/Openstack.groovy
+++ b/src/com/mirantis/mk/Openstack.groovy
@@ -22,9 +22,9 @@
* @param version Version of the OpenStack clients
*/
-def setupOpenstackVirtualenv(path, version = 'latest') {
- def python = new com.mirantis.mk.Python()
- python.setupDocutilsVirtualenv(path)
+def setupOpenstackVirtualenv(path, version = 'latest', python="python2") {
+ def pythonLib = new com.mirantis.mk.Python()
+ pythonLib.setupDocutilsVirtualenv(path)
def openstack_kilo_packages = [
//XXX: hack to fix https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1635463
@@ -68,7 +68,7 @@
} else {
requirements = openstack_latest_packages
}
- python.setupVirtualenv(path, 'python2', requirements, null, true)
+ pythonLib.setupVirtualenv(path, python, requirements, null, true)
}
/**
diff --git a/src/com/mirantis/mk/Python.groovy b/src/com/mirantis/mk/Python.groovy
index f009107..496e6f5 100644
--- a/src/com/mirantis/mk/Python.groovy
+++ b/src/com/mirantis/mk/Python.groovy
@@ -32,17 +32,18 @@
}
common.infoMsg("[Python ${path}] Setup ${python} environment")
sh(returnStdout: true, script: virtualenv_cmd)
- if(!offlineDeployment){
- try {
- def pipPackage = 'pip'
- if (python == 'python2') {
- pipPackage = "\"pip<=19.3.1\""
- common.infoMsg("Pinning pip package due to end of life of Python2 to ${pipPackage} version.")
- }
- runVirtualenvCommand(path, "pip install -U setuptools ${pipPackage}")
- } catch(Exception e) {
- common.warningMsg("Setuptools and pip cannot be updated, you might be offline but OFFLINE_DEPLOYMENT global property not initialized!")
- }
+ if (!offlineDeployment) {
+ try {
+ def pipPackage = 'pip'
+ if (python == 'python2') {
+ pipPackage = "\"pip<=19.3.1\""
+ common.infoMsg("Pinning pip package due to end of life of Python2 to ${pipPackage} version.")
+ }
+ // NOTE(vsaienko): pin setuptools explicitly for latest version that works with python2
+ runVirtualenvCommand(path, "pip install -U \"setuptools<45.0.0\" ${pipPackage}")
+ } catch (Exception e) {
+ common.warningMsg("Setuptools and pip cannot be updated, you might be offline but OFFLINE_DEPLOYMENT global property not initialized!")
+ }
}
if (reqs_path==null) {
def args = ""
@@ -87,11 +88,11 @@
*
* @param path Path where virtualenv is created
*/
-def setupDocutilsVirtualenv(path) {
+def setupDocutilsVirtualenv(path, python="python2") {
requirements = [
'docutils',
]
- setupVirtualenv(path, 'python2', requirements)
+ setupVirtualenv(path, python, requirements)
}