Skip to content

Commit 66cf38b

Browse files
authored
feat(venv): shared env (#3195)
* feat(venv): allow to share veenvs Signed-off-by: Ettore Di Giacinto <[email protected]> * fix(vllm): add back flash-attn Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 11b2ada commit 66cf38b

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

backend/python/common/libbackend.sh

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,23 @@
1818
# source $(dirname $0)/../common/libbackend.sh
1919
#
2020
function init() {
21+
# Name of the backend (directory name)
2122
BACKEND_NAME=${PWD##*/}
23+
24+
# Path where all backends files are
2225
MY_DIR=$(realpath `dirname $0`)
26+
27+
# Build type
2328
BUILD_PROFILE=$(getBuildProfile)
2429

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+
2538
# If a backend has defined a list of valid build profiles...
2639
if [ ! -z "${LIMIT_TARGETS}" ]; then
2740
isValidTarget=$(checkTargets ${LIMIT_TARGETS})
@@ -74,13 +87,14 @@ function getBuildProfile() {
7487
# This function is idempotent, so you can call it as many times as you want and it will
7588
# always result in an activated virtual environment
7689
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
7992
echo "virtualenv created"
8093
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
8498
echo "virtualenv activated"
8599
fi
86100

@@ -113,21 +127,25 @@ function installRequirements() {
113127

114128
# These are the requirements files we will attempt to install, in order
115129
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"
119133
)
120134

121135
if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
122-
requirementFiles+=("${MY_DIR}/requirements-${BUILD_PROFILE}.txt")
136+
requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}.txt")
123137
fi
124138

125139
# if BUILD_TYPE is empty, we are a CPU build, so we should try to install the CPU requirements
126140
if [ "x${BUILD_TYPE}" == "x" ]; then
127-
requirementFiles+=("${MY_DIR}/requirements-cpu.txt")
141+
requirementFiles+=("${EDIR}/requirements-cpu.txt")
128142
fi
129143

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
131149

132150
for reqFile in ${requirementFiles[@]}; do
133151
if [ -f ${reqFile} ]; then
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flash-attn
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flash-attn

0 commit comments

Comments
 (0)