forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirtualenv
executable file
·40 lines (32 loc) · 1.48 KB
/
virtualenv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
# Wrapper for self-bootstrapping virtualenv
set -e
VIRTUALENV_VERSION=16.6.2
VIRTUALENV_PACKAGE_LOCATION=${VIRTUALENV_PACKAGE_LOCATION:-https://pypi.io/packages/source/v/virtualenv}
REPO_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && git rev-parse --show-toplevel)
# shellcheck source=build-support/common.sh
source "${REPO_ROOT}/build-support/common.sh"
# Locate the binary's path to log to user or die gracefully if not found.
if command -v "${PY}" >/dev/null; then
PY="$(command -v "${PY}")"
else
die "No ${PY} interpreter found on the path. Python will not work!"
fi
log "Using python at ${PY}"
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
if ! [ -f "${HERE}/virtualenv.dist/BOOTSTRAPPED-${VIRTUALENV_VERSION}" ]; then
pushd "${HERE}" >/dev/null
VIRTUALENV_PACKAGE_FULL_URL="${VIRTUALENV_PACKAGE_LOCATION}/virtualenv-${VIRTUALENV_VERSION}.tar.gz"
log "Downloading ${VIRTUALENV_PACKAGE_FULL_URL}..."
curl -#L -O "${VIRTUALENV_PACKAGE_FULL_URL}" || \
die "Failed to download ${VIRTUALENV_PACKAGE_FULL_URL}."
rm -rf virtualenv-${VIRTUALENV_VERSION}
tar zxf virtualenv-${VIRTUALENV_VERSION}.tar.gz || \
die "Failed to extract ${VIRTUALENV_PACKAGE_FULL_URL}."
# TODO(ksweeney): Checksum
touch virtualenv-${VIRTUALENV_VERSION}/BOOTSTRAPPED-${VIRTUALENV_VERSION} && \
rm -rf virtualenv.dist && \
mv -f virtualenv-${VIRTUALENV_VERSION} virtualenv.dist
popd >/dev/null
fi
exec "${PY}" "${HERE}/virtualenv.dist/virtualenv.py" "$@"