provision: Add option to specify python version.
MODIFY
README.md
README.md
@@ -24,7 +24,12 @@ This repository contains the source code for Zulip's PyPI packages:
4. Run:
```
./tools/provision
- source ./zulip-api-py2-venv/bin/activate
+ ```
+ This sets up a virtual Python environment in `zulip-api-py<your_python_version>-venv`,
+ where `<your_python_version>` is your default version of Python. If you would like to specify
+ a different Python version, run
+ ```
+ ./tools/provision -p <path_to_your_python_version>`
```
5. You should now be able to run all the tests within this virtualenv.

MODIFY
tools/provision
tools/provision
-#!/bin/bash
+#!/usr/bin/env bash
BASEDIR=$(dirname `dirname $0`)
-VENVDIR="zulip-api-py2-venv"
VENVEXECDIR="bin"
+PYVERSION=$(python -V | grep -Po '(?<=Python ).+')
+PYCUSTOMPATH_ARG=""
+while getopts "hp:" arg; do
+ case "$arg" in
+ h)
+ echo "USAGE: $0 [-p <path_to_python_version>]"
+ exit
+ ;;
+ p)
+ PYCUSTOMPATH_ARG="-p $OPTARG"
+ PYVERSION=$("$OPTARG" "-V" 2>&1 | grep -Po '(?<=Python ).+')
+ ;;
+ esac
+done
+VENVDIR="zulip-api-py$PYVERSION-venv"
if [ ! -d "$BASEDIR/$VENVDIR" ]; then
- virtualenv "$BASEDIR/$VENVDIR"
+ virtualenv $PYCUSTOMPATH_ARG "$BASEDIR/$VENVDIR"
echo "Virtualenv created."
fi
-VENVBINDIR="bin"
if [[ ! -d "$BASEDIR/$VENVDIR/$VENVEXECDIR" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
# Virtual uses /Scripts instead of /bin on Windows.

provision: Add option to specify python version.