mirror of
https://github.com/zardus/ctf-tools
synced 2024-12-13 14:32:34 +00:00
drop virtualenvwrapper dependency for ctf-tools-pip, which should make it portable accross ubuntu/arch
This commit is contained in:
parent
7f4cfe2c57
commit
368484543a
2 changed files with 19 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e -o pipefail
|
set -eu -o pipefail
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
# let's stick with python 2 as default
|
# let's stick with python 2 as default
|
||||||
|
@ -12,27 +12,32 @@ if [[ "$0" =~ pip2 ]]; then
|
||||||
PY_VERSION=2
|
PY_VERSION=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PY_INTERPRETER=$(which "python$PY_VERSION" || which python)
|
||||||
|
|
||||||
CTF_TOOLS_VE="ctftools"
|
CTF_TOOLS_VE="ctftools"
|
||||||
if [[ "PY_VERSION" -eq 3 ]]; then
|
if [[ $PY_VERSION -eq 3 ]]; then
|
||||||
CTF_TOOLS_VE="${CTF_TOOLS_VE}3"
|
CTF_TOOLS_VE="${CTF_TOOLS_VE}3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export WORKON_HOME=~/.virtualenvs
|
if [[ -z "${WORKON_HOME+x}" ]]; then
|
||||||
|
export WORKON_HOME="$HOME/.virtualenvs"
|
||||||
|
fi
|
||||||
if [[ ! -d "$WORKON_HOME" ]]; then
|
if [[ ! -d "$WORKON_HOME" ]]; then
|
||||||
mkdir -p "$WORKON_HOME"
|
mkdir -p "$WORKON_HOME"
|
||||||
fi
|
fi
|
||||||
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
|
|
||||||
|
|
||||||
source /etc/bash_completion.d/virtualenvwrapper \
|
VE_DIR="$WORKON_HOME/$CTF_TOOLS_VE"
|
||||||
|| source $(which virtualenvwrapper.sh)
|
|
||||||
|
|
||||||
if ! workon "$CTF_TOOLS_VE" 2>&1 1>/dev/null; then
|
if [[ ! -d "$VE_DIR" || ! -e "$VE_DIR/bin/activate" ]]; then
|
||||||
echo "#### Creating python#PY_VERSION virtualenv '$CTF_TOOLS_VE' ####" >&2
|
echo "#### Creating python$PY_VERSION virtualenv '$CTF_TOOLS_VE' ####" >&2
|
||||||
# for some reason mkvirtualenv returns non-zero even if it
|
virtualenv --system-site-packages -p "$PY_INTERPRETER" "$VE_DIR"
|
||||||
# succeeds?
|
fi
|
||||||
mkvirtualenv -p $(which "python$PY_VERSION") "$CTF_TOOLS_VE" || true
|
|
||||||
echo "#### Switching to '$CTF_TOOLS_VE' virtualenv" >&2
|
if [[ -z "${VIRTUAL_ENV+x}" || "$VIRTUAL_ENV" != "$VE_DIR" ]]; then
|
||||||
workon "$CTF_TOOLS_VE" || (deactivate && workon "$CTF_TOOLS_VE")
|
if [[ -n "${VIRTUAL_ENV+x}" ]]; then
|
||||||
|
deactivate
|
||||||
|
fi
|
||||||
|
source "$VE_DIR/bin/activate"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec pip "$@"
|
exec pip "$@"
|
||||||
|
|
|
@ -134,7 +134,7 @@ function base_build_setup()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create the py2 virtualenv
|
# create the py2 virtualenv
|
||||||
"$PWD/bin/ctf-tools-pip" freeze 2>&1 >/dev/null || true
|
"$PWD/bin/ctf-tools-pip" freeze 2>&1 >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue