Skip to content

Commit d72af2c

Browse files
authored
modifications to account for running script in General Translation agent environment
1 parent 60565be commit d72af2c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

scripts/autogenerate-table-of-contents.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set +e
1010

1111
# Function to cleanup on exit
1212
cleanup() {
13-
if [ -d "venv" ]; then
13+
if [ "$USE_VENV" = true ]; then
1414
deactivate 2>/dev/null || true
1515
rm -rf venv
1616
fi
@@ -19,14 +19,29 @@ cleanup() {
1919
# Set trap to cleanup on exit (success or failure)
2020
trap cleanup EXIT
2121

22-
# Check if virtual environment exists
22+
USE_VENV=false
23+
24+
# Try to create a venv, if that fails fall back to installing packages
2325
if [ ! -d "venv" ]; then
2426
echo "Creating virtual environment..."
25-
python3 -m venv venv
27+
if python3 -m venv venv 2>/tmp/venv_err.log; then
28+
USE_VENV=true
29+
else
30+
echo "Warning: could not create venv, falling back to user site-packages."
31+
cat /tmp/venv_err.log
32+
rm -rf venv
33+
fi
34+
else
35+
USE_VENV=true
2636
fi
2737

28-
source venv/bin/activate
29-
pip install -r scripts/table-of-contents-generator/requirements.txt
38+
if [ "$USE_VENV" = true ]; then
39+
. venv/bin/activate
40+
pip install -r scripts/table-of-contents-generator/requirements.txt
41+
else
42+
# No working venv, install deps
43+
python3 -m pip install --user -r scripts/table-of-contents-generator/requirements.txt
44+
fi
3045

3146
# Define all TOC generation commands
3247
COMMANDS=(

0 commit comments

Comments
 (0)