mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
Remove --pyvenv option.
Use pyvenv only if virtualenv is not installed and there is pyvenv.
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
# pyenv virtualenv --version
|
# pyenv virtualenv --version
|
||||||
# pyenv virtualenv --help
|
# pyenv virtualenv --help
|
||||||
#
|
#
|
||||||
# -u/--upgrade Upgrade existing virtualenv with migrating installed packages
|
# -u/--upgrade Upgrade existing virtualenv to use new version of Python,
|
||||||
|
# assuming Python has been upgraded in-place.
|
||||||
# -f/--force Install even if the version appears to be installed already
|
# -f/--force Install even if the version appears to be installed already
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -78,17 +79,17 @@ usage() {
|
|||||||
[ -z "$1" ] || exit "$1"
|
[ -z "$1" ] || exit "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
require_executable() {
|
virtualenv_is_pyvenv() {
|
||||||
local version="$1"
|
# Use pyvenv only if virtualenv is not installed and there is pyvenv
|
||||||
local executable="$2"
|
if pyenv-which "virtualenv" 1>/dev/null 2>&1; then
|
||||||
if ! PYENV_VERSION="${version}" pyenv-which "${executable}" 1>/dev/null 2>&1; then
|
|
||||||
echo "pyenv: ${executable} is not installed in ${version}." 1>&2
|
|
||||||
return 1
|
return 1
|
||||||
|
else
|
||||||
|
pyenv-which "pyvenv" 1>/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
virtualenv() {
|
virtualenv() {
|
||||||
if [ -n "$PYVENV" ]; then
|
if virtualenv_is_pyvenv; then
|
||||||
pyenv-exec pyvenv "$@"
|
pyenv-exec pyvenv "$@"
|
||||||
else
|
else
|
||||||
pyenv-exec virtualenv "$@"
|
pyenv-exec virtualenv "$@"
|
||||||
@@ -102,7 +103,6 @@ fi
|
|||||||
VIRTUALENV_OPTIONS=()
|
VIRTUALENV_OPTIONS=()
|
||||||
|
|
||||||
unset FORCE
|
unset FORCE
|
||||||
unset PYVENV
|
|
||||||
unset QUIET
|
unset QUIET
|
||||||
unset UPGRADE
|
unset UPGRADE
|
||||||
unset VERBOSE
|
unset VERBOSE
|
||||||
@@ -116,9 +116,6 @@ for option in "${OPTIONS[@]}"; do
|
|||||||
"h" | "help" )
|
"h" | "help" )
|
||||||
usage 0
|
usage 0
|
||||||
;;
|
;;
|
||||||
"pyvenv" )
|
|
||||||
PYVENV=true
|
|
||||||
;;
|
|
||||||
"q" | "quiet" )
|
"q" | "quiet" )
|
||||||
QUIET="--quiet"
|
QUIET="--quiet"
|
||||||
;;
|
;;
|
||||||
@@ -173,8 +170,7 @@ UPGRADE_LIST="${TMP}/pyenv-virtualenv.${SEED}.txt"
|
|||||||
|
|
||||||
VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
|
VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
|
||||||
|
|
||||||
if [ -n "$PYVENV" ]; then
|
if virtualenv_is_pyvenv; then
|
||||||
require_executable "${VERSION_NAME}" "pyvenv"
|
|
||||||
# Unset some arguments not supported by pyvenv
|
# Unset some arguments not supported by pyvenv
|
||||||
unset QUIET
|
unset QUIET
|
||||||
unset VERBOSE
|
unset VERBOSE
|
||||||
@@ -183,8 +179,7 @@ if [ -n "$PYVENV" ]; then
|
|||||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--upgrade"
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--upgrade"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
require_executable "${VERSION_NAME}" "virtualenv" || {
|
pyenv-which "virtualenv" 1>/dev/null 2>&1 || {
|
||||||
require_executable "${VERSION_NAME}" "pip"
|
|
||||||
VIRTUALENV_VERSION="==${VIRTUALENV_VERSION}"
|
VIRTUALENV_VERSION="==${VIRTUALENV_VERSION}"
|
||||||
pyenv-exec pip install $QUIET $VERBOSE "virtualenv${VIRTUALENV_VERSION%==}"
|
pyenv-exec pip install $QUIET $VERBOSE "virtualenv${VIRTUALENV_VERSION%==}"
|
||||||
pyenv-rehash
|
pyenv-rehash
|
||||||
@@ -233,7 +228,6 @@ if [ -d "${VIRTUALENV_PATH}/bin" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$UPGRADE" ]; then
|
if [ -n "$UPGRADE" ]; then
|
||||||
require_executable "${VIRTUALENV_NAME}" "pip"
|
|
||||||
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec pip freeze >"${UPGRADE_LIST}"
|
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec pip freeze >"${UPGRADE_LIST}"
|
||||||
mv -f "${VIRTUALENV_PATH}" "${UPGRADE_PATH}"
|
mv -f "${VIRTUALENV_PATH}" "${UPGRADE_PATH}"
|
||||||
fi
|
fi
|
||||||
@@ -269,7 +263,6 @@ fi
|
|||||||
## Migrate previously installed packages from requirements.txt
|
## Migrate previously installed packages from requirements.txt
|
||||||
if [ -n "$UPGRADE" ]; then
|
if [ -n "$UPGRADE" ]; then
|
||||||
UPGRADE_STATUS=0
|
UPGRADE_STATUS=0
|
||||||
require_executable "${VIRTUALENV_NAME}" "pip" || UPGRADE_STATUS=1
|
|
||||||
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec pip install $QUIET $VERBOSE --requirement "${UPGRADE_LIST}" || UPGRADE_STATUS=$?
|
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec pip install $QUIET $VERBOSE --requirement "${UPGRADE_LIST}" || UPGRADE_STATUS=$?
|
||||||
if [ "$UPGRADE_STATUS" == "0" ]; then
|
if [ "$UPGRADE_STATUS" == "0" ]; then
|
||||||
rm -f "${UPGRADE_LIST}"
|
rm -f "${UPGRADE_LIST}"
|
||||||
|
|||||||
Reference in New Issue
Block a user