Changes for page VirtualEnv

Last modified by David De La Harpe Golden on 2026/05/17 17:37

From version 3.1
edited by David De La Harpe Golden
on 2026/05/17 16:12
Change comment: There is no comment for this version
To version 8.1
edited by David De La Harpe Golden
on 2026/05/17 16:17
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -7,9 +7,14 @@
7 7  ...since virtualenv is now in the python stdlib, I have lately pared it down to two little helpers
8 8  
9 9  * ##mkve## - makes a new basic virtualenv.
10 -* ##ve## - launches a subshell with the virtualenv active - in contrast to the weird way official activate does it your _current_ shell i.e like vex but less fancy.
10 +* ##ve## - launches a subshell with the virtualenv active - in contrast to the weird way official activate does within the current shell i.e like ##vex## but less fancy.
11 11  
12 12  {{code language="bash"}}
13 +$ mkve BlahVenv
14 +$ ve BlahVenv
15 +$ pip install av
16 +$ exit
17 +{{/code}}
13 13  
14 14  
15 15  == mkve ==
... ... @@ -16,6 +16,8 @@
16 16  
17 17  {{code language="bash"}}
18 18  #!/bin/bash
24 +# make a new python venv:
25 +# mkve SomeVenv
19 19  
20 20  if [ -e "$1" ] ; then
21 21   echo >&2 "Already exists. Use python -m venv ... directly for complex args."
... ... @@ -25,11 +25,14 @@
25 25  
26 26  {{/code}}
27 27  
35 +
28 28  == ve ==
29 29  
30 30  {{code language="bash"}}
31 31  
32 32  #!/bin/bash
41 +# use an existing python venv in a subshell, exit to exit:
42 +# ve SomeVenv
33 33  
34 34  if [ -f "$1/bin/activate" ]; then
35 35   exec bash --rcfile <(cat ~/.bashrc $1/bin/activate)
... ... @@ -40,4 +40,15 @@
40 40  {{/code}}
41 41  
42 42  
53 +== Shell Prompt ==
43 43  
55 +I have a fancy non-default prompt in my ##~/.bashrc## that shows a little snake if in a python vm
56 +
57 +{{code language="bash"}}
58 +# venvs themselves prefix these days, new ones created by stdlib honor this disable, allowing us to customize
59 +export VIRTUAL_ENV_DISABLE_PROMPT=1
60 +PS1='${debian_chroot:+\[\033[01;33m\]🌲($debian_chroot)\[\033[00m\]}${VIRTUAL_ENV:+\[\033[01;36m\]🐍($(basename $VIRTUAL_ENV))\[\033[00m\]}\[\033[38;5;108m\]\u@\h\[\033[38;5;128m\]:\[\033[38;5;139m\]\w\[\033[38;5;129m\]\$\[\033[00m\] '
61 +{{/code}}
62 +
63 +
64 +