provision: Add option to specify python version.

This commit is contained in:
derAnfaenger 2017-08-18 14:13:33 +02:00 committed by Tim Abbott
parent a4d6c4700f
commit 735943379f
2 changed files with 23 additions and 5 deletions

View file

@ -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.

View file

@ -1,15 +1,28 @@
#!/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.