File tree Expand file tree Collapse file tree 4 files changed +83
-5
lines changed Expand file tree Collapse file tree 4 files changed +83
-5
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,27 @@ Syntax::
204
204
* :ref: `scripts-premkvirtualenv `
205
205
* :ref: `scripts-postmkvirtualenv `
206
206
207
+ .. _command-allvirtualenv :
208
+
209
+ allvirtualenv
210
+ -------------
211
+
212
+ Run a command in all virtualenvs under WORKON_HOME.
213
+
214
+ Syntax::
215
+
216
+ allenvs command with arguments
217
+
218
+ Each virtualenv is activated, bypassing activation hooks, the current
219
+ working directory is changed to the current virtualenv, and then the
220
+ command is run. Commands cannot modify the current shell state, but
221
+ can modify the virtualenv.
222
+
223
+ ::
224
+
225
+ $ allenvs pip install -U pip
226
+
227
+
207
228
==================================
208
229
Controlling the Active Environment
209
230
==================================
Original file line number Diff line number Diff line change 15
15
:bbissue: `188 `.
16
16
- Fix detection of ``--python `` option to
17
17
:ref: `command-mkvirtualenv `. Resolves :bbissue: `190 `.
18
+ - Add :ref: `command-allvirtualenv ` command to run a command across all
19
+ virtualenvs. Suggested by Dave Coutts in :bbissue: `186 `.
18
20
19
21
4.0
20
22
===
Original file line number Diff line number Diff line change
1
+ # -*- mode: shell-script -*-
2
+
3
+ test_dir=$( cd $( dirname $0 ) && pwd)
4
+ source " $test_dir /setup.sh"
5
+
6
+ oneTimeSetUp () {
7
+ rm -rf " $WORKON_HOME "
8
+ mkdir -p " $WORKON_HOME "
9
+ unset VIRTUAL_ENV
10
+ source " $test_dir /../virtualenvwrapper.sh"
11
+ mkvirtualenv test1 > /dev/null 2>&1
12
+ mkvirtualenv test2 > /dev/null 2>&1
13
+ deactivate
14
+ }
15
+
16
+ oneTimeTearDown () {
17
+ rm -rf " $WORKON_HOME "
18
+ }
19
+
20
+ setUp () {
21
+ echo
22
+ rm -f " $test_dir /catch_output"
23
+ }
24
+
25
+ tearDown () {
26
+ deactivate > /dev/null 2>&1
27
+ }
28
+
29
+ test_allvirtualenv_all () {
30
+ assertTrue " Did not find test1" " allvirtualenv pwd | grep -q 'test1$'"
31
+ assertTrue " Did not find test2" " allvirtualenv pwd | grep -q 'test2$'"
32
+ }
33
+
34
+ . " $test_dir /shunit2"
Original file line number Diff line number Diff line change @@ -592,10 +592,11 @@ function lsvirtualenv {
592
592
593
593
if $long_mode
594
594
then
595
- for env_name in $( virtualenvwrapper_show_workon_options)
596
- do
597
- showvirtualenv " $env_name "
598
- done
595
+ allenvs showvirtualenv " $env_name "
596
+ # for env_name in $(virtualenvwrapper_show_workon_options)
597
+ # do
598
+
599
+ # done
599
600
else
600
601
virtualenvwrapper_show_workon_options
601
602
fi
@@ -616,7 +617,6 @@ function showvirtualenv {
616
617
env_name=$( basename " $VIRTUAL_ENV " )
617
618
fi
618
619
619
- echo -n " $env_name "
620
620
virtualenvwrapper_run_hook " get_env_details" " $env_name "
621
621
echo
622
622
}
@@ -1157,6 +1157,27 @@ function wipeenv {
1157
1157
rm -f " $req_file "
1158
1158
}
1159
1159
1160
+ #
1161
+ # Run a command in each virtualenv
1162
+ #
1163
+ function allvirtualenv {
1164
+ virtualenvwrapper_verify_workon_home || return 1
1165
+ typeset d
1166
+
1167
+ virtualenvwrapper_show_workon_options | while read d
1168
+ do
1169
+ [ ! -d " $WORKON_HOME /$d " ] && continue
1170
+ echo " $d "
1171
+ echo " $d " | sed ' s/./=/g'
1172
+ # Activate the environment, but not with workon
1173
+ # because we don't want to trigger any hooks.
1174
+ (source " $WORKON_HOME /$d /bin/activate" ;
1175
+ cd " $VIRTUAL_ENV " ;
1176
+ $@ )
1177
+ echo
1178
+ done
1179
+ }
1180
+
1160
1181
#
1161
1182
# Invoke the initialization functions
1162
1183
#
You can’t perform that action at this time.
0 commit comments