forked from twitter/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpants_venv
executable file
·57 lines (46 loc) · 1.61 KB
/
pants_venv
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
REPO_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}") && cd .. && pwd -P)
source ${REPO_ROOT}/build-support/common.sh
REQUIREMENTS=(
${REPO_ROOT}/3rdparty/python/requirements.txt
${REPO_ROOT}/3rdparty/python/twitter/commons/requirements.txt
${REPO_ROOT}/pants-plugins/3rdparty/python/requirements.txt
)
function venv_dir() {
echo ${REPO_ROOT}/build-support/pants_dev_deps.venv
}
function activate_venv() {
source "$(venv_dir)/bin/activate"
}
function create_venv() {
rm -rf "$(venv_dir)"
"${REPO_ROOT}/build-support/virtualenv" "$(venv_dir)"
}
function activate_pants_venv() {
fingerprint=""
for req in ${REQUIREMENTS[@]}; do
fingerprint="${fingerprint}$(cat ${req} | fingerprint_data)"
done
fingerprint=$(echo "${fingerprint}" | fingerprint_data)
BOOTSTRAPPED_FILE="$(venv_dir)/BOOTSTRAPPED.${fingerprint}"
if ! [ -f ${BOOTSTRAPPED_FILE} ]; then
log "Bootstrapping pants_deps with requirements:"
# Use -f ${REPO_ROOT}/third_party if patching in local dependencies like so
# pip_extra="-f ${REPO_ROOT}/third_party"
pip_extra=""
for req in ${REQUIREMENTS[@]}; do
log " ${req}"
done
create_venv || die "Failed to create venv."
activate_venv || die "Failed to activate venv."
for req in ${REQUIREMENTS[@]}; do
pip install ${pip_extra} -r "${req}" || \
die "Failed to install requirements from ${req}."
done
touch "${BOOTSTRAPPED_FILE}"
else
activate_venv || die "Failed to activate venv."
fi
}