Created
July 30, 2020 20:03
-
-
Save chr5tphr/c1a5c444533bdfc3b2c40622a875a12e to your computer and use it in GitHub Desktop.
Require/ install python virtual environment with flock to support concurrent calls.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
RETVAL=0 | |
VENV="${1:?"No path to virtual environment supplied!"}" | |
shift | |
exec 3>"${VENV}.lock" | |
if flock --exclusive --wait 180 3; then | |
if ! [ -d "$VENV" ]; then | |
virtualenv -p python3 "$VENV" && "${VENV}/bin/pip" install "$@" | |
fi | |
else | |
echo "Could not acquire lock!" >&2 | |
RETVAL=1 | |
fi | |
exec 3>&- | |
exit "$RETVAL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment