]> git.proxmox.com Git - ceph.git/blame - ceph/src/tools/setup-virtualenv.sh
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / tools / setup-virtualenv.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
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
11fdf7f2 18SCRIPTNAME="$(basename $0)"
11fdf7f2
TL
19if [ `uname` == FreeBSD ]; then
20 GETOPT="/usr/local/bin/getopt"
21else
22 GETOPT=getopt
23fi
24
25function usage {
26 echo
27 echo "$SCRIPTNAME - automate setup of Python virtual environment"
28 echo " (for use in building Ceph)"
29 echo
30 echo "Usage:"
31 echo " $SCRIPTNAME [--python=PYTHON_BINARY] TARGET_DIRECTORY"
32 echo
11fdf7f2
TL
33 echo " TARGET_DIRECTORY will be created if it doesn't exist,"
34 echo " and completely destroyed and re-created if it does!"
35 echo
36 exit 1
37}
38
39TEMP=$($GETOPT --options "h" --long "help,python:" --name "$SCRIPTNAME" -- "$@")
40test $? != 0 && usage
41eval set -- "$TEMP"
42
92f5a8d4 43PYTHON_OPTION=""
11fdf7f2
TL
44while true ; do
45 case "$1" in
46 -h|--help) usage ;; # does not return
92f5a8d4 47 --python) PYTHON_OPTION="--python=$2" ; shift ; shift ;;
11fdf7f2
TL
48 --) shift ; break ;;
49 *) echo "Internal error" ; exit 1 ;;
50 esac
51done
52
7c673cae 53DIR=$1
11fdf7f2
TL
54if [ -z "$DIR" ] ; then
55 echo "$SCRIPTNAME: need a directory path, but none was provided"
56 usage
57fi
7c673cae
FG
58rm -fr $DIR
59mkdir -p $DIR
92f5a8d4 60virtualenv $PYTHON_OPTION $DIR
7c673cae
FG
61. $DIR/bin/activate
62
63if pip --help | grep -q disable-pip-version-check; then
64 DISABLE_PIP_VERSION_CHECK=--disable-pip-version-check
65else
66 DISABLE_PIP_VERSION_CHECK=
67fi
68
69# older versions of pip will not install wrap_console scripts
70# when using wheel packages
71pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install --upgrade 'pip >= 6.1'
72
73if pip --help | grep -q disable-pip-version-check; then
74 DISABLE_PIP_VERSION_CHECK=--disable-pip-version-check
75else
76 DISABLE_PIP_VERSION_CHECK=
77fi
78
79if test -d wheelhouse ; then
80 export NO_INDEX=--no-index
81fi
82
11fdf7f2 83pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install $NO_INDEX --find-links=file://$(pwd)/wheelhouse 'tox >=2.9.1'
7c673cae 84if test -f requirements.txt ; then
11fdf7f2
TL
85 if ! test -f wheelhouse/md5 || ! md5sum -c wheelhouse/md5 > /dev/null; then
86 NO_INDEX=''
87 fi
94b18763 88 pip $DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt install $NO_INDEX --find-links=file://$(pwd)/wheelhouse -r requirements.txt
7c673cae 89fi