|
18 | 18 | # source $(dirname $0)/../common/libbackend.sh
|
19 | 19 | #
|
20 | 20 | function init() {
|
| 21 | + # Name of the backend (directory name) |
21 | 22 | BACKEND_NAME=${PWD##*/}
|
| 23 | + |
| 24 | + # Path where all backends files are |
22 | 25 | MY_DIR=$(realpath `dirname $0`)
|
| 26 | + |
| 27 | + # Build type |
23 | 28 | BUILD_PROFILE=$(getBuildProfile)
|
24 | 29 |
|
| 30 | + # Environment directory |
| 31 | + EDIR=${MY_DIR} |
| 32 | + |
| 33 | + # Allow to specify a custom env dir for shared environments |
| 34 | + if [ "x${ENV_DIR}" != "x" ]; then |
| 35 | + EDIR=${ENV_DIR} |
| 36 | + fi |
| 37 | + |
25 | 38 | # If a backend has defined a list of valid build profiles...
|
26 | 39 | if [ ! -z "${LIMIT_TARGETS}" ]; then
|
27 | 40 | isValidTarget=$(checkTargets ${LIMIT_TARGETS})
|
@@ -74,13 +87,14 @@ function getBuildProfile() {
|
74 | 87 | # This function is idempotent, so you can call it as many times as you want and it will
|
75 | 88 | # always result in an activated virtual environment
|
76 | 89 | function ensureVenv() {
|
77 |
| - if [ ! -d "${MY_DIR}/venv" ]; then |
78 |
| - uv venv ${MY_DIR}/venv |
| 90 | + if [ ! -d "${EDIR}/venv" ]; then |
| 91 | + uv venv ${EDIR}/venv |
79 | 92 | echo "virtualenv created"
|
80 | 93 | fi
|
81 |
| - |
82 |
| - if [ "x${VIRTUAL_ENV}" != "x${MY_DIR}/venv" ]; then |
83 |
| - source ${MY_DIR}/venv/bin/activate |
| 94 | + |
| 95 | + # Source if we are not already in a Virtual env |
| 96 | + if [ "x${VIRTUAL_ENV}" != "x${EDIR}/venv" ]; then |
| 97 | + source ${EDIR}/venv/bin/activate |
84 | 98 | echo "virtualenv activated"
|
85 | 99 | fi
|
86 | 100 |
|
@@ -113,21 +127,25 @@ function installRequirements() {
|
113 | 127 |
|
114 | 128 | # These are the requirements files we will attempt to install, in order
|
115 | 129 | declare -a requirementFiles=(
|
116 |
| - "${MY_DIR}/requirements-install.txt" |
117 |
| - "${MY_DIR}/requirements.txt" |
118 |
| - "${MY_DIR}/requirements-${BUILD_TYPE}.txt" |
| 130 | + "${EDIR}/requirements-install.txt" |
| 131 | + "${EDIR}/requirements.txt" |
| 132 | + "${EDIR}/requirements-${BUILD_TYPE}.txt" |
119 | 133 | )
|
120 | 134 |
|
121 | 135 | if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
|
122 |
| - requirementFiles+=("${MY_DIR}/requirements-${BUILD_PROFILE}.txt") |
| 136 | + requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}.txt") |
123 | 137 | fi
|
124 | 138 |
|
125 | 139 | # if BUILD_TYPE is empty, we are a CPU build, so we should try to install the CPU requirements
|
126 | 140 | if [ "x${BUILD_TYPE}" == "x" ]; then
|
127 |
| - requirementFiles+=("${MY_DIR}/requirements-cpu.txt") |
| 141 | + requirementFiles+=("${EDIR}/requirements-cpu.txt") |
128 | 142 | fi
|
129 | 143 |
|
130 |
| - requirementFiles+=("${MY_DIR}/requirements-after.txt") |
| 144 | + requirementFiles+=("${EDIR}/requirements-after.txt") |
| 145 | + |
| 146 | + if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then |
| 147 | + requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}-after.txt") |
| 148 | + fi |
131 | 149 |
|
132 | 150 | for reqFile in ${requirementFiles[@]}; do
|
133 | 151 | if [ -f ${reqFile} ]; then
|
|
0 commit comments