VirtualEnv

Version 2.1 by David De La Harpe Golden on 2026/05/17 16:11

While historically I use python virtualenv helpers like 

...since virtualenv is now in the python stdlib, I have lately pared it down to two little helpers

  • mkve - makes a new basic virtualenv.
  • 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.


== mkve ==

{{code language="bash"}}
#!/bin/bash

if [ -e "$1" ] ; then
   echo >&2 "Already exists. Use python -m venv ... directly for complex args."
else
   exec python -m venv "$1"
fi
{{code}}

== ve ==

{{code language="bash"}}
#!/bin/bash

if [ -f "$1/bin/activate" ]; then
   exec bash --rcfile <(cat ~/.bashrc $1/bin/activate)
else
   echo >&2 "Missing Python Virtual Env (should have venv/bin/activate script)"
fi
{{code}}