Skip to content

Commit b6fd49d

Browse files
committed
Custom pyvenv.cfg
1 parent 1896002 commit b6fd49d

File tree

1 file changed

+6
-33
lines changed

1 file changed

+6
-33
lines changed

mac/fix-mac-venv.sh

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
11
#!/bin/bash
22

3-
# Get absolute path of the current directory
4-
VENV_DIR="./runtime"
5-
NEW_VENV_PATH="$(cd "$VENV_DIR" && pwd)"
6-
PYTHON_BIN="$NEW_VENV_PATH/bin/python3"
3+
cat > ./pyvenv.cfg << EOF
4+
home = ./bin
5+
include-system-site-packages = false
6+
version = 3.13.5
7+
executable = ./bin/python3.13
8+
EOF
79

8-
echo "🔧 Updating venv paths to: $NEW_VENV_PATH"
9-
10-
# 1. Patch pyvenv.cfg
11-
if [ -f "$VENV_DIR/pyvenv.cfg" ]; then
12-
echo "✅ Patching pyvenv.cfg"
13-
sed -i '' "s|^home = .*|home = $NEW_VENV_PATH/bin/python3|" "$VENV_DIR/pyvenv.cfg"
14-
fi
15-
16-
# 2. Patch activate scripts
17-
for f in "$VENV_DIR"/bin/activate*; do
18-
if [[ -f "$f" ]]; then
19-
echo "✅ Patching $f"
20-
sed -i '' "s|^VIRTUAL_ENV=.*|VIRTUAL_ENV=\"$NEW_VENV_PATH\"|" "$f"
21-
fi
22-
done
23-
24-
# 3. Patch shebangs in bin scripts (e.g., pip, flask)
25-
echo "✅ Patching shebangs in venv/bin/*"
26-
for f in "$VENV_DIR"/bin/*; do
27-
if head -1 "$f" | grep -q "^#\!.*python"; then
28-
sed -i '' "1 s|^#!.*python.*|#!$PYTHON_BIN|" "$f"
29-
fi
30-
done
31-
32-
# 4. Optional: clean .pyc files (they sometimes cache paths)
33-
echo "🧹 Deleting stale .pyc files"
34-
find "$VENV_DIR" -name "*.pyc" -delete
35-
36-
echo "🎉 Done. Your venv is now patched for: $NEW_VENV_PATH"

0 commit comments

Comments
 (0)