mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-14 06:23:52 -05:00
Display error if pyenv activate was invoked as a command
This commit is contained in:
26
bin/pyenv-activate
Executable file
26
bin/pyenv-activate
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Summary: Activate virtual environment
|
||||||
|
#
|
||||||
|
# Usage: pyenv activate <virtualenv>
|
||||||
|
# pyenv activate --unset
|
||||||
|
#
|
||||||
|
# Activate a Python virtualenv environment in current shell.
|
||||||
|
# This acts almost as same as `pyenv shell`, but this invokes the `activate`
|
||||||
|
# script in your shell.
|
||||||
|
#
|
||||||
|
# <virtualenv> should be a string matching a Python version known to pyenv.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
{ printf "\x1B[31;1m"
|
||||||
|
echo
|
||||||
|
echo "Failed to activate virtualenv."
|
||||||
|
echo
|
||||||
|
echo "Perhaps pyenv-virtualenv has not been loaded into your shell properly."
|
||||||
|
echo "Please restart current shell and try again."
|
||||||
|
echo
|
||||||
|
printf "\x1B[0m"
|
||||||
|
} 1>&2
|
||||||
|
exit 1
|
||||||
21
bin/pyenv-deactivate
Executable file
21
bin/pyenv-deactivate
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Summary: Deactivate virtual environment
|
||||||
|
#
|
||||||
|
# Usage: pyenv deactivate
|
||||||
|
#
|
||||||
|
# Deactivate a Python virtual environment.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
{ printf "\x1B[31;1m"
|
||||||
|
echo
|
||||||
|
echo "Failed to deactivate virtualenv."
|
||||||
|
echo
|
||||||
|
echo "Perhaps pyenv-virtualenv has not been loaded into your shell properly."
|
||||||
|
echo "Please restart current shell and try again."
|
||||||
|
echo
|
||||||
|
printf "\x1B[0m"
|
||||||
|
} 1>&2
|
||||||
|
exit 1
|
||||||
@@ -85,3 +85,9 @@ EOS
|
|||||||
pyenv-virtualenv: cannot activate multiple versions at once: venv venv27
|
pyenv-virtualenv: cannot activate multiple versions at once: venv venv27
|
||||||
EOS
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "should fail if activate is invoked as a command" {
|
||||||
|
run pyenv-activate
|
||||||
|
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,3 +25,9 @@ functions -q deactivate; and deactivate
|
|||||||
pyenv shell --unset
|
pyenv shell --unset
|
||||||
EOS
|
EOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "should fail if deactivate is invoked as a command" {
|
||||||
|
run pyenv-deactivate
|
||||||
|
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user