From 2c724509d1561ed4690ba405e156650c353901b2 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 18 Apr 2018 10:49:53 +0100 Subject: [PATCH] pip: Use 'upgrade-strategy' option to make PIP upgrades less aggressive The default upgrade-strategy could change from one version of PIP to another and the results may be unpredictable. We can control the PIP behavior during upgrades using the 'upgrade-strategy' option and default that to 'only-if-required' so PIP only upgrades what's really necessary. This also ensure that getting the latest pip passes the idempotence test now that we only upgrade only what's really necessary. Depends-On: I998182eca9851d2cc745930fc73ca37bfefd0951 Link: https://pip.pypa.io/en/stable/user_guide/#only-if-needed-recursive-upgrade Co-Authored-By: Jean-Philippe Evrard Change-Id: I2ba89e25c0010c9a5b515a3d0c9c731b30876e74 --- defaults/main.yml | 1 + ...control-upgrade-strategy-2807e228d529c389.yaml | 15 +++++++++++++++ templates/pip.conf.j2 | 1 + 3 files changed, 17 insertions(+) create mode 100644 releasenotes/notes/pip-control-upgrade-strategy-2807e228d529c389.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 8f41a49..c8b6e26 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -70,6 +70,7 @@ pip_timeout: 120 # Options for pip install pip_upgrade: true +pip_upgrade_strategy: "only-if-needed" # Default index for pip to use pip_default_index: https://pypi.python.org/simple diff --git a/releasenotes/notes/pip-control-upgrade-strategy-2807e228d529c389.yaml b/releasenotes/notes/pip-control-upgrade-strategy-2807e228d529c389.yaml new file mode 100644 index 0000000..c34d1e5 --- /dev/null +++ b/releasenotes/notes/pip-control-upgrade-strategy-2807e228d529c389.yaml @@ -0,0 +1,15 @@ +--- +features: + - | + The PIP upgrade strategy can now be controlled using the new + ``pip_install_strategy`` variable which can either be ``eager`` + if the deployers want to upgrade both the package and its dependencies or + ``only-if-needed`` if they want to only upgrade what's really necessary. + More information can be found on the `PIP user guide + `_ +upgrade: + - | + The default PIP stategy has been changed to ``only-of-needed`` in order to + minimize the amount of packages which are updated during installation. + Deployers can still override the default option using the ``pip_install_strategy`` + variable. diff --git a/templates/pip.conf.j2 b/templates/pip.conf.j2 index 30054ab..9b94138 100644 --- a/templates/pip.conf.j2 +++ b/templates/pip.conf.j2 @@ -14,6 +14,7 @@ trusted-host = [install] upgrade = {{ pip_upgrade }} +upgrade-strategy = {{ pip_upgrade_strategy }} pre = {{ pip_enable_pre_releases }} {% if pip_links | length > 0 %} find-links =