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 --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
|
||||
#
|
||||
|
||||
@@ -78,17 +79,17 @@ usage() {
|
||||
[ -z "$1" ] || exit "$1"
|
||||
}
|
||||
|
||||
require_executable() {
|
||||
local version="$1"
|
||||
local executable="$2"
|
||||
if ! PYENV_VERSION="${version}" pyenv-which "${executable}" 1>/dev/null 2>&1; then
|
||||
echo "pyenv: ${executable} is not installed in ${version}." 1>&2
|
||||
virtualenv_is_pyvenv() {
|
||||
# Use pyvenv only if virtualenv is not installed and there is pyvenv
|
||||
if pyenv-which "virtualenv" 1>/dev/null 2>&1; then
|
||||
return 1
|
||||
else
|
||||
pyenv-which "pyvenv" 1>/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
virtualenv() {
|
||||
if [ -n "$PYVENV" ]; then
|
||||
if virtualenv_is_pyvenv; then
|
||||
pyenv-exec pyvenv "$@"
|
||||
else
|
||||
pyenv-exec virtualenv "$@"
|
||||
@@ -102,7 +103,6 @@ fi
|
||||
VIRTUALENV_OPTIONS=()
|
||||
|
||||
unset FORCE
|
||||
unset PYVENV
|
||||
unset QUIET
|
||||
unset UPGRADE
|
||||
unset VERBOSE
|
||||
@@ -116,9 +116,6 @@ for option in "${OPTIONS[@]}"; do
|
||||
"h" | "help" )
|
||||
usage 0
|
||||
;;
|
||||
"pyvenv" )
|
||||
PYVENV=true
|
||||
;;
|
||||
"q" | "quiet" )
|
||||
QUIET="--quiet"
|
||||
;;
|
||||
@@ -173,8 +170,7 @@ UPGRADE_LIST="${TMP}/pyenv-virtualenv.${SEED}.txt"
|
||||
|
||||
VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
|
||||
|
||||
if [ -n "$PYVENV" ]; then
|
||||
require_executable "${VERSION_NAME}" "pyvenv"
|
||||
if virtualenv_is_pyvenv; then
|
||||
# Unset some arguments not supported by pyvenv
|
||||
unset QUIET
|
||||
unset VERBOSE
|
||||
@@ -183,8 +179,7 @@ if [ -n "$PYVENV" ]; then
|
||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--upgrade"
|
||||
fi
|
||||
else
|
||||
require_executable "${VERSION_NAME}" "virtualenv" || {
|
||||
require_executable "${VERSION_NAME}" "pip"
|
||||
pyenv-which "virtualenv" 1>/dev/null 2>&1 || {
|
||||
VIRTUALENV_VERSION="==${VIRTUALENV_VERSION}"
|
||||
pyenv-exec pip install $QUIET $VERBOSE "virtualenv${VIRTUALENV_VERSION%==}"
|
||||
pyenv-rehash
|
||||
@@ -233,7 +228,6 @@ if [ -d "${VIRTUALENV_PATH}/bin" ]; then
|
||||
fi
|
||||
|
||||
if [ -n "$UPGRADE" ]; then
|
||||
require_executable "${VIRTUALENV_NAME}" "pip"
|
||||
PYENV_VERSION="${VIRTUALENV_NAME}" pyenv-exec pip freeze >"${UPGRADE_LIST}"
|
||||
mv -f "${VIRTUALENV_PATH}" "${UPGRADE_PATH}"
|
||||
fi
|
||||
@@ -269,7 +263,6 @@ fi
|
||||
## Migrate previously installed packages from requirements.txt
|
||||
if [ -n "$UPGRADE" ]; then
|
||||
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=$?
|
||||
if [ "$UPGRADE_STATUS" == "0" ]; then
|
||||
rm -f "${UPGRADE_LIST}"
|
||||
|
||||
Reference in New Issue
Block a user