Wiki source code of VirtualEnv
Version 6.1 by David De La Harpe Golden on 2026/05/17 16:14
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
1.1 | 1 | While historically I use python virtualenv helpers like |
| 2 | |||
| 3 | * [[vex>>https://pypi.org/project/vex/]] | ||
| 4 | * [[virtualenvwrapper>>https://pypi.org/project/virtualenvwrapper/]] | ||
| 5 | * [[virtualenvwrapper-win>>https://pypi.org/project/virtualenvwrapper-win/]] | ||
| 6 | |||
| 7 | ...since virtualenv is now in the python stdlib, I have lately pared it down to two little helpers | ||
| 8 | |||
| 9 | * ##mkve## - makes a new basic virtualenv. | ||
![]() |
6.1 | 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. |
![]() |
1.1 | 11 | |
| 12 | {{code language="bash"}} | ||
![]() |
5.1 | 13 | $ mkve BlahVenv |
| 14 | $ ve BlahVenv | ||
| 15 | $ pip install av | ||
| 16 | $ exit | ||
| 17 | {{/code}} | ||
![]() |
1.1 | 18 | |
| 19 | |||
| 20 | == mkve == | ||
| 21 | |||
| 22 | {{code language="bash"}} | ||
| 23 | #!/bin/bash | ||
| 24 | |||
| 25 | if [ -e "$1" ] ; then | ||
| 26 | echo >&2 "Already exists. Use python -m venv ... directly for complex args." | ||
| 27 | else | ||
| 28 | exec python -m venv "$1" | ||
| 29 | fi | ||
| 30 | |||
![]() |
3.1 | 31 | {{/code}} |
| 32 | |||
![]() |
1.1 | 33 | |
![]() |
5.1 | 34 | == ve == |
![]() |
4.1 | 35 | |
![]() |
1.1 | 36 | {{code language="bash"}} |
![]() |
3.1 | 37 | |
![]() |
1.1 | 38 | #!/bin/bash |
| 39 | |||
| 40 | if [ -f "$1/bin/activate" ]; then | ||
| 41 | exec bash --rcfile <(cat ~/.bashrc $1/bin/activate) | ||
| 42 | else | ||
| 43 | echo >&2 "Missing Python Virtual Env (should have venv/bin/activate script)" | ||
| 44 | fi | ||
| 45 | |||
![]() |
3.1 | 46 | {{/code}} |
![]() |
1.1 | 47 | |
| 48 | |||
![]() |
3.1 | 49 |
