Skip to content

Commit b952f57

Browse files
committed
Merge pull request #169 from puhitaku/verbose_env
Suppress activate/deactivate messages by default
2 parents 23f7027 + 62e32f9 commit b952f57

6 files changed

+12
-29
lines changed

bin/pyenv-sh-activate

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ fi
138138

139139
pyenv-sh-deactivate --force --quiet ${VERBOSE+--verbose} || true
140140

141-
echo "pyenv-virtualenv: activate ${venv}" 1>&2
141+
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
142+
echo "pyenv-virtualenv: activate ${venv}" 1>&2
143+
fi
142144

143145
if [ -z "$no_shell" ]; then
144146
# shell version set in pyenv-sh-activate should be unset

bin/pyenv-sh-deactivate

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ else
5858
venv="${prefix##*/}"
5959
fi
6060

61-
echo "pyenv-virtualenv: deactivate ${venv}" 1>&2
61+
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
62+
echo "pyenv-virtualenv: deactivate ${venv}" 1>&2
63+
fi
6264

6365
if [ -n "${PYENV_ACTIVATE_SHELL}" ]; then
6466
# shell version set in pyenv-sh-activate should be unset

test/activate.bats

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ setup() {
1111
unset CONDA_DEFAULT_ENV
1212
unset PYTHONHOME
1313
unset _OLD_VIRTUAL_PYTHONHOME
14+
unset PYENV_VIRTUALENV_VERBOSE_ACTIVATE
1415
unset PYENV_VIRTUALENV_DISABLE_PROMPT
1516
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
1617
unset VIRTUAL_ENV_DISABLE_PROMPT
@@ -30,7 +31,6 @@ setup() {
3031
assert_success
3132
assert_output <<EOS
3233
deactivated
33-
pyenv-virtualenv: activate venv
3434
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
3535
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
3636
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
@@ -46,6 +46,7 @@ EOS
4646

4747
@test "activate virtualenv from current version (verbose)" {
4848
export PYENV_VIRTUALENV_INIT=1
49+
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
4950

5051
stub pyenv-version-name "echo venv"
5152
stub pyenv-virtualenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
@@ -84,7 +85,6 @@ EOS
8485
assert_success
8586
assert_output <<EOS
8687
deactivated
87-
pyenv-virtualenv: activate venv
8888
export PYENV_VERSION="venv";
8989
export PYENV_ACTIVATE_SHELL=1;
9090
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
@@ -113,7 +113,6 @@ EOS
113113
assert_success
114114
assert_output <<EOS
115115
deactivated
116-
pyenv-virtualenv: activate venv
117116
setenv PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
118117
setenv VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
119118
pyenv-virtualenv: prompt changing not working for fish.
@@ -138,7 +137,6 @@ EOS
138137
assert_success
139138
assert_output <<EOS
140139
deactivated
141-
pyenv-virtualenv: activate venv
142140
setenv PYENV_VERSION "venv";
143141
setenv PYENV_ACTIVATE_SHELL 1;
144142
setenv PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
@@ -164,7 +162,6 @@ EOS
164162
assert_success
165163
assert_output <<EOS
166164
deactivated
167-
pyenv-virtualenv: activate venv27
168165
export PYENV_VERSION="venv27";
169166
export PYENV_ACTIVATE_SHELL=1;
170167
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
@@ -191,7 +188,6 @@ EOS
191188
assert_success
192189
assert_output <<EOS
193190
deactivated
194-
pyenv-virtualenv: activate venv27
195191
export PYENV_VERSION="venv27";
196192
export PYENV_ACTIVATE_SHELL=1;
197193
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
@@ -218,7 +214,6 @@ EOS
218214
assert_success
219215
assert_output <<EOS
220216
deactivated
221-
pyenv-virtualenv: activate venv27
222217
setenv PYENV_VERSION "venv27";
223218
setenv PYENV_ACTIVATE_SHELL 1;
224219
setenv PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
@@ -243,7 +238,6 @@ EOS
243238
assert_success
244239
assert_output <<EOS
245240
deactivated
246-
pyenv-virtualenv: activate venv27
247241
setenv PYENV_VERSION "venv27";
248242
setenv PYENV_ACTIVATE_SHELL 1;
249243
setenv PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
@@ -367,7 +361,6 @@ EOS
367361
assert_success
368362
assert_output <<EOS
369363
deactivated
370-
pyenv-virtualenv: activate venv27
371364
export PYENV_VERSION="venv27:2.7.10";
372365
export PYENV_ACTIVATE_SHELL=1;
373366
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";

test/conda-activate.bats

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ setup() {
1212
unset CONDA_DEFAULT_ENV
1313
unset PYTHONHOME
1414
unset _OLD_VIRTUAL_PYTHONHOME
15+
unset PYENV_VIRTUALENV_VERBOSE_ACTIVATE
1516
unset PYENV_VIRTUALENV_DISABLE_PROMPT
1617
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
1718
unset VIRTUAL_ENV_DISABLE_PROMPT
@@ -32,7 +33,6 @@ setup() {
3233
assert_success
3334
assert_output <<EOS
3435
deactivated
35-
pyenv-virtualenv: activate anaconda-2.3.0
3636
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0";
3737
export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0";
3838
export CONDA_DEFAULT_ENV="root";
@@ -62,7 +62,6 @@ EOS
6262
assert_success
6363
assert_output <<EOS
6464
deactivated
65-
pyenv-virtualenv: activate anaconda-2.3.0
6665
setenv PYENV_VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
6766
setenv VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
6867
setenv CONDA_DEFAULT_ENV "root";
@@ -90,7 +89,6 @@ EOS
9089
assert_success
9190
assert_output <<EOS
9291
deactivated
93-
pyenv-virtualenv: activate miniconda-3.9.1
9492
export PYENV_VERSION="miniconda-3.9.1";
9593
export PYENV_ACTIVATE_SHELL=1;
9694
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1";
@@ -122,7 +120,6 @@ EOS
122120
assert_success
123121
assert_output <<EOS
124122
deactivated
125-
pyenv-virtualenv: activate anaconda-2.3.0/envs/foo
126123
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo";
127124
export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo";
128125
export CONDA_DEFAULT_ENV="foo";
@@ -152,7 +149,6 @@ EOS
152149
assert_success
153150
assert_output <<EOS
154151
deactivated
155-
pyenv-virtualenv: activate miniconda-3.9.1/envs/bar
156152
export PYENV_VERSION="miniconda-3.9.1/envs/bar";
157153
export PYENV_ACTIVATE_SHELL=1;
158154
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar";

test/conda-deactivate.bats

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ setup() {
1111
unset CONDA_DEFAULT_ENV
1212
unset PYTHONHOME
1313
unset _OLD_VIRTUAL_PYTHONHOME
14+
unset PYENV_VIRTUALENV_VERBOSE_ACTIVATE
1415
unset PYENV_VIRTUALENV_DISABLE_PROMPT
1516
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
1617
unset VIRTUAL_ENV_DISABLE_PROMPT
@@ -29,7 +30,6 @@ setup() {
2930

3031
assert_success
3132
assert_output <<EOS
32-
pyenv-virtualenv: deactivate anaconda-2.3.0
3333
unset PYENV_VIRTUAL_ENV;
3434
unset VIRTUAL_ENV;
3535
unset CONDA_DEFAULT_ENV;
@@ -65,7 +65,6 @@ EOS
6565

6666
assert_success
6767
assert_output <<EOS
68-
pyenv-virtualenv: deactivate anaconda-2.3.0
6968
set -e PYENV_VIRTUAL_ENV;
7069
set -e VIRTUAL_ENV;
7170
set -e CONDA_DEFAULT_ENV;
@@ -97,7 +96,6 @@ EOS
9796

9897
assert_success
9998
assert_output <<EOS
100-
pyenv-virtualenv: deactivate anaconda-2.3.0/envs/foo
10199
unset PYENV_VIRTUAL_ENV;
102100
unset VIRTUAL_ENV;
103101
unset CONDA_DEFAULT_ENV;

test/deactivate.bats

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ setup() {
1111
unset CONDA_DEFAULT_ENV
1212
unset PYTHONHOME
1313
unset _OLD_VIRTUAL_PYTHONHOME
14+
unset PYENV_VIRTUALENV_VERBOSE_ACTIVATE
1415
unset PYENV_VIRTUALENV_DISABLE_PROMPT
1516
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
1617
unset VIRTUAL_ENV_DISABLE_PROMPT
@@ -27,7 +28,6 @@ setup() {
2728

2829
assert_success
2930
assert_output <<EOS
30-
pyenv-virtualenv: deactivate venv
3131
unset PYENV_VIRTUAL_ENV;
3232
unset VIRTUAL_ENV;
3333
if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then
@@ -53,6 +53,7 @@ EOS
5353
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
5454
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
5555
export PYENV_ACTIVATE_SHELL=
56+
export PYENV_VIRTUALENV_VERBOSE_ACTIVATE=1
5657

5758
PYENV_SHELL="bash" run pyenv-sh-deactivate --verbose
5859

@@ -89,7 +90,6 @@ EOS
8990

9091
assert_success
9192
assert_output <<EOS
92-
pyenv-virtualenv: deactivate venv
9393
unset PYENV_VIRTUAL_ENV;
9494
unset VIRTUAL_ENV;
9595
if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then
@@ -120,7 +120,6 @@ EOS
120120

121121
assert_success
122122
assert_output <<EOS
123-
pyenv-virtualenv: deactivate venv
124123
unset PYENV_VERSION;
125124
unset PYENV_ACTIVATE_SHELL;
126125
unset PYENV_VIRTUAL_ENV;
@@ -153,7 +152,6 @@ EOS
153152

154153
assert_success
155154
assert_output <<EOS
156-
pyenv-virtualenv: deactivate venv
157155
unset PYENV_VERSION;
158156
unset PYENV_ACTIVATE_SHELL;
159157
unset PYENV_VIRTUAL_ENV;
@@ -186,7 +184,6 @@ EOS
186184

187185
assert_success
188186
assert_output <<EOS
189-
pyenv-virtualenv: deactivate venv
190187
unset PYENV_VIRTUAL_ENV;
191188
unset VIRTUAL_ENV;
192189
if [ -n "\${_OLD_VIRTUAL_PATH}" ]; then
@@ -217,7 +214,6 @@ EOS
217214

218215
assert_success
219216
assert_output <<EOS
220-
pyenv-virtualenv: deactivate venv
221217
set -e PYENV_VIRTUAL_ENV;
222218
set -e VIRTUAL_ENV;
223219
if [ -n "\$_OLD_VIRTUAL_PATH" ];
@@ -244,7 +240,6 @@ EOS
244240

245241
assert_success
246242
assert_output <<EOS
247-
pyenv-virtualenv: deactivate venv
248243
set -e PYENV_VIRTUAL_ENV;
249244
set -e VIRTUAL_ENV;
250245
if [ -n "\$_OLD_VIRTUAL_PATH" ];
@@ -271,7 +266,6 @@ EOS
271266

272267
assert_success
273268
assert_output <<EOS
274-
pyenv-virtualenv: deactivate venv
275269
set -e PYENV_VERSION;
276270
set -e PYENV_ACTIVATE_SHELL;
277271
set -e PYENV_VIRTUAL_ENV;
@@ -300,7 +294,6 @@ EOS
300294

301295
assert_success
302296
assert_output <<EOS
303-
pyenv-virtualenv: deactivate venv
304297
set -e PYENV_VERSION;
305298
set -e PYENV_ACTIVATE_SHELL;
306299
set -e PYENV_VIRTUAL_ENV;
@@ -329,7 +322,6 @@ EOS
329322

330323
assert_success
331324
assert_output <<EOS
332-
pyenv-virtualenv: deactivate venv
333325
set -e PYENV_VIRTUAL_ENV;
334326
set -e VIRTUAL_ENV;
335327
if [ -n "\$_OLD_VIRTUAL_PATH" ];

0 commit comments

Comments
 (0)