]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/setup-virtualenv.sh: do not default to python2.7
authorNathan Cutler <ncutler@suse.com>
Fri, 13 Sep 2019 14:12:52 +0000 (16:12 +0200)
committerNathan Cutler <ncutler@suse.com>
Tue, 14 Jan 2020 14:43:22 +0000 (15:43 +0100)
This commit changes the script's behavior when run without a --python option.
Before, we were running virtualenv with "--python python2.7" in that case.

That is not a reasonable default in September 2019, given that Python 2 EOL is
coming on January 1, 2020. Also, it breaks setup-virtualenv.sh in py3-only
environments.

With this patch, the script will not pass any "--python" option to virtualenv
(i.e., it will let virtualenv do whatever it thinks is best) in this case.

Fixes: https://tracker.ceph.com/issues/41821
Signed-off-by: Nathan Cutler <ncutler@suse.com>
(cherry picked from commit 78468e49ab2110d69bc34333c0ce90acb832de1a)

src/tools/setup-virtualenv.sh

index 89e50b744ff9716181251753d469fe7fd61162ba..f0fa1e4345ebefd50864b9089fed2951c396b24a 100755 (executable)
@@ -16,7 +16,6 @@
 #
 
 SCRIPTNAME="$(basename $0)"
-PYTHON_BINARY="python2.7"
 if [ `uname` == FreeBSD ]; then
     GETOPT="/usr/local/bin/getopt"
 else
@@ -31,7 +30,6 @@ function usage {
     echo "Usage:"
     echo "    $SCRIPTNAME [--python=PYTHON_BINARY] TARGET_DIRECTORY"
     echo
-    echo "    PYTHON_BINARY defaults to \"$PYTHON_BINARY\""
     echo "    TARGET_DIRECTORY will be created if it doesn't exist,"
     echo "        and completely destroyed and re-created if it does!"
     echo
@@ -42,10 +40,11 @@ TEMP=$($GETOPT --options "h" --long "help,python:" --name "$SCRIPTNAME" -- "$@")
 test $? != 0 && usage
 eval set -- "$TEMP"
 
+PYTHON_OPTION=""
 while true ; do
     case "$1" in
         -h|--help) usage ;;  # does not return
-        --python) PYTHON_BINARY="$2" ; shift ; shift ;;
+        --python) PYTHON_OPTION="--python=$2" ; shift ; shift ;;
         --) shift ; break ;;
         *) echo "Internal error" ; exit 1 ;;
     esac
@@ -58,7 +57,7 @@ if [ -z "$DIR" ] ; then
 fi
 rm -fr $DIR
 mkdir -p $DIR
-virtualenv --python $PYTHON_BINARY $DIR
+virtualenv $PYTHON_OPTION $DIR
 . $DIR/bin/activate
 
 if pip --help | grep -q disable-pip-version-check; then