3 # Copyright (C) 2016 <contact@redhat.com>
5 # Author: Loic Dachary <loic@dachary.org>
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)
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.
18 SCRIPTNAME
="$(basename $0)"
19 if [ `uname` == FreeBSD
]; then
20 GETOPT
="/usr/local/bin/getopt"
27 echo "$SCRIPTNAME - automate setup of Python virtual environment"
28 echo " (for use in building Ceph)"
31 echo " $SCRIPTNAME [--python=PYTHON_BINARY] TARGET_DIRECTORY"
33 echo " TARGET_DIRECTORY will be created if it doesn't exist,"
34 echo " and completely destroyed and re-created if it does!"
39 TEMP
=$
($GETOPT --options "h" --long "help,python:" --name "$SCRIPTNAME" -- "$@")
46 -h|
--help) usage
;; # does not return
47 --python) PYTHON_OPTION
="--python=$2" ; shift ; shift ;;
49 *) echo "Internal error" ; exit 1 ;;
54 if [ -z "$DIR" ] ; then
55 echo "$SCRIPTNAME: need a directory path, but none was provided"
60 virtualenv
$PYTHON_OPTION $DIR
63 if pip
--help |
grep -q disable-pip-version-check
; then
64 DISABLE_PIP_VERSION_CHECK
=--disable-pip-version-check
66 DISABLE_PIP_VERSION_CHECK
=
69 # older versions of pip will not install wrap_console scripts
70 # when using wheel packages
71 pip
$DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt
install --upgrade 'pip >= 6.1'
73 if pip
--help |
grep -q disable-pip-version-check
; then
74 DISABLE_PIP_VERSION_CHECK
=--disable-pip-version-check
76 DISABLE_PIP_VERSION_CHECK
=
79 if test -d wheelhouse
; then
80 export NO_INDEX
=--no-index
83 pip
$DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt
install $NO_INDEX --find-links=file://$
(pwd)/wheelhouse
'tox >=2.9.1'
84 if test -f requirements.txt
; then
85 if ! test -f wheelhouse
/md5 ||
! md5sum -c wheelhouse
/md5
> /dev
/null
; then
88 pip
$DISABLE_PIP_VERSION_CHECK --log $DIR/log.txt
install $NO_INDEX --find-links=file://$
(pwd)/wheelhouse
-r requirements.txt