mirror of
https://github.com/pyenv/pyenv.git
synced 2026-08-04 03:20:35 +09:00
Merge commit from fork
This commit is contained in:
parent
e4c462dc70
commit
95df7dbc7b
@ -36,12 +36,16 @@ if [ -n "$versions" ]; then
|
|||||||
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
|
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
|
||||||
else
|
else
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
|
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
IFS=: versions=($(
|
IFS=: versions=($(
|
||||||
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
||||||
pyenv-version-file-read "${PYENV_ROOT}/global" ||
|
pyenv-version-file-read "${PYENV_ROOT}/global" ||
|
||||||
pyenv-version-file-read "${PYENV_ROOT}/default" ||
|
pyenv-version-file-read "${PYENV_ROOT}/default" ||
|
||||||
echo system
|
echo system
|
||||||
))
|
))
|
||||||
|
set +f
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
for version in "${versions[@]}"; do
|
for version in "${versions[@]}"; do
|
||||||
echo "$version"
|
echo "$version"
|
||||||
|
|||||||
@ -59,7 +59,11 @@ elif [ -n "$versions" ]; then
|
|||||||
pyenv-version-file-write ${FORCE:+-f }.python-version "${versions[@]}"
|
pyenv-version-file-write ${FORCE:+-f }.python-version "${versions[@]}"
|
||||||
else
|
else
|
||||||
if version_file="$(pyenv-version-file "$PWD")"; then
|
if version_file="$(pyenv-version-file "$PWD")"; then
|
||||||
|
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
IFS=: versions=($(pyenv-version-file-read "$version_file"))
|
IFS=: versions=($(pyenv-version-file-read "$version_file"))
|
||||||
|
set +f
|
||||||
for version in "${versions[@]}"; do
|
for version in "${versions[@]}"; do
|
||||||
echo "$version"
|
echo "$version"
|
||||||
done
|
done
|
||||||
|
|||||||
@ -28,6 +28,9 @@ fi
|
|||||||
PYENV_PREFIX_PATHS=()
|
PYENV_PREFIX_PATHS=()
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
{ IFS=:
|
{ IFS=:
|
||||||
|
# Unquoted $VAR does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
for version in ${PYENV_VERSION}; do
|
for version in ${PYENV_VERSION}; do
|
||||||
if [ "$version" = "system" ]; then
|
if [ "$version" = "system" ]; then
|
||||||
if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python --skip-advice 2>/dev/null)" || \
|
if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python --skip-advice 2>/dev/null)" || \
|
||||||
@ -52,6 +55,7 @@ OLDIFS="$IFS"
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
set +f
|
||||||
}
|
}
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,11 @@ set -e
|
|||||||
|
|
||||||
exitcode=0
|
exitcode=0
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
|
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$?
|
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name)) || exitcode=$?
|
||||||
|
set +f
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
unset bare
|
unset bare
|
||||||
|
|||||||
@ -46,6 +46,9 @@ versions=()
|
|||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
{ IFS=:
|
{ IFS=:
|
||||||
any_not_installed=0
|
any_not_installed=0
|
||||||
|
# Unquoted $VAR does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
for version in ${PYENV_VERSION}; do
|
for version in ${PYENV_VERSION}; do
|
||||||
# Remove the explicit 'python-' prefix from versions like 'python-3.12'.
|
# Remove the explicit 'python-' prefix from versions like 'python-3.12'.
|
||||||
normalised_version="${version#python-}"
|
normalised_version="${version#python-}"
|
||||||
@ -66,6 +69,7 @@ OLDIFS="$IFS"
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
set +f
|
||||||
}
|
}
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
|
|||||||
@ -99,6 +99,9 @@ else
|
|||||||
miss_prefix=" "
|
miss_prefix=" "
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
IFS=:
|
IFS=:
|
||||||
|
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
if ((${BASH_VERSINFO[0]} > 3)); then
|
if ((${BASH_VERSINFO[0]} > 3)); then
|
||||||
for i in $(pyenv-version-name || true); do
|
for i in $(pyenv-version-name || true); do
|
||||||
current_versions["$i"]="1"
|
current_versions["$i"]="1"
|
||||||
@ -106,6 +109,7 @@ else
|
|||||||
else
|
else
|
||||||
current_versions=($(pyenv-version-name || true))
|
current_versions=($(pyenv-version-name || true))
|
||||||
fi
|
fi
|
||||||
|
set +f
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
include_system="1"
|
include_system="1"
|
||||||
fi
|
fi
|
||||||
@ -161,11 +165,15 @@ versions_dir_entries=("$versions_dir"/*)
|
|||||||
if sort --version-sort </dev/null >/dev/null 2>&1; then
|
if sort --version-sort </dev/null >/dev/null 2>&1; then
|
||||||
# system sort supports version sorting
|
# system sort supports version sorting
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
|
# VAR=() of unquoted value does glob expansion (against the current dir's contents) after IFS-splitting
|
||||||
|
# which is undesired
|
||||||
|
set -f
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
versions_dir_entries=($(
|
versions_dir_entries=($(
|
||||||
printf "%s\n" "${versions_dir_entries[@]}" |
|
printf "%s\n" "${versions_dir_entries[@]}" |
|
||||||
sort --version-sort
|
sort --version-sort
|
||||||
))
|
))
|
||||||
|
set +f
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,11 @@ if [ -z "$PYENV_COMMAND" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
|
# Unquoted $VAR or VAR=() of unquoted value does glob expansion (against the current dir's contents)
|
||||||
|
# after IFS-splitting which is undesired
|
||||||
|
set -f
|
||||||
IFS=: versions=(${PYENV_VERSION:-$(pyenv-version-name -f)})
|
IFS=: versions=(${PYENV_VERSION:-$(pyenv-version-name -f)})
|
||||||
|
set +f
|
||||||
IFS="$OLDIFS"
|
IFS="$OLDIFS"
|
||||||
|
|
||||||
declare -a nonexistent_versions
|
declare -a nonexistent_versions
|
||||||
|
|||||||
@ -16,6 +16,14 @@ load test_helper
|
|||||||
assert_output "1.2.3"
|
assert_output "1.2.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
touch 1.1
|
||||||
|
mkdir -p "$PYENV_ROOT"
|
||||||
|
echo "[1-9].?*" > "$PYENV_ROOT/version"
|
||||||
|
run pyenv-global
|
||||||
|
assert_success "[1-9].?*"
|
||||||
|
}
|
||||||
|
|
||||||
@test "set PYENV_ROOT/version" {
|
@test "set PYENV_ROOT/version" {
|
||||||
mkdir -p "$PYENV_ROOT/versions/1.2.3"
|
mkdir -p "$PYENV_ROOT/versions/1.2.3"
|
||||||
run pyenv-global "1.2.3"
|
run pyenv-global "1.2.3"
|
||||||
|
|||||||
@ -19,6 +19,13 @@ _setup() {
|
|||||||
assert_success "1.2.3"
|
assert_success "1.2.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
touch 1.1
|
||||||
|
echo "[1-9].?*" > .python-version
|
||||||
|
run pyenv-local
|
||||||
|
assert_success "[1-9].?*"
|
||||||
|
}
|
||||||
|
|
||||||
@test "discovers version file in parent directory" {
|
@test "discovers version file in parent directory" {
|
||||||
echo "1.2.3" > .python-version
|
echo "1.2.3" > .python-version
|
||||||
mkdir -p "subdir" && cd "subdir"
|
mkdir -p "subdir" && cd "subdir"
|
||||||
|
|||||||
@ -16,6 +16,12 @@ load test_helper
|
|||||||
assert_failure "pyenv: version \`1.2.3' not installed"
|
assert_failure "pyenv: version \`1.2.3' not installed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
touch 1.1
|
||||||
|
PYENV_VERSION="[1-9].?*" run pyenv-prefix
|
||||||
|
assert_failure "pyenv: version \`[1-9].?*' not installed"
|
||||||
|
}
|
||||||
|
|
||||||
@test "prefix for system" {
|
@test "prefix for system" {
|
||||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||||
touch "${PYENV_TEST_DIR}/bin/python"
|
touch "${PYENV_TEST_DIR}/bin/python"
|
||||||
|
|||||||
@ -22,6 +22,14 @@ _setup() {
|
|||||||
assert_success "system"
|
assert_success "system"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
touch 1.1
|
||||||
|
PYENV_VERSION="[1-9].?*" run pyenv-version-name
|
||||||
|
assert_failure <<'!'
|
||||||
|
pyenv: version `[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
|
||||||
|
!
|
||||||
|
}
|
||||||
|
|
||||||
@test "PYENV_VERSION can be overridden by hook" {
|
@test "PYENV_VERSION can be overridden by hook" {
|
||||||
create_version "2.7.11"
|
create_version "2.7.11"
|
||||||
create_version "3.5.1"
|
create_version "3.5.1"
|
||||||
|
|||||||
@ -79,3 +79,12 @@ OUT
|
|||||||
3.3.3
|
3.3.3
|
||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
touch 1.1
|
||||||
|
PYENV_VERSION="[1-9].?*" run pyenv-version
|
||||||
|
assert_failure
|
||||||
|
assert_output <<OUT
|
||||||
|
pyenv: version \`[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|||||||
@ -63,6 +63,18 @@ OUT
|
|||||||
assert_success "3.3"
|
assert_success "3.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
stub_system_python
|
||||||
|
create_version "[1-9].?*"
|
||||||
|
touch 1.1
|
||||||
|
run pyenv-versions
|
||||||
|
assert_success
|
||||||
|
assert_output <<OUT
|
||||||
|
* system (set by ${PYENV_ROOT}/version)
|
||||||
|
[1-9].?*
|
||||||
|
OUT
|
||||||
|
}
|
||||||
|
|
||||||
@test "multiple versions and envs" {
|
@test "multiple versions and envs" {
|
||||||
stub_system_python
|
stub_system_python
|
||||||
create_version "2.7.6"
|
create_version "2.7.6"
|
||||||
|
|||||||
@ -90,6 +90,17 @@ Note: See 'pyenv help global' for tips on allowing multiple
|
|||||||
OUT
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "version with glob characters is handled correctly" {
|
||||||
|
bats_require_minimum_version 1.5.0
|
||||||
|
touch 1.1
|
||||||
|
PATH="$(path_without foo)" PYENV_VERSION="[1-9].?*" run -127 pyenv-which foo
|
||||||
|
assert_failure
|
||||||
|
assert_output <<!
|
||||||
|
pyenv: version \`[1-9].?*' is not installed (set by PYENV_VERSION environment variable)
|
||||||
|
pyenv: foo: command not found
|
||||||
|
!
|
||||||
|
}
|
||||||
|
|
||||||
@test "no executable found" {
|
@test "no executable found" {
|
||||||
bats_require_minimum_version 1.5.0
|
bats_require_minimum_version 1.5.0
|
||||||
create_alt_executable_in_version "2.7" "py.test"
|
create_alt_executable_in_version "2.7" "py.test"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user