Merge pull request #82 from zardus/wip/venv

Wip/venv
This commit is contained in:
Yan 2016-10-11 02:51:59 -07:00 committed by GitHub
commit a6ca3ef34a
3 changed files with 44 additions and 43 deletions

View file

@ -1,10 +1,6 @@
#!/bin/bash -e
if [ -z "$VIRTUAL_ENV" ]
then
echo "Please activate the ctftools virtualenv before installing angr."
exit
fi
source ctf-tools-venv-activate
#[ -e $VIRTUAL_ENV/lib/python2.7/site-packages/PyQt4 ] || ln -s /usr/lib/python2.7/dist-packages/PyQt4 $VIRTUAL_ENV/lib/python2.7/site-packages/
#[ -e $VIRTUAL_ENV/lib/python2.7/site-packages/sip.so ] || ln -s /usr/lib/python2.7/dist-packages/sip.so $VIRTUAL_ENV/lib/python2.7/site-packages/

View file

@ -2,43 +2,8 @@
set -e -o pipefail
#set -x
# let's stick with python 2 as default
PY_VERSION=2
# check this scripts file ending
if [[ "$0" =~ pip3 ]]; then
PY_VERSION=3
fi
if [[ "$0" =~ pip2 ]]; then
PY_VERSION=2
fi
PY_INTERPRETER=$(which "python$PY_VERSION" || which python)
CTF_TOOLS_VE="ctftools"
if [[ $PY_VERSION -eq 3 ]]; then
CTF_TOOLS_VE="${CTF_TOOLS_VE}3"
fi
if [[ -z "${WORKON_HOME+x}" ]]; then
export WORKON_HOME="$HOME/.virtualenvs"
fi
if [[ ! -d "$WORKON_HOME" ]]; then
mkdir -p "$WORKON_HOME"
fi
VE_DIR="$WORKON_HOME/$CTF_TOOLS_VE"
if [[ ! -d "$VE_DIR" || ! -e "$VE_DIR/bin/activate" ]]; then
echo "#### Creating python$PY_VERSION virtualenv '$CTF_TOOLS_VE' ####" >&2
virtualenv --system-site-packages -p "$PY_INTERPRETER" "$VE_DIR"
fi
if [[ -z "${VIRTUAL_ENV+x}" || "$VIRTUAL_ENV" != "$VE_DIR" ]]; then
if [[ -n "${VIRTUAL_ENV+x}" ]]; then
source ${VIRTUAL_ENV}/bin/activate
deactivate
fi
source "$VE_DIR/bin/activate"
fi
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-which-directory-it-is-stored-in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/ctf-tools-venv-activate
exec pip "$@"

40
bin/ctf-tools-venv-activate Executable file
View file

@ -0,0 +1,40 @@
#!/bin/bash
# let's stick with python 2 as default
PY_VERSION=2
# check this scripts file ending
if [[ "$0" =~ pip3 ]]; then
PY_VERSION=3
fi
if [[ "$0" =~ pip2 ]]; then
PY_VERSION=2
fi
PY_INTERPRETER=$(which "python$PY_VERSION" || which python)
CTF_TOOLS_VE="ctftools"
if [[ $PY_VERSION -eq 3 ]]; then
CTF_TOOLS_VE="${CTF_TOOLS_VE}3"
fi
if [[ -z "${WORKON_HOME+x}" ]]; then
export WORKON_HOME="$HOME/.virtualenvs"
fi
if [[ ! -d "$WORKON_HOME" ]]; then
mkdir -p "$WORKON_HOME"
fi
VE_DIR="$WORKON_HOME/$CTF_TOOLS_VE"
if [[ ! -d "$VE_DIR" || ! -e "$VE_DIR/bin/activate" ]]; then
echo "#### Creating python$PY_VERSION virtualenv '$CTF_TOOLS_VE' ####" >&2
virtualenv --system-site-packages -p "$PY_INTERPRETER" "$VE_DIR"
fi
if [[ -z "${VIRTUAL_ENV+x}" || "$VIRTUAL_ENV" != "$VE_DIR" ]]; then
if [[ -n "${VIRTUAL_ENV+x}" ]]; then
source ${VIRTUAL_ENV}/bin/activate
deactivate
fi
source "$VE_DIR/bin/activate"
fi