provision: Add option to specify python version.
This commit is contained in:
parent
a4d6c4700f
commit
735943379f
|
@ -24,7 +24,12 @@ This repository contains the source code for Zulip's PyPI packages:
|
||||||
4. Run:
|
4. Run:
|
||||||
```
|
```
|
||||||
./tools/provision
|
./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.
|
5. You should now be able to run all the tests within this virtualenv.
|
||||||
|
|
|
@ -1,15 +1,28 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
BASEDIR=$(dirname `dirname $0`)
|
BASEDIR=$(dirname `dirname $0`)
|
||||||
VENVDIR="zulip-api-py2-venv"
|
|
||||||
VENVEXECDIR="bin"
|
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
|
if [ ! -d "$BASEDIR/$VENVDIR" ]; then
|
||||||
virtualenv "$BASEDIR/$VENVDIR"
|
virtualenv $PYCUSTOMPATH_ARG "$BASEDIR/$VENVDIR"
|
||||||
echo "Virtualenv created."
|
echo "Virtualenv created."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VENVBINDIR="bin"
|
|
||||||
if [[ ! -d "$BASEDIR/$VENVDIR/$VENVEXECDIR" ]]; then
|
if [[ ! -d "$BASEDIR/$VENVDIR/$VENVEXECDIR" ]]; then
|
||||||
# POSIX compatibility layer and Linux environment emulation for Windows
|
# POSIX compatibility layer and Linux environment emulation for Windows
|
||||||
# Virtual uses /Scripts instead of /bin on Windows.
|
# Virtual uses /Scripts instead of /bin on Windows.
|
||||||
|
|
Loading…
Reference in a new issue