diff --git a/README.md b/README.md index 9cff135..f1cddc9 100644 --- a/README.md +++ b/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-venv`, + where `` is your default version of Python. If you would like to specify + a different Python version, run + ``` + ./tools/provision -p ` ``` 5. You should now be able to run all the tests within this virtualenv. diff --git a/tools/provision b/tools/provision index be591ec..a36e671 100755 --- a/tools/provision +++ b/tools/provision @@ -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 ]" + 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.