From 3f6e44323264713da4ff2f4afb89989eb6b38614 Mon Sep 17 00:00:00 2001
From: "John L. Villalovos" <john.l.villalovos@intel.com>
Date: Fri, 4 Sep 2015 11:57:16 -0700
Subject: [PATCH] Add constraint target to tox.ini

This adds a pip install command to tox.ini that is only used when the
tox env is passed with the 'constraints' factor appended onto it.
As such this will not effect developer workflows or current unit tests.

The initial use of this will be in a non-voting job, to verify that the
constrained checks with tox are stable.  DevStack is already running
constrained jobs, as such problems are not expected.

To run a tox with pip using constraints on a developer system a
developer should run the desired tox environment with -constraints.
For example: $(tox -epy27-constraints)
Pip will pull the current version of the upper-constraints.txt file down
from the git.openstack.org, however this method can be overriden to use
a local file setting the environment variable "UPPER_CONSTRAINTS_FILE"
to the local path or a different URL, it is passed directly to pip.

This is currently not enabled in the default tox run, however it is
possible to enable it as a default by adding it to 'envlist' in tox.ini

Backport of Nova commit ad38ce1fc98692ee59ef061de1a35f355d219aa1

Change-Id: Ia3cfb30fd1d8529bb4fbcf8873036149ea6f483c
Implements Blueprint: Requirements-Management
---
 tox.ini | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tox.ini b/tox.ini
index 6dfecc57e5..8a7704c824 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,11 +1,13 @@
 [tox]
-minversion = 1.6
+minversion = 1.8
 skipsdist = True
 envlist = py34,py27,pep8
 
 [testenv]
 usedevelop = True
-install_command = pip install -U {opts} {packages}
+install_command =
+                  constraints: pip install -U --force-reinstall -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
+                  pip install -U {opts} {packages}
 setenv = VIRTUAL_ENV={envdir}
          PYTHONDONTWRITEBYTECODE = 1
          LANGUAGE=en_US