Skip to content

Commit 708da58

Browse files
committed
Activate Script
1 parent 7386b81 commit 708da58

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

mac/fix-mac-venv.sh

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,52 @@
11
#!/bin/bash
22

3-
chmod 777 ./pyvenv.cfg
4-
cat > ./pyvenv.cfg << EOF
5-
home = ./bin
3+
DIR="$(cd "$(dirname "$0")" && pwd)"
4+
RUNTIME_DIR="$DIR/../runtime"
5+
PYVENV_FILE="$RUNTIME_DIR/pyvenv.cfg"
6+
ACTIVATE_FILE="$RUNTIME_DIR/bin/activate"
7+
8+
mkdir -p "$RUNTIME_DIR/bin"
9+
10+
cat > "$PYVENV_FILE" << EOF
11+
home = $RUNTIME_DIR/bin
612
include-system-site-packages = false
713
version = 3.13.5
8-
executable = ./bin/python3.13
14+
executable = $RUNTIME_DIR/bin/python3.13
15+
EOF
16+
17+
cat > "$ACTIVATE_FILE" << 'EOF'
18+
# This file must be sourced. You cannot run it directly.
19+
20+
deactivate () {
21+
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
22+
PATH="$_OLD_VIRTUAL_PATH"
23+
export PATH
24+
unset _OLD_VIRTUAL_PATH
25+
fi
26+
27+
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
28+
PS1="$_OLD_VIRTUAL_PS1"
29+
export PS1
30+
unset _OLD_VIRTUAL_PS1
31+
fi
32+
33+
unset VIRTUAL_ENV
34+
if [ ! "$1" = "nondestructive" ] ; then
35+
unset -f deactivate
36+
fi
37+
}
38+
39+
VIRTUAL_ENV="$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd)"
40+
export VIRTUAL_ENV
41+
42+
_OLD_VIRTUAL_PATH="$PATH"
43+
PATH="$VIRTUAL_ENV/bin:$PATH"
44+
export PATH
45+
46+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
47+
_OLD_VIRTUAL_PS1="$PS1"
48+
PS1="($(basename "$VIRTUAL_ENV")) $PS1"
49+
export PS1
50+
fi
951
EOF
1052

0 commit comments

Comments
 (0)