Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / tools / setup-virtualenv.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2016 <contact@redhat.com>
4 #
5 # Author: Loic Dachary <loic@dachary.org>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Library Public License for more details.
16 #
17
18 DIR=$1
19 rm -fr $DIR
20 mkdir -p $DIR
21 virtualenv --python python2.7 $DIR
22 . $DIR/bin/activate
23
24 if pip --help | grep -q disable-pip-version-check; then
25     DISABLE_PIP_VERSION_CHECK=--disable-pip-version-check
26 else
27     DISABLE_PIP_VERSION_CHECK=
28 fi
29
30 # older versions of pip will not install wrap_console scripts
31 # when using wheel packages
32 pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install --upgrade 'pip >= 6.1'
33
34 # workaround of https://github.com/pypa/setuptools/issues/1042
35 pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install --upgrade "setuptools < 36"
36
37 if pip --help | grep -q disable-pip-version-check; then
38     DISABLE_PIP_VERSION_CHECK=--disable-pip-version-check
39 else
40     DISABLE_PIP_VERSION_CHECK=
41 fi
42
43 if test -d wheelhouse ; then
44     export NO_INDEX=--no-index
45 fi
46
47 pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse 'tox >=1.9'
48 if test -f requirements.txt ; then
49     pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install $NO_INDEX --use-wheel --find-links=file://$(pwd)/wheelhouse -r requirements.txt
50 fi