mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-11 21:13:52 -05:00
Use -m venv instead of pyvenv executable (fixes #184)
This commit is contained in:
@@ -108,10 +108,7 @@ version() {
|
|||||||
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (conda ${version:-unknown})"
|
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (conda ${version:-unknown})"
|
||||||
else
|
else
|
||||||
if [ -n "$USE_PYVENV" ]; then
|
if [ -n "$USE_PYVENV" ]; then
|
||||||
version="$(pyenv-which pyvenv 2>/dev/null || true)"
|
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (python -m venv)"
|
||||||
version="${version#${PYENV_ROOT}/versions/}"
|
|
||||||
version="${version%/bin/pyvenv}"
|
|
||||||
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (pyvenv ${version:-unknown})"
|
|
||||||
else
|
else
|
||||||
version="$(pyenv-exec virtualenv --version 2>/dev/null || true)"
|
version="$(pyenv-exec virtualenv --version 2>/dev/null || true)"
|
||||||
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${version:-unknown})"
|
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${version:-unknown})"
|
||||||
@@ -126,7 +123,7 @@ usage() {
|
|||||||
pyenv-exec conda create --help 2>/dev/null || true
|
pyenv-exec conda create --help 2>/dev/null || true
|
||||||
else
|
else
|
||||||
if [ -n "${USE_PYVENV}" ]; then
|
if [ -n "${USE_PYVENV}" ]; then
|
||||||
pyenv-exec pyvenv --help 2>/dev/null || true
|
pyenv-exec python -m venv --help 2>/dev/null || true
|
||||||
else
|
else
|
||||||
pyenv-exec virtualenv --help 2>/dev/null || true
|
pyenv-exec virtualenv --help 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
@@ -144,11 +141,11 @@ detect_venv() {
|
|||||||
if [ -x "${prefix}/bin/virtualenv" ]; then
|
if [ -x "${prefix}/bin/virtualenv" ]; then
|
||||||
HAS_VIRTUALENV=1
|
HAS_VIRTUALENV=1
|
||||||
fi
|
fi
|
||||||
if [ -x "${prefix}/bin/pyvenv" ]; then
|
if "${prefix}/bin/python" -m venv --help 1>/dev/null 2>&1; then
|
||||||
HAS_PYVENV=1
|
HAS_PYVENV=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Use pyvenv only if there is pyvenv, virtualenv is not installed, and `-p` not given
|
# Use `python -m venv` only if there is venv available, virtualenv is not installed, and `-p` not given
|
||||||
if [ -n "${HAS_CONDA}" ]; then
|
if [ -n "${HAS_CONDA}" ]; then
|
||||||
USE_CONDA=1
|
USE_CONDA=1
|
||||||
else
|
else
|
||||||
@@ -371,7 +368,7 @@ REQUIREMENTS="${TMP}/requirements.${SEED}.txt"
|
|||||||
# Upgrade existing virtualenv
|
# Upgrade existing virtualenv
|
||||||
if [ -n "$UPGRADE" ]; then
|
if [ -n "$UPGRADE" ]; then
|
||||||
FORCE=1
|
FORCE=1
|
||||||
# pyvenv has `--upgrade` by default
|
# `python -m venv` has `--upgrade` by default
|
||||||
if [ -n "${USE_PYVENV}" ]; then
|
if [ -n "${USE_PYVENV}" ]; then
|
||||||
unset UPGRADE
|
unset UPGRADE
|
||||||
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--upgrade"
|
VIRTUALENV_OPTIONS[${#VIRTUALENV_OPTIONS[*]}]="--upgrade"
|
||||||
@@ -406,11 +403,11 @@ if [ -n "${USE_CONDA}" ]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ -n "${USE_PYVENV}" ]; then
|
if [ -n "${USE_PYVENV}" ]; then
|
||||||
# Unset some arguments not supported by pyvenv
|
# Unset some arguments not supported by `python -m venv`
|
||||||
unset QUIET
|
unset QUIET
|
||||||
unset VERBOSE
|
unset VERBOSE
|
||||||
if [ -n "${VIRTUALENV_PYTHON}" ]; then
|
if [ -n "${VIRTUALENV_PYTHON}" ]; then
|
||||||
echo "pyenv-virtualenv: \`--python=${VIRTUALENV_PYTHON}' is not supported by pyvenv." 1>&2
|
echo "pyenv-virtualenv: \`--python=${VIRTUALENV_PYTHON}' is not supported by \`python -m venv'." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -525,7 +522,7 @@ if [ -n "${USE_CONDA}" ]; then
|
|||||||
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" python || STATUS="$?"
|
pyenv-exec conda create $QUIET $VERBOSE --name "${VIRTUALENV_PATH##*/}" --yes "${VIRTUALENV_OPTIONS[@]}" python || STATUS="$?"
|
||||||
else
|
else
|
||||||
if [ -n "${USE_PYVENV}" ]; then
|
if [ -n "${USE_PYVENV}" ]; then
|
||||||
pyenv-exec pyvenv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
pyenv-exec python -m venv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
||||||
else
|
else
|
||||||
pyenv-exec virtualenv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
pyenv-exec virtualenv $QUIET $VERBOSE "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}" || STATUS="$?"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user