mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-09 12:03:55 -05:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b90bd92853 | ||
|
|
33f54ecad9 | ||
|
|
f8469a1c67 | ||
|
|
ac28398fc0 | ||
|
|
45a28ac094 | ||
|
|
0f83c33a3b | ||
|
|
2b2b87a25a | ||
|
|
38a6561f96 | ||
|
|
c85c1c9ed5 | ||
|
|
cd6a51ad68 | ||
|
|
85d8c5aabf | ||
|
|
fca12418ca | ||
|
|
13bc1877ef | ||
|
|
a724aaa149 | ||
|
|
f4162706d8 | ||
|
|
77a7644ff7 | ||
|
|
826f3fbe6f |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
|
|||||||
liberapay: # Replace with a single Liberapay username
|
liberapay: # Replace with a single Liberapay username
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
otechie: # Replace with a single Otechie username
|
otechie: # Replace with a single Otechie username
|
||||||
custom: ['https://www.bountysource.com/teams/pyenv-virtualenv/issues'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE.md
vendored
4
.github/ISSUE_TEMPLATE.md
vendored
@@ -22,7 +22,11 @@ Make sure you have checked all steps below.
|
|||||||
* If the problem happens in a Pyenv invocation, you can turn on debug logging by setting `PYENV_DEBUG=1`, e.g. `env PYENV_DEBUG=1 pyenv install -v 3.6.4`
|
* If the problem happens in a Pyenv invocation, you can turn on debug logging by setting `PYENV_DEBUG=1`, e.g. `env PYENV_DEBUG=1 pyenv install -v 3.6.4`
|
||||||
* If the problem happens outside of a Pyenv invocation, get the debug log like this:
|
* If the problem happens outside of a Pyenv invocation, get the debug log like this:
|
||||||
```
|
```
|
||||||
|
# for Bash
|
||||||
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
|
# for Zsh
|
||||||
|
export PS4='+(%x:%I): %N(%i): '
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
<reproduce the problem>
|
<reproduce the problem>
|
||||||
set +x
|
set +x
|
||||||
|
|||||||
40
CHANGELOG.md
40
CHANGELOG.md
@@ -1,5 +1,45 @@
|
|||||||
## Version History
|
## Version History
|
||||||
|
|
||||||
|
#### 1.2.3
|
||||||
|
* Fix: add `colorize` helper by @silverjam in https://github.com/pyenv/pyenv-virtualenv/pull/470
|
||||||
|
* Bump pyenv-virtualenv reporting version to match release by @ushuz in https://github.com/pyenv/pyenv-virtualenv/pull/471
|
||||||
|
* Add fish prompt changing by @romirk in https://github.com/pyenv/pyenv-virtualenv/pull/475
|
||||||
|
* Don't activate if a 3rd-party venv is activated over ours by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/478
|
||||||
|
|
||||||
|
#### 1.2.2
|
||||||
|
* Prompt removal was never done and is not planned anymore by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/447
|
||||||
|
* Update PYENV_VIRTUALENV_VERSION by @jack-mcivor in https://github.com/pyenv/pyenv-virtualenv/pull/449
|
||||||
|
* Add activate/deactivate hooks by @joshfrench in https://github.com/pyenv/pyenv-virtualenv/pull/452
|
||||||
|
* More helpful error message when requesting a nonexistent base version by @MarcinKonowalczyk in https://github.com/pyenv/pyenv-virtualenv/pull/454
|
||||||
|
* Add fish install oneliner by @ElijahLynn in https://github.com/pyenv/pyenv-virtualenv/pull/322
|
||||||
|
* Link python*-config into VE by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/460
|
||||||
|
|
||||||
|
#### 1.2.1
|
||||||
|
* Support prefixes resolved by pyenv-latest as base version names by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/446
|
||||||
|
|
||||||
|
#### 1.2.0
|
||||||
|
* ~/.*rc should be modified instead of ~/.*profile by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/384
|
||||||
|
* Fixes #394 - update pyenv virtualenvs to list virtualenvs start with dot prefixes by @Gauravtalreja1 in https://github.com/pyenv/pyenv-virtualenv/pull/395
|
||||||
|
* Fix installation steps to allow for Pyenv 2 by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/388
|
||||||
|
* Fix get-pip.py URLs for older versions of Python by @jivanf in https://github.com/pyenv/pyenv-virtualenv/pull/403
|
||||||
|
* Add (y/N) prompt help text by @sh-cho in https://github.com/pyenv/pyenv-virtualenv/pull/404
|
||||||
|
* perf(sh-activate): avoid a pyenv-version-name call by @scop in https://github.com/pyenv/pyenv-virtualenv/pull/380
|
||||||
|
* Fix unbound variable errors when running `pyenv activate` with `set -u` Use default empty value. This fixes #422. by @ackalker in https://github.com/pyenv/pyenv-virtualenv/pull/423
|
||||||
|
* Fix another unbound variable error by @ackalker in https://github.com/pyenv/pyenv-virtualenv/pull/424
|
||||||
|
* Update `get-pip.py` URLs in `pyenv-virtualenv` by @mcdonnnj in https://github.com/pyenv/pyenv-virtualenv/pull/426
|
||||||
|
* Deduplicate shims in $PATH for the fish shell during initialization by @ericvw in https://github.com/pyenv/pyenv-virtualenv/pull/430
|
||||||
|
* Upgrade uninstall hook after pyenv/pyenv#2432 by @laggardkernel in https://github.com/pyenv/pyenv-virtualenv/pull/438
|
||||||
|
* Stop delete force failing when virtualenv does not exist by @eganjs in https://github.com/pyenv/pyenv-virtualenv/pull/330
|
||||||
|
* fix: relative path to pyenv-realpath.dylib by @scop in https://github.com/pyenv/pyenv-virtualenv/pull/378
|
||||||
|
* Spelling fixes by @scop in https://github.com/pyenv/pyenv-virtualenv/pull/352
|
||||||
|
* Clone bats with --depth=1, gitignore it by @scop in https://github.com/pyenv/pyenv-virtualenv/pull/351
|
||||||
|
* set -u fixes by @scop in https://github.com/pyenv/pyenv-virtualenv/pull/350
|
||||||
|
* Set up Github Actions CI by @native-api in https://github.com/pyenv/pyenv-virtualenv/pull/440
|
||||||
|
* Enhance documentation about options for `pyenv virtualenv` by @pylipp in https://github.com/pyenv/pyenv-virtualenv/pull/425
|
||||||
|
* Return control to pyenv-uninstall in uninstall/envs.bash by @aiguofer in https://github.com/pyenv/pyenv-virtualenv/pull/321
|
||||||
|
* Use realpath of scripts to determine relative locations by @andrew-christianson in https://github.com/pyenv/pyenv-virtualenv/pull/308
|
||||||
|
* Shell detect improvements by @scop in https://github.com/pyenv/pyenv-virtualenv/pull/377
|
||||||
|
|
||||||
#### 1.1.5
|
#### 1.1.5
|
||||||
|
|
||||||
* Fix install script (#290, #302)
|
* Fix install script (#290, #302)
|
||||||
|
|||||||
15
MAINTENANCE.md
Normal file
15
MAINTENANCE.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
Creating a release
|
||||||
|
==================
|
||||||
|
|
||||||
|
The release of the new version of Pyenv is done via GitHub Releases.
|
||||||
|
|
||||||
|
Release checklist:
|
||||||
|
* Start [drafting a new release on GitHub](https://github.com/pyenv/pyenv-virtualenv/releases) to generate a summary of changes. Save the summary locally.
|
||||||
|
* The summary may need editing. E.g. rephrase entries, delete/merge entries that are too minor or irrelevant to the users (e.g. typo fixes, CI)
|
||||||
|
* Push the version number in `bin/pyenv-virtualenv`
|
||||||
|
* Minor version is pushed if there are significant functional changes (not e.g. bugfixes/formula adaptations/supporting niche use cases).
|
||||||
|
* Major version is pushed if there are breaking changes
|
||||||
|
* Update `CHANGELOG.md` with the new version number and the edited summary (only the changes section), reformatting it like the rest of the changelog sections
|
||||||
|
* Commit the changes locally into `master`
|
||||||
|
* Create a new tag with the new version number and push the changes including the tag
|
||||||
|
* Create a new release on GitHub based on the tag, using the saved summary
|
||||||
@@ -34,6 +34,12 @@ From inside that directory you can:
|
|||||||
$ git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
|
$ git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For the Fish shell:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git clone https://github.com/pyenv/pyenv-virtualenv.git (pyenv root)/plugins/pyenv-virtualenv
|
||||||
|
```
|
||||||
|
|
||||||
2. (OPTIONAL) **Add `pyenv virtualenv-init` to your shell** to enable auto-activation of virtualenvs. This is entirely optional but pretty useful. See "Activate virtualenv" below.
|
2. (OPTIONAL) **Add `pyenv virtualenv-init` to your shell** to enable auto-activation of virtualenvs. This is entirely optional but pretty useful. See "Activate virtualenv" below.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
@@ -25,6 +25,27 @@ resolve_link() {
|
|||||||
unset FORCE
|
unset FORCE
|
||||||
unset QUIET
|
unset QUIET
|
||||||
|
|
||||||
|
# Define `before_activate` and `after_activate` functions that allow
|
||||||
|
# plugin hooks to register a string of code for execution before or
|
||||||
|
# after activating a virtualenv.
|
||||||
|
declare -a before_hooks after_hooks
|
||||||
|
|
||||||
|
before_activate() {
|
||||||
|
local hook="$1"
|
||||||
|
before_hooks["${#before_hooks[@]}"]="$hook"
|
||||||
|
}
|
||||||
|
|
||||||
|
after_activate() {
|
||||||
|
local hook="$1"
|
||||||
|
after_hooks["${#after_hooks[@]}"]="$hook"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load plugin hooks.
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=$'\n' scripts=(`pyenv-hooks activate`)
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
for script in "${scripts[@]}"; do source "$script"; done
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--complete" )
|
"--complete" )
|
||||||
@@ -75,8 +96,8 @@ fi
|
|||||||
venv="${versions}"
|
venv="${versions}"
|
||||||
|
|
||||||
if [ -n "${VIRTUAL_ENV}" ]; then
|
if [ -n "${VIRTUAL_ENV}" ]; then
|
||||||
# exit as success if some virtualenv is already activated outside from pyenv-virtualenv
|
# exit as success if a non-pyenv virtualenv is active
|
||||||
if [ -z "${PYENV_VIRTUAL_ENV}" ]; then
|
if [[ -z $PYENV_VIRTUAL_ENV || $PYENV_VIRTUAL_ENV != "$VIRTUAL_ENV" ]]; then
|
||||||
if [ -z "${FORCE}" ]; then
|
if [ -z "${FORCE}" ]; then
|
||||||
if [ -z "${QUIET}" ]; then
|
if [ -z "${QUIET}" ]; then
|
||||||
echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2
|
echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2
|
||||||
@@ -137,6 +158,9 @@ fi
|
|||||||
|
|
||||||
pyenv-sh-deactivate --force --quiet || true
|
pyenv-sh-deactivate --force --quiet || true
|
||||||
|
|
||||||
|
# Execute `before_activate` hooks.
|
||||||
|
for hook in "${before_hooks[@]}"; do eval "$hook"; done
|
||||||
|
|
||||||
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
||||||
echo "pyenv-virtualenv: activate ${venv}" 1>&2
|
echo "pyenv-virtualenv: activate ${venv}" 1>&2
|
||||||
fi
|
fi
|
||||||
@@ -221,13 +245,23 @@ if [ -z "${PYENV_VIRTUALENV_DISABLE_PROMPT}" ]; then
|
|||||||
case "${shell}" in
|
case "${shell}" in
|
||||||
fish )
|
fish )
|
||||||
if [ -z "${QUIET}" ]; then
|
if [ -z "${QUIET}" ]; then
|
||||||
echo "pyenv-virtualenv: prompt changing not working for fish." 1>&2
|
cat <<EOS
|
||||||
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(${venv}) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
|
EOS
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
if [ -z "${QUIET}" ]; then
|
|
||||||
echo "pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior." 1>&2
|
|
||||||
fi
|
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(${venv}) \${PS1:-}";
|
export PS1="(${venv}) \${PS1:-}";
|
||||||
@@ -261,3 +295,6 @@ if [ -d "${prefix}/conda-meta" ] ||
|
|||||||
esac
|
esac
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Execute `after_activate` hooks.
|
||||||
|
for hook in "${after_hooks[@]}"; do eval "$hook"; done
|
||||||
|
|||||||
@@ -16,6 +16,27 @@ fi
|
|||||||
unset FORCE
|
unset FORCE
|
||||||
unset QUIET
|
unset QUIET
|
||||||
|
|
||||||
|
# Define `before_deactivate` and `after_deactivate` functions that allow
|
||||||
|
# plugin hooks to register a string of code for execution before or
|
||||||
|
# after deactivating a virtualenv.
|
||||||
|
declare -a before_hooks after_hooks
|
||||||
|
|
||||||
|
before_deactivate() {
|
||||||
|
local hook="$1"
|
||||||
|
before_hooks["${#before_hooks[@]}"]="$hook"
|
||||||
|
}
|
||||||
|
|
||||||
|
after_deactivate() {
|
||||||
|
local hook="$1"
|
||||||
|
after_hooks["${#after_hooks[@]}"]="$hook"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load plugin hooks.
|
||||||
|
OLDIFS="$IFS"
|
||||||
|
IFS=$'\n' scripts=(`pyenv-hooks deactivate`)
|
||||||
|
IFS="$OLDIFS"
|
||||||
|
for script in "${scripts[@]}"; do source "$script"; done
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"-f" | "--force" )
|
"-f" | "--force" )
|
||||||
@@ -54,6 +75,9 @@ else
|
|||||||
venv="${prefix##*/}"
|
venv="${prefix##*/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Execute `before_deactivate` hooks.
|
||||||
|
for hook in "${before_hooks[@]}"; do eval "$hook"; done
|
||||||
|
|
||||||
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then
|
||||||
echo "pyenv-virtualenv: deactivate ${venv}" 1>&2
|
echo "pyenv-virtualenv: deactivate ${venv}" 1>&2
|
||||||
fi
|
fi
|
||||||
@@ -163,7 +187,15 @@ esac
|
|||||||
|
|
||||||
case "${shell}" in
|
case "${shell}" in
|
||||||
fish )
|
fish )
|
||||||
:
|
cat <<EOS
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
|
EOS
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
@@ -191,3 +223,6 @@ fi;
|
|||||||
EOS
|
EOS
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Execute `after_deactivate` hooks.
|
||||||
|
for hook in "${after_hooks[@]}"; do eval "$hook"; done
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
# -u/--upgrade Imply --force
|
# -u/--upgrade Imply --force
|
||||||
#
|
#
|
||||||
|
|
||||||
PYENV_VIRTUALENV_VERSION="1.1.5"
|
PYENV_VIRTUALENV_VERSION="1.2.3"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
@@ -54,6 +54,12 @@ parse_options() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
colorize() {
|
||||||
|
if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
|
||||||
|
else echo -n "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
resolve_link() {
|
resolve_link() {
|
||||||
$(type -p greadlink readlink | head -1) "$1"
|
$(type -p greadlink readlink | head -1) "$1"
|
||||||
}
|
}
|
||||||
@@ -336,10 +342,20 @@ fi
|
|||||||
# Set VERSION_NAME as default version in this script
|
# Set VERSION_NAME as default version in this script
|
||||||
export PYENV_VERSION="${VERSION_NAME}"
|
export PYENV_VERSION="${VERSION_NAME}"
|
||||||
|
|
||||||
|
not_installed_message() {
|
||||||
|
local is_available=$(python-build --definitions | grep -F -x "$1")
|
||||||
|
echo "pyenv-virtualenv: \`${1}' is not installed in pyenv." 1>&2
|
||||||
|
if [[ $is_available ]]; then
|
||||||
|
echo "Run \`pyenv install ${1}' to install it." 1>&2
|
||||||
|
else
|
||||||
|
echo "It does not look like a valid Python version. See \`pyenv install --list' for available versions." 1>&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Source version must exist before creating virtualenv.
|
# Source version must exist before creating virtualenv.
|
||||||
PREFIX="$(pyenv-prefix 2>/dev/null || true)"
|
PREFIX="$(pyenv-prefix 2>/dev/null || true)"
|
||||||
if [ ! -d "${PREFIX}" ]; then
|
if [ ! -d "${PREFIX}" ]; then
|
||||||
echo "pyenv-virtualenv: \`${PYENV_VERSION}' is not installed in pyenv." 1>&2
|
not_installed_message "${PYENV_VERSION}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -441,7 +457,8 @@ else
|
|||||||
if [ -x "${python}" ]; then
|
if [ -x "${python}" ]; then
|
||||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--python=${python}"
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--python=${python}"
|
||||||
else
|
else
|
||||||
echo "pyenv-virtualenv: \`${VIRTUALENV_PYTHON##*/}' is not installed in pyenv." 1>&2
|
# echo "pyenv-virtualenv: \`${VIRTUALENV_PYTHON##*/}' is not installed in pyenv." 1>&2
|
||||||
|
not_installed_message "${VIRTUALENV_PYTHON##*/}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -589,6 +606,15 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
shopt -s nullglob
|
||||||
|
for extra_binary in "$PREFIX"/bin/python*-config; do
|
||||||
|
extra_binary_linkname="$VIRTUALENV_PATH/bin/$(basename $extra_binary)"
|
||||||
|
[[ -e "$extra_binary_linkname" ]] || \
|
||||||
|
ln -s "$extra_binary" "$extra_binary_linkname"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
## Create symlink in the `versions` directory for backward compatibility
|
## Create symlink in the `versions` directory for backward compatibility
|
||||||
if [ -d "${VIRTUALENV_PATH}" ] && [ -n "${COMPAT_VIRTUALENV_PATH}" ]; then
|
if [ -d "${VIRTUALENV_PATH}" ] && [ -n "${COMPAT_VIRTUALENV_PATH}" ]; then
|
||||||
ln -fs "${VIRTUALENV_PATH}" "${COMPAT_VIRTUALENV_PATH}"
|
ln -fs "${VIRTUALENV_PATH}" "${COMPAT_VIRTUALENV_PATH}"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ setup() {
|
|||||||
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset VIRTUAL_ENV_DISABLE_PROMPT
|
unset VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset _OLD_VIRTUAL_PS1
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
stub pyenv-hooks "activate : echo"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "activate virtualenv from current version" {
|
@test "activate virtualenv from current version" {
|
||||||
@@ -33,7 +34,6 @@ setup() {
|
|||||||
deactivated
|
deactivated
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(venv) \${PS1:-}";
|
export PS1="(venv) \${PS1:-}";
|
||||||
EOS
|
EOS
|
||||||
@@ -86,7 +86,6 @@ deactivated
|
|||||||
pyenv-virtualenv: activate venv
|
pyenv-virtualenv: activate venv
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(venv) \${PS1:-}";
|
export PS1="(venv) \${PS1:-}";
|
||||||
EOS
|
EOS
|
||||||
@@ -114,7 +113,6 @@ export PYENV_VERSION="venv";
|
|||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(venv) \${PS1:-}";
|
export PS1="(venv) \${PS1:-}";
|
||||||
EOS
|
EOS
|
||||||
@@ -140,7 +138,18 @@ EOS
|
|||||||
deactivated
|
deactivated
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-version-name
|
unstub pyenv-version-name
|
||||||
@@ -166,7 +175,18 @@ set -gx PYENV_VERSION "venv";
|
|||||||
set -gx PYENV_ACTIVATE_SHELL 1;
|
set -gx PYENV_ACTIVATE_SHELL 1;
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-version-name
|
unstub pyenv-version-name
|
||||||
@@ -191,7 +211,6 @@ export PYENV_VERSION="venv27";
|
|||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(venv27) \${PS1:-}";
|
export PS1="(venv27) \${PS1:-}";
|
||||||
EOS
|
EOS
|
||||||
@@ -217,7 +236,6 @@ export PYENV_VERSION="venv27";
|
|||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(venv27) \${PS1:-}";
|
export PS1="(venv27) \${PS1:-}";
|
||||||
EOS
|
EOS
|
||||||
@@ -243,7 +261,18 @@ set -gx PYENV_VERSION "venv27";
|
|||||||
set -gx PYENV_ACTIVATE_SHELL 1;
|
set -gx PYENV_ACTIVATE_SHELL 1;
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv27) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
@@ -267,7 +296,18 @@ set -gx PYENV_VERSION "venv27";
|
|||||||
set -gx PYENV_ACTIVATE_SHELL 1;
|
set -gx PYENV_ACTIVATE_SHELL 1;
|
||||||
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx PYENV_VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
set -gx VIRTUAL_ENV "${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(venv27) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
@@ -390,7 +430,6 @@ export PYENV_VERSION="venv27:2.7.10";
|
|||||||
export PYENV_ACTIVATE_SHELL=1;
|
export PYENV_ACTIVATE_SHELL=1;
|
||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv27";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(venv27) \${PS1:-}";
|
export PS1="(venv27) \${PS1:-}";
|
||||||
EOS
|
EOS
|
||||||
@@ -400,6 +439,34 @@ EOS
|
|||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "do nothing if a 3rd-party virtualenv is active" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
export VIRTUAL_ENV="${TMP}/venv-3rd-party"
|
||||||
|
unset PYENV_VIRTUAL_ENV
|
||||||
|
|
||||||
|
PYENV_SHELL="bash" run pyenv-sh-activate "venv"
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
pyenv-virtualenv: virtualenv \`${TMP}/venv-3rd-party' is already activated
|
||||||
|
true
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "do nothing if a 3rd-party virtualenv is active over ours" {
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
export VIRTUAL_ENV="${TMP}/venv-3rd-party"
|
||||||
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||||
|
|
||||||
|
PYENV_SHELL="bash" run pyenv-sh-activate "venv"
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
pyenv-virtualenv: virtualenv \`${TMP}/venv-3rd-party' is already activated
|
||||||
|
true
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
@test "should fail if activate is invoked as a command" {
|
@test "should fail if activate is invoked as a command" {
|
||||||
run pyenv-activate
|
run pyenv-activate
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ setup() {
|
|||||||
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset VIRTUAL_ENV_DISABLE_PROMPT
|
unset VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset _OLD_VIRTUAL_PS1
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
stub pyenv-hooks "activate : echo"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
unstub pyenv-hooks
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "activate conda root from current version" {
|
@test "activate conda root from current version" {
|
||||||
@@ -36,7 +41,6 @@ deactivated
|
|||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0";
|
||||||
export CONDA_DEFAULT_ENV="root";
|
export CONDA_DEFAULT_ENV="root";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(anaconda-2.3.0) \${PS1:-}";
|
export PS1="(anaconda-2.3.0) \${PS1:-}";
|
||||||
export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0";
|
export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0";
|
||||||
@@ -66,7 +70,18 @@ deactivated
|
|||||||
set -gx PYENV_VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
set -gx PYENV_VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
||||||
set -gx VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
set -gx VIRTUAL_ENV "${TMP}/pyenv/versions/anaconda-2.3.0";
|
||||||
set -gx CONDA_DEFAULT_ENV "root";
|
set -gx CONDA_DEFAULT_ENV "root";
|
||||||
pyenv-virtualenv: prompt changing not working for fish.
|
functions -e _pyenv_old_prompt # remove old prompt function if exists.
|
||||||
|
# since everything is in memory, it's safe to
|
||||||
|
# remove it.
|
||||||
|
functions -c fish_prompt _pyenv_old_prompt # backup old prompt function
|
||||||
|
|
||||||
|
# from python-venv
|
||||||
|
function fish_prompt
|
||||||
|
set -l prompt (_pyenv_old_prompt) # call old prompt function first since it might
|
||||||
|
# read exit status
|
||||||
|
echo -n "(anaconda-2.3.0) " # add virtualenv to prompt
|
||||||
|
string join -- \n \$prompt # handle multiline prompts
|
||||||
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
unstub pyenv-version-name
|
unstub pyenv-version-name
|
||||||
@@ -95,7 +110,6 @@ export PYENV_ACTIVATE_SHELL=1;
|
|||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1";
|
||||||
export CONDA_DEFAULT_ENV="root";
|
export CONDA_DEFAULT_ENV="root";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(miniconda-3.9.1) \${PS1:-}";
|
export PS1="(miniconda-3.9.1) \${PS1:-}";
|
||||||
export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1";
|
export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1";
|
||||||
@@ -125,7 +139,6 @@ deactivated
|
|||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo";
|
||||||
export CONDA_DEFAULT_ENV="foo";
|
export CONDA_DEFAULT_ENV="foo";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(anaconda-2.3.0/envs/foo) \${PS1:-}";
|
export PS1="(anaconda-2.3.0/envs/foo) \${PS1:-}";
|
||||||
export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0/envs/foo";
|
export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0/envs/foo";
|
||||||
@@ -158,7 +171,6 @@ export PYENV_ACTIVATE_SHELL=1;
|
|||||||
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar";
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar";
|
||||||
export VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar";
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar";
|
||||||
export CONDA_DEFAULT_ENV="bar";
|
export CONDA_DEFAULT_ENV="bar";
|
||||||
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
|
|
||||||
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
export PS1="(miniconda-3.9.1/envs/bar) \${PS1:-}";
|
export PS1="(miniconda-3.9.1/envs/bar) \${PS1:-}";
|
||||||
export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1/envs/bar";
|
export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1/envs/bar";
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ setup() {
|
|||||||
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset VIRTUAL_ENV_DISABLE_PROMPT
|
unset VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset _OLD_VIRTUAL_PS1
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
stub pyenv-hooks "deactivate : echo"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
unstub pyenv-hooks
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "deactivate conda root" {
|
@test "deactivate conda root" {
|
||||||
@@ -77,6 +82,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ setup() {
|
|||||||
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
unset PYENV_VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset VIRTUAL_ENV_DISABLE_PROMPT
|
unset VIRTUAL_ENV_DISABLE_PROMPT
|
||||||
unset _OLD_VIRTUAL_PS1
|
unset _OLD_VIRTUAL_PS1
|
||||||
|
stub pyenv-hooks "deactivate : echo"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "deactivate virtualenv" {
|
@test "deactivate virtualenv" {
|
||||||
@@ -224,6 +225,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -250,6 +258,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -278,6 +293,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -306,6 +328,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
@@ -332,6 +361,13 @@ if [ -n "\$_OLD_VIRTUAL_PYTHONHOME" ];
|
|||||||
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
set -gx PYTHONHOME "\$_OLD_VIRTUAL_PYTHONHOME";
|
||||||
set -e _OLD_VIRTUAL_PYTHONHOME;
|
set -e _OLD_VIRTUAL_PYTHONHOME;
|
||||||
end;
|
end;
|
||||||
|
# check if old prompt function exists
|
||||||
|
if functions -q _pyenv_old_prompt
|
||||||
|
# remove old prompt function if exists.
|
||||||
|
functions -e fish_prompt
|
||||||
|
functions -c _pyenv_old_prompt fish_prompt
|
||||||
|
functions -e _pyenv_old_prompt
|
||||||
|
end
|
||||||
if functions -q deactivate;
|
if functions -q deactivate;
|
||||||
functions -e deactivate;
|
functions -e deactivate;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -40,3 +40,74 @@ OUT
|
|||||||
unstub pyenv-rehash
|
unstub pyenv-rehash
|
||||||
teardown_version "3.5.1"
|
teardown_version "3.5.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "pyenv-sh-activate hooks" {
|
||||||
|
cat > "${HOOK_PATH}/activate.bash" <<OUT
|
||||||
|
before_activate 'echo "before"'
|
||||||
|
after_activate 'echo "after"'
|
||||||
|
OUT
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
|
||||||
|
stub pyenv-version-name "echo venv"
|
||||||
|
stub pyenv-virtualenv-prefix ""
|
||||||
|
stub pyenv-prefix "venv : echo \"${PYENV_ROOT}/versions/venv\""
|
||||||
|
stub pyenv-hooks "activate : echo '$HOOK_PATH'/activate.bash"
|
||||||
|
stub pyenv-sh-deactivate ""
|
||||||
|
|
||||||
|
PYENV_SHELL="bash" PYENV_VERSION="venv" run pyenv-sh-activate
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
before
|
||||||
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv";
|
||||||
|
export _OLD_VIRTUAL_PS1="\${PS1:-}";
|
||||||
|
export PS1="(venv) \${PS1:-}";
|
||||||
|
after
|
||||||
|
EOS
|
||||||
|
|
||||||
|
unstub pyenv-version-name
|
||||||
|
unstub pyenv-virtualenv-prefix
|
||||||
|
unstub pyenv-prefix
|
||||||
|
unstub pyenv-hooks
|
||||||
|
unstub pyenv-sh-deactivate
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "deactivate virtualenv" {
|
||||||
|
cat > "${HOOK_PATH}/deactivate.bash" <<OUT
|
||||||
|
before_deactivate 'echo "before"'
|
||||||
|
after_deactivate 'echo "after"'
|
||||||
|
OUT
|
||||||
|
export PYENV_VIRTUALENV_INIT=1
|
||||||
|
export PYENV_VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||||
|
export VIRTUAL_ENV="${PYENV_ROOT}/versions/venv"
|
||||||
|
export PYENV_ACTIVATE_SHELL=
|
||||||
|
stub pyenv-hooks "deactivate : echo '$HOOK_PATH'/deactivate.bash"
|
||||||
|
|
||||||
|
PYENV_SHELL="bash" run pyenv-sh-deactivate
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
assert_output <<EOS
|
||||||
|
before
|
||||||
|
unset PYENV_VIRTUAL_ENV;
|
||||||
|
unset VIRTUAL_ENV;
|
||||||
|
if [ -n "\${_OLD_VIRTUAL_PATH:-}" ]; then
|
||||||
|
export PATH="\${_OLD_VIRTUAL_PATH}";
|
||||||
|
unset _OLD_VIRTUAL_PATH;
|
||||||
|
fi;
|
||||||
|
if [ -n "\${_OLD_VIRTUAL_PYTHONHOME:-}" ]; then
|
||||||
|
export PYTHONHOME="\${_OLD_VIRTUAL_PYTHONHOME}";
|
||||||
|
unset _OLD_VIRTUAL_PYTHONHOME;
|
||||||
|
fi;
|
||||||
|
if [ -n "\${_OLD_VIRTUAL_PS1:-}" ]; then
|
||||||
|
export PS1="\${_OLD_VIRTUAL_PS1}";
|
||||||
|
unset _OLD_VIRTUAL_PS1;
|
||||||
|
fi;
|
||||||
|
if declare -f deactivate 1>/dev/null 2>&1; then
|
||||||
|
unset -f deactivate;
|
||||||
|
fi;
|
||||||
|
after
|
||||||
|
EOS
|
||||||
|
|
||||||
|
unstub pyenv-hooks
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ setup() {
|
|||||||
stub pyenv-rehash " : true"
|
stub pyenv-rehash " : true"
|
||||||
stub pyenv-version-name "echo \${PYENV_VERSION}"
|
stub pyenv-version-name "echo \${PYENV_VERSION}"
|
||||||
stub curl true
|
stub curl true
|
||||||
|
stub python-build "echo python2.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
@@ -22,6 +23,7 @@ teardown() {
|
|||||||
unstub pyenv-prefix
|
unstub pyenv-prefix
|
||||||
unstub pyenv-hooks
|
unstub pyenv-hooks
|
||||||
unstub pyenv-rehash
|
unstub pyenv-rehash
|
||||||
|
unstub python-build
|
||||||
teardown_version "2.7.8"
|
teardown_version "2.7.8"
|
||||||
rm -fr "$TMP"/*
|
rm -fr "$TMP"/*
|
||||||
}
|
}
|
||||||
@@ -96,6 +98,7 @@ OUT
|
|||||||
|
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
pyenv-virtualenv: \`python2.7' is not installed in pyenv.
|
pyenv-virtualenv: \`python2.7' is not installed in pyenv.
|
||||||
|
Run \`pyenv install python2.7' to install it.
|
||||||
OUT
|
OUT
|
||||||
assert_failure
|
assert_failure
|
||||||
|
|
||||||
@@ -106,3 +109,13 @@ OUT
|
|||||||
remove_executable "2.7.8" "python2.7"
|
remove_executable "2.7.8" "python2.7"
|
||||||
remove_executable "2.7.9" "python2.7"
|
remove_executable "2.7.9" "python2.7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "invalid python name" {
|
||||||
|
run pyenv-virtualenv --verbose --python=99.99.99 venv
|
||||||
|
|
||||||
|
assert_output <<OUT
|
||||||
|
pyenv-virtualenv: \`99.99.99' is not installed in pyenv.
|
||||||
|
It does not look like a valid Python version. See \`pyenv install --list' for available versions.
|
||||||
|
OUT
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
@@ -11,11 +11,10 @@ _STUB_RUN="${PROGRAM}_STUB_RUN"
|
|||||||
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
||||||
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
||||||
_STUB_END="${PROGRAM}_STUB_END"
|
_STUB_END="${PROGRAM}_STUB_END"
|
||||||
_STUB_DEBUG="${PROGRAM}_STUB_DEBUG"
|
_STUB_LOG="${PROGRAM}_STUB_LOG"
|
||||||
|
|
||||||
if [ -n "${!_STUB_DEBUG}" ]; then
|
[ -n "${!_STUB_LOG}" ] || eval "${_STUB_LOG}"="${TMPDIR}/${program}-stub-log"
|
||||||
echo "$program" "$@" >&${!_STUB_DEBUG}
|
if test -z "${!_STUB_END}"; then echo "$program" "$@" >>"${!_STUB_LOG}"; fi
|
||||||
fi
|
|
||||||
|
|
||||||
[ -e "${!_STUB_PLAN}" ] || exit 1
|
[ -e "${!_STUB_PLAN}" ] || exit 1
|
||||||
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
|
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
|
||||||
@@ -24,7 +23,7 @@ fi
|
|||||||
# Initialize or load the stub run information.
|
# Initialize or load the stub run information.
|
||||||
eval "${_STUB_INDEX}"=1
|
eval "${_STUB_INDEX}"=1
|
||||||
eval "${_STUB_RESULT}"=0
|
eval "${_STUB_RESULT}"=0
|
||||||
[ ! -e "${!_STUB_RUN}" ] || source "${!_STUB_RUN}"
|
if test -e "${!_STUB_RUN}"; then source "${!_STUB_RUN}"; fi
|
||||||
|
|
||||||
|
|
||||||
# Loop over each line in the plan.
|
# Loop over each line in the plan.
|
||||||
@@ -80,14 +79,26 @@ done < "${!_STUB_PLAN}"
|
|||||||
|
|
||||||
|
|
||||||
if [ -n "${!_STUB_END}" ]; then
|
if [ -n "${!_STUB_END}" ]; then
|
||||||
# Clean up the run file.
|
|
||||||
rm -f "${!_STUB_RUN}"
|
|
||||||
|
|
||||||
# If the number of lines in the plan is larger than
|
# If the number of lines in the plan is larger than
|
||||||
# the requested index, we failed.
|
# the requested index, we failed.
|
||||||
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
if [ $index -ge "${!_STUB_INDEX}" ]; then
|
||||||
eval "${_STUB_RESULT}"=1
|
eval "${_STUB_RESULT}"=1
|
||||||
fi
|
fi
|
||||||
|
if [ "${!_STUB_RESULT}" -ne 0 ]; then
|
||||||
|
{
|
||||||
|
echo "index: $index; stub index: ${!_STUB_INDEX}"
|
||||||
|
echo "plan:"
|
||||||
|
cat "${!_STUB_PLAN}" || true
|
||||||
|
echo "run:"
|
||||||
|
cat "${!_STUB_RUN}" || true
|
||||||
|
echo "log:"
|
||||||
|
cat "${!_STUB_LOG}" || true
|
||||||
|
} >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up the run file.
|
||||||
|
rm -f "${!_STUB_RUN}"
|
||||||
|
rm -f "${!_STUB_LOG}"
|
||||||
|
|
||||||
# Return the result.
|
# Return the result.
|
||||||
exit "${!_STUB_RESULT}"
|
exit "${!_STUB_RESULT}"
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ stub() {
|
|||||||
|
|
||||||
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
||||||
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
||||||
|
export "${prefix}_STUB_LOG"="${TMP}/${program}-stub-log"
|
||||||
export "${prefix}_STUB_END"=
|
export "${prefix}_STUB_END"=
|
||||||
|
|
||||||
mkdir -p "${TMP}/bin"
|
mkdir -p "${TMP}/bin"
|
||||||
|
|||||||
@@ -29,10 +29,13 @@ unstub_pyenv() {
|
|||||||
stub pyenv-exec "python2.7 -m venv --help : false"
|
stub pyenv-exec "python2.7 -m venv --help : false"
|
||||||
stub pyenv-exec "python2 -m venv --help : false"
|
stub pyenv-exec "python2 -m venv --help : false"
|
||||||
stub pyenv-exec "python -m venv --help : false"
|
stub pyenv-exec "python -m venv --help : false"
|
||||||
stub pyenv-exec "virtualenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\""
|
stub pyenv-exec "virtualenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\"; mkdir -p \"\$2/bin\""
|
||||||
stub pyenv-exec "python -s -m ensurepip : false"
|
stub pyenv-exec "python -s -m ensurepip : false"
|
||||||
stub pyenv-exec "python -s */get-pip.py : true"
|
stub pyenv-exec "python -s */get-pip.py : true"
|
||||||
stub curl true
|
stub curl true
|
||||||
|
create_executable "${PYENV_VERSION}" "python-config"
|
||||||
|
create_executable "${PYENV_VERSION}" "python2-config"
|
||||||
|
create_executable "${PYENV_VERSION}" "python2.7-config"
|
||||||
|
|
||||||
run pyenv-virtualenv "2.7.11" "venv"
|
run pyenv-virtualenv "2.7.11" "venv"
|
||||||
|
|
||||||
@@ -41,8 +44,10 @@ PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/venv
|
|||||||
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
|
||||||
rehashed
|
rehashed
|
||||||
OUT
|
OUT
|
||||||
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
|
|
||||||
assert_success
|
assert_success
|
||||||
|
for x in pydoc python-config python2-config python2.7-config; do
|
||||||
|
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/$x" ]
|
||||||
|
done
|
||||||
|
|
||||||
unstub_pyenv
|
unstub_pyenv
|
||||||
unstub pyenv-virtualenv-prefix
|
unstub pyenv-virtualenv-prefix
|
||||||
|
|||||||
Reference in New Issue
Block a user