1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-08 11:33:49 -05:00

Compare commits

...

16 Commits

Author SHA1 Message Date
Ivan Pozdeev
2b22145670 2.3.4 2022-09-04 01:54:33 +03:00
Filip Š
7c1c180551 Add Cinder 3.8 (#2433)
* Add Cinder 3.8
* Add distro and GCC warnings
* Set the complier to GCC 10 if available

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2022-09-04 01:48:43 +03:00
native-api
a648682ed6 CI: Bump OS versions (#2448)
* CI: Bump OS versions

Github released ubuntu-22.04 and macos-12 from beta
and deprecated ubuntu-18.04 and macos-10.15, due to dropping by 2013.

* CI: clean up installed packages
2022-09-04 01:40:00 +03:00
James Stronz
47b0ce77c0 Re-allow paths in .python-version provided that they resolve to within the versions dir (#2442)
* Fixes #2430 while still preventing CVE-2022-35861
* Adds a skipped version message to stderr

Co-authored-by: Ivan Pozdeev <vano@mail.mipt.ru>
2022-09-03 22:37:53 +03:00
Ivan Pozdeev
fdabd14c2b Merge branch 'master' of https://github.com/pyenv/pyenv 2022-09-03 22:31:15 +03:00
Ivan Pozdeev
e52ad61389 CI: Bump versions 2022-09-03 22:31:00 +03:00
native-api
2e5983b004 Merge pull request #2447 from native-api/ci_modified_micropython
CI: support Micropython, deleted scripts; build with -v
2022-09-03 22:22:56 +03:00
Ivan Pozdeev
27b5f62dfb CI: Build with -v 2022-09-03 22:02:47 +03:00
Ivan Pozdeev
7c1e3a710c CI: Support Micropython 2022-09-03 22:02:47 +03:00
Ivan Pozdeev
13f273188d CI: Exclude deleted scripts from modified check 2022-09-03 22:02:47 +03:00
Dmitriy Serdyuk
c89a69a6ed Add micropython 1.18 and 1.19.1 (#2443)
Support frozen builtin modules e.g. upip
2022-09-01 13:48:26 +03:00
native-api
a8afc61146 CONTRIBUTING.md: phrasing 2022-08-16 21:33:49 +03:00
native-api
e4a0c12b1b CONTRIBUTING.md: clarify that Bash 4+ optimizations are allowed 2022-08-16 21:32:14 +03:00
hardikpnsp
afeb971fa2 Add support for multiple versions in pyenv uninstall (#2432) 2022-08-15 20:25:46 +03:00
Edgar R. M
965421d5d4 Add CPython 3.11.0rc1 (#2434) 2022-08-14 15:12:22 +03:00
Janith Petangoda
ae22c69505 Small update to instruction in README.md (#2431) 2022-08-06 18:12:11 +03:00
21 changed files with 276 additions and 103 deletions

View File

@@ -6,11 +6,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- 3.7.10
- 3.8.10
- 3.9.5
- 3.10.0
runs-on: macos-10.15
- 3.7.13
- 3.8.13
- 3.9.13
- 3.10.6
runs-on: macos-11
steps:
- uses: actions/checkout@v2
# Normally, we would use the superbly maintained...
@@ -27,7 +27,7 @@ jobs:
run: |
echo $PYENV_ROOT
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
bin/pyenv install ${{ matrix.python-version }}
bin/pyenv install -v ${{ matrix.python-version }}
bin/pyenv global ${{ matrix.python-version }}
bin/pyenv rehash
- run: python --version

View File

@@ -12,7 +12,7 @@ jobs:
run: >
versions=$(git diff "origin/$GITHUB_BASE_REF" --name-only -z
| perl -ne 'BEGIN {$\="\n";$/="\0";} chomp;
if (/^plugins\/python-build\/share\/python-build\/(?:([^\/]+)|patches\/([^\/]+)\/.*)$/)
if (/^plugins\/python-build\/share\/python-build\/(?:([^\/]+)|patches\/([^\/]+)\/.*)$/ and -e $& )
{ print $1.$2; }' \
| sort -u);
echo -e "versions<<!\\n$versions\\n!" >> $GITHUB_ENV
@@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions)}}
os: ["macos-10.15", "macos-11"]
os: ["macos-11", "macos-12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
@@ -38,22 +38,33 @@ jobs:
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
- run: |
pyenv install ${{ matrix.python-version }}
pyenv install -v ${{ matrix.python-version }}
pyenv global ${{ matrix.python-version }}
- run: |
python --version
python -m pip --version
- shell: python # Prove that actual Python == expected Python
env:
# Micropython doesn't support --version
- run: >
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
python -c 'import sys; print(sys.version)'
else
python --version;
python -m pip --version
fi
# Micropython doesn't support sys.executable, os.path, older versions even os
- env:
EXPECTED_PYTHON: ${{ matrix.python-version }}
run: |
import os, sys, os.path
correct_dir = os.path.join(
os.environ['PYENV_ROOT'],
'versions',
os.environ['EXPECTED_PYTHON'],
'bin')
assert os.path.dirname(sys.executable) == correct_dir
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
[[ $(pyenv which python) == "${{ env.PYENV_ROOT }}/versions/${{ matrix.python-version }}/bin/python" ]] || exit 1
python -c 'import sys; assert sys.implementation.name == "micropython"'
else
python -c 'if True:
import os, sys, os.path
correct_dir = os.path.join(
os.environ["PYENV_ROOT"],
"versions",
os.environ["EXPECTED_PYTHON"],
"bin")
assert os.path.dirname(sys.executable) == correct_dir'
fi
# bundled executables in some Anaconda releases cause the post-run step to hang in MacOS
- run: |
pyenv global system
@@ -66,32 +77,44 @@ jobs:
fail-fast: false
matrix:
python-version: ${{fromJson(needs.discover_modified_scripts.outputs.versions)}}
os: ["ubuntu-18.04", "ubuntu-20.04"]
os: ["ubuntu-20.04", "ubuntu-22.04"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: |
sudo apt-get update -q; sudo apt-get install -yq build-essential \
sudo apt-get update -q; sudo apt-get install -yq make build-essential \
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \
wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev
- run: |
export PYENV_ROOT="$GITHUB_WORKSPACE"
echo "PYENV_ROOT=$PYENV_ROOT" >> $GITHUB_ENV
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
- run: |
pyenv install ${{ matrix.python-version }}
pyenv install -v ${{ matrix.python-version }}
pyenv global ${{ matrix.python-version }}
- run: python --version
- run: python -m pip --version
- shell: python # Prove that actual Python == expected Python
env:
# Micropython doesn't support --version
- run: >
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
python -c 'import sys; print(sys.version)'
else
python --version;
python -m pip --version
fi
# Micropython doesn't support sys.executable, os.path, older versions even os
- env:
EXPECTED_PYTHON: ${{ matrix.python-version }}
run: |
import os, sys, os.path
correct_dir = os.path.join(
os.environ['PYENV_ROOT'],
'versions',
os.environ['EXPECTED_PYTHON'],
'bin')
assert os.path.dirname(sys.executable) == correct_dir
if [[ "${{ matrix.python-version }}" == "micropython-"* ]]; then
[[ $(pyenv which python) == "${{ env.PYENV_ROOT }}/versions/${{ matrix.python-version }}/bin/python" ]] || exit 1
python -c 'import sys; assert sys.implementation.name == "micropython"'
else
python -c 'if True:
import os, sys, os.path
correct_dir = os.path.join(
os.environ["PYENV_ROOT"],
"versions",
os.environ["EXPECTED_PYTHON"],
"bin")
assert os.path.dirname(sys.executable) == correct_dir'
fi

View File

@@ -6,10 +6,10 @@ jobs:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-20.04
- ubuntu-18.04
- macos-12
- macos-11
- macos-10.15
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

View File

@@ -6,11 +6,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- 3.7.10
- 3.8.10
- 3.9.5
- 3.10.0
runs-on: Ubuntu-20.04
- 3.7.13
- 3.8.13
- 3.9.13
- 3.10.6
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Normally, we would use the superbly maintained...
@@ -19,9 +19,9 @@ jobs:
# python-version: ${{ matrix.python-version }}
# ... but in the repo, we want to test pyenv builds on Ubuntu
- run: |
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
sudo apt-get install -yq make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
# https://github.com/pyenv/pyenv#installation
- run: pwd
- env:
@@ -29,7 +29,7 @@ jobs:
run: |
echo $PYENV_ROOT
echo "$PYENV_ROOT/shims:$PYENV_ROOT/bin" >> $GITHUB_PATH
bin/pyenv install ${{ matrix.python-version }}
bin/pyenv install -v ${{ matrix.python-version }}
bin/pyenv global ${{ matrix.python-version }}
bin/pyenv rehash
- run: python --version

View File

@@ -1,5 +1,15 @@
## Version History
## Release 2.3.4
* Add CPython 3.11.0rc1 (#2434)
* Add support for multiple versions in `pyenv uninstall` (#2432)
* Add micropython 1.18 and 1.19.1 (#2443)
* CI: support Micropython, deleted scripts; build with -v (#2447)
* Re-allow paths in .python-version while still preventing CVE-2022-35861 (#2442)
* CI: Bump OS versions (#2448)
* Add Cinder 3.8 (#2433)
## Release 2.3.3
* Use version sort in `pyenv versions` (#2405)

View File

@@ -238,9 +238,9 @@ To install the latest major release for Python 3 try:
## `pyenv uninstall`
Uninstall a specific Python version.
Uninstall Python versions.
Usage: pyenv uninstall [-f|--force] <version>
Usage: pyenv uninstall [-f|--force] <version> ...
-f Attempt to remove the specified version without prompting
for confirmation. If the version does not exist, do not

View File

@@ -9,6 +9,9 @@ General guidance
That's because that's the version shipped with MacOS.
(They didn't upgrade past it and switched to Zsh because later versions
are covered by GPLv3 which has additional restrictions unacceptable for Apple.)
You can still add performance optimizations etc that take advantage of newer Bash features
as long as there is a fallback execution route for Bash 3.
* Be extra careful when submitting logic specific for the Apple Silicon platform

View File

@@ -288,7 +288,7 @@ See [Advanced configuration](#advanced-configuration) for details and more confi
configuration commands to both `.bashrc` (for interactive shells)
and the profile file that Bash would use (for login shells).
First, add the commands to `~/.bashrc`:
First, add the commands to `~/.bashrc` by running the following in your terminal:
~~~ bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
@@ -432,7 +432,7 @@ for more details on how the selection works and more information on its usage.
As time goes on, you will accumulate Python versions in your
`$(pyenv root)/versions` directory.
To remove old Python versions, use [`pyenv uninstall <version>`](COMMANDS.md#pyenv-uninstall).
To remove old Python versions, use [`pyenv uninstall <versions>`](COMMANDS.md#pyenv-uninstall).
Alternatively, you can simply `rm -rf` the directory of the version you want
to remove. You can find the directory of a particular Python version

View File

@@ -12,7 +12,7 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
version="2.3.3"
version="2.3.4"
git_revision=""
if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q pyenv; then

View File

@@ -5,18 +5,33 @@ set -e
VERSION_FILE="$1"
function is_version_safe() {
# As needed, check that the constructed path exists as a child path of PYENV_ROOT/versions
version="$1"
if [[ "$version" == ".." || "$version" == */* ]]; then
# Sanity check the value of version to prevent malicious path-traversal
(
cd "$PYENV_ROOT/versions/$version" &>/dev/null || exit 1
[[ "$PWD" == "$PYENV_ROOT/versions/"* ]]
)
return $?
else
return 0
fi
}
if [ -s "$VERSION_FILE" ]; then
# Read the first non-whitespace word from the specified version file.
# Be careful not to load it whole in case there's something crazy in it.
IFS="${IFS}"$'\r'
IFS="$IFS"$'\r'
sep=
while read -n 1024 -r version _ || [[ $version ]]; do
if [[ -z $version || $version == \#* ]]; then
if [[ -z "$version" || "$version" == \#* ]]; then
# Skip empty lines and comments
continue
elif [ "$version" = ".." ] || [[ $version == */* ]]; then
# The version string is used to construct a path and we skip dubious values.
# This prevents issues such as path traversal (CVE-2022-35861).
elif ! is_version_safe "$version"; then
# CVE-2022-35861 allowed arbitrary code execution in some contexts and is mitigated by is_version_safe.
echo "pyenv: invalid version \`$version' ignored in \`$VERSION_FILE'" >&2
continue
fi
printf "%s%s" "$sep" "$version"

View File

@@ -106,7 +106,7 @@ Set or show the shell\-specific Python version
List existing pyenv shims
.TP
.B uninstall
Uninstall a specific Python version
Uninstall Python versions
.TP
.B version
Show the current Python version(s) and its origin
@@ -452,10 +452,10 @@ $ pyenv versions
.fi
.IP "" 0
.SS "pyenv uninstall"
Uninstall a specific Python version\.
Uninstall Python versions\.
.IP "" 4
.nf
Usage: pyenv uninstall [\-f|\-\-force] <version>
Usage: pyenv uninstall [\-f|\-\-force] <version> ...
\-f Attempt to remove the specified version without prompting
for confirmation\. If the version does not exist, do not

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env bash
#
# Summary: Uninstall a specific Python version
# Summary: Uninstall Python versions
#
# Usage: pyenv uninstall [-f|--force] <version>
# Usage: pyenv uninstall [-f|--force] <version> ...
#
# -f Attempt to remove the specified version without prompting
# for confirmation. If the version does not exist, do not
@@ -33,14 +33,17 @@ if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
shift
fi
[ "$#" -eq 1 ] || usage 1 >&2
[ "$#" -gt 0 ] || usage 1 >&2
DEFINITION="$1"
case "$DEFINITION" in
"" | -* )
usage 1 >&2
;;
esac
versions=("$@")
for version in "${versions[@]}"; do
case "$version" in
"" | -* )
usage 1 >&2
;;
esac
done
declare -a before_hooks after_hooks
@@ -59,29 +62,36 @@ IFS=$'\n' scripts=(`pyenv-hooks uninstall`)
IFS="$OLDIFS"
for script in "${scripts[@]}"; do source "$script"; done
uninstall-python() {
local DEFINITION="$1"
VERSION_NAME="${DEFINITION##*/}"
PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
local VERSION_NAME="${DEFINITION##*/}"
local PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
if [ -z "$FORCE" ]; then
if [ ! -d "$PREFIX" ]; then
echo "pyenv: version \`$VERSION_NAME' not installed" >&2
exit 1
if [ -z "$FORCE" ]; then
if [ ! -d "$PREFIX" ]; then
echo "pyenv: version \`$VERSION_NAME' not installed" >&2
exit 1
fi
read -p "pyenv: remove $PREFIX? [y|N] "
case "$REPLY" in
y | Y | yes | YES ) ;;
* ) exit 1 ;;
esac
fi
read -p "pyenv: remove $PREFIX? [y|N] "
case "$REPLY" in
y | Y | yes | YES ) ;;
* ) exit 1 ;;
esac
fi
for hook in "${before_hooks[@]}"; do eval "$hook"; done
for hook in "${before_hooks[@]}"; do eval "$hook"; done
if [ -d "$PREFIX" ]; then
rm -rf "$PREFIX"
pyenv-rehash
echo "pyenv: $VERSION_NAME uninstalled"
fi
if [ -d "$PREFIX" ]; then
rm -rf "$PREFIX"
pyenv-rehash
echo "pyenv: $VERSION_NAME uninstalled"
fi
for hook in "${after_hooks[@]}"; do eval "$hook"; done
}
for hook in "${after_hooks[@]}"; do eval "$hook"; done
for version in "${versions[@]}"; do
uninstall-python "$version"
done

View File

@@ -899,7 +899,7 @@ build_package_micropython() {
"$MAKE" $MAKE_OPTS
cd ../ports/unix
"$MAKE" $MAKE_OPTS axtls
"$MAKE" $MAKE_OPTS CFLAGS_EXTRA="-DMICROPY_PY_SYS_PATH_DEFAULT='\"${PREFIX_PATH}/lib/micropython\"' $CFLAGS_EXTRA"
"$MAKE" $MAKE_OPTS CFLAGS_EXTRA="-DMICROPY_PY_SYS_PATH_DEFAULT='\".frozen:${PREFIX_PATH}/lib/micropython\"' $CFLAGS_EXTRA"
"$MAKE" install $MAKE_INSTALL_OPTS PREFIX="${PREFIX_PATH}"
ln -fs micropython "${PREFIX_PATH}/bin/python"
mkdir -p "${PREFIX_PATH}/lib/micropython"

View File

@@ -3,7 +3,7 @@ export PYTHON_BUILD_CONFIGURE_WITH_OPENSSL=1
install_package "openssl-1.1.1n" "https://www.openssl.org/source/openssl-1.1.1n.tar.gz#40dceb51a4f6a5275bde0e6bf20ef4b91bfc32ed57c0552e2e8e15463372b17a" mac_openssl --if has_broken_mac_openssl
install_package "readline-8.0" "https://ftpmirror.gnu.org/readline/readline-8.0.tar.gz#e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461" mac_readline --if has_broken_mac_readline
if has_tar_xz_support; then
install_package "Python-3.11.0b5" "https://www.python.org/ftp/python/3.11.0/Python-3.11.0b5.tar.xz#3810bd22f7dc34a99c2a2eb4b85264a4df4f05ef59c4e0ccc2ea82ee9c491698" standard verify_py311 copy_python_gdb ensurepip
install_package "Python-3.11.0rc1" "https://www.python.org/ftp/python/3.11.0/Python-3.11.0rc1.tar.xz#53a5377c37a8a2c6da075b14eb9d63374579f7f3c718fa20f0a1fbb0e94a922b" standard verify_py311 copy_python_gdb ensurepip
else
install_package "Python-3.11.0b5" "https://www.python.org/ftp/python/3.11.0/Python-3.11.0b5.tgz#3f7d1a4ab0e64425f4ffd92d49de192ad2ee1c62bc52e3877e9f7b254c702e60" standard verify_py311 copy_python_gdb ensurepip
install_package "Python-3.11.0rc1" "https://www.python.org/ftp/python/3.11.0/Python-3.11.0rc1.tgz#456f32a8d66e7cae226478a74c3ebb358bae09eba0b8537f47d7b2790f65a1f0" standard verify_py311 copy_python_gdb ensurepip
fi

View File

@@ -0,0 +1,31 @@
require_distro Fedora 32 &>/dev/null || \
{ echo
colorize 1 "WARNING"
cat >&2 <<!
: The Cinder compiler only officially supports
Facebook's Docker images which are Fedora 32 - based.
It may fail to build on a system
with a different GCC and/or Glibc version.
!
echo
}
[[ $(${CC:-gcc} -dumpversion 2>/dev/null) == 10 ]] || \
{ command -v "gcc-10" >/dev/null && \
export CC="gcc-10" && \
echo "python-build: setting the compiler to \`gcc-10'"; } || \
{
echo
colorize 1 WARNING
cat >&2 <<!
: GCC 10 is not found on PATH.
The build may fail.
!
echo
}
prefer_openssl11
export PYTHON_BUILD_CONFIGURE_WITH_OPENSSL=1
install_package "openssl-1.1.1k" "https://www.openssl.org/source/openssl-1.1.1k.tar.gz#892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5" mac_openssl --if has_broken_mac_openssl
install_package "readline-8.0" "https://ftpmirror.gnu.org/readline/readline-8.0.tar.gz#e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461" mac_readline --if has_broken_mac_readline
install_git "Cinder-3.8-dev" "https://github.com/facebookincubator/cinder" "cinder/3.8" standard verify_py38 copy_python_gdb ensurepip

View File

@@ -0,0 +1,4 @@
has_tar_xz_support \
&& { install=install_package; src="https://micropython.org/resources/source/micropython-1.18.tar.xz#96fc71b42ed331c64e1adc5a830ec4f29f2975c23e8751109c03f32b80fa3eb4"; } \
|| { install=install_zip; src="https://micropython.org/resources/source/micropython-1.18.zip#90fa8049cf275310638b9e9c77121f6042f7250b814ef622f9522befde009f57"; }
$install micropython-1.18 "$src" micropython

View File

@@ -0,0 +1,4 @@
has_tar_xz_support \
&& { install=install_package; src="https://micropython.org/resources/source/micropython-1.19.1.tar.xz#940e3815e8c425c6eaed3a2aa30d320220cc012a2654b6e086e1b6f0567df350"; } \
|| { install=install_zip; src="https://micropython.org/resources/source/micropython-1.19.1.zip#7047ce208627457c6881850527edb78189a1855a974aa34e2d929c9a3b3c5cc3"; }
$install micropython-1.19.1 "$src" micropython

View File

@@ -115,6 +115,6 @@ DEF
#assert_success
assert_output <<OUT
CFLAGS_EXTRA=-DMICROPY_PY_SYS_PATH_DEFAULT='"${TMP}/install/lib/micropython"' -Wno-floating-conversion
CFLAGS_EXTRA=-DMICROPY_PY_SYS_PATH_DEFAULT='".frozen:${TMP}/install/lib/micropython"' -Wno-floating-conversion
OUT
}

View File

@@ -55,3 +55,38 @@ OUT
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
}
@test "pyenv-uninstall hooks with multiple versions" {
cat > "${HOOK_PATH}/uninstall.bash" <<OUT
before_uninstall 'echo before: \$PREFIX'
after_uninstall 'echo after.'
rm() {
echo "rm \$@"
command rm "\$@"
}
OUT
stub pyenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
stub pyenv-rehash "echo rehashed"
stub pyenv-rehash "echo rehashed"
mkdir -p "${PYENV_ROOT}/versions/3.6.2"
mkdir -p "${PYENV_ROOT}/versions/3.6.3"
run pyenv-uninstall -f 3.6.2 3.6.3
assert_success
assert_output <<-OUT
before: ${PYENV_ROOT}/versions/3.6.2
rm -rf ${PYENV_ROOT}/versions/3.6.2
rehashed
pyenv: 3.6.2 uninstalled
after.
before: ${PYENV_ROOT}/versions/3.6.3
rm -rf ${PYENV_ROOT}/versions/3.6.3
rehashed
pyenv: 3.6.3 uninstalled
after.
OUT
refute [ -d "${PYENV_ROOT}/versions/3.6.2" ]
refute [ -d "${PYENV_ROOT}/versions/3.6.3" ]
}

View File

@@ -195,12 +195,28 @@ OUT
unstub pyenv-help
}
@test "too many arguments for pyenv-uninstall" {
stub pyenv-help 'uninstall : true'
@test "more than one argument for pyenv-uninstall" {
mkdir -p "${PYENV_ROOT}/versions/3.4.1"
mkdir -p "${PYENV_ROOT}/versions/3.4.2"
run pyenv-uninstall -f 3.4.1 3.4.2
run pyenv-uninstall 3.4.1 3.4.2
assert_success
refute [ -d "${PYENV_ROOT}/versions/3.4.1" ]
refute [ -d "${PYENV_ROOT}/versions/3.4.2" ]
}
@test "invalid arguments for pyenv-uninstall" {
mkdir -p "${PYENV_ROOT}/versions/3.10.3"
mkdir -p "${PYENV_ROOT}/versions/3.10.4"
run pyenv-uninstall -f 3.10.3 --invalid-option 3.10.4
assert_failure
unstub pyenv-help
assert [ -d "${PYENV_ROOT}/versions/3.10.3" ]
assert [ -d "${PYENV_ROOT}/versions/3.10.4" ]
rmdir "${PYENV_ROOT}/versions/3.10.3"
rmdir "${PYENV_ROOT}/versions/3.10.4"
}
@test "show help for pyenv-uninstall" {

View File

@@ -83,14 +83,36 @@ IN
assert_success "3.9.3:3.8.9:2.7.16"
}
@test "skips relative path traversal" {
@test "skips \`..' relative path traversal" {
echo '..' > my-version
run pyenv-version-file-read my-version
assert_failure "pyenv: invalid version \`..' ignored in \`my-version'"
}
@test "skips glob path traversal" {
cat > my-version <<IN
../*
3.9.3
3.8.9
..
./*
2.7.16
IN
run pyenv-version-file-read my-version
assert_success "3.9.3:3.8.9:2.7.16"
assert_success <<OUT
pyenv: invalid version \`../\*' ignored in \`my-version'
3.9.3
OUT
}
@test "allows relative paths that exist and stay within versions" {
venv=3.10.3/envs/../test
mkdir -p "${PYENV_ROOT}/versions/${venv}"
echo -n "${venv}" > my-version
run pyenv-version-file-read my-version
assert_success "${venv}"
}
@test "skips relative paths that lead outside of versions" {
venv=../3.10.3/envs/test
mkdir -p "${PYENV_ROOT}/versions/${venv}"
echo -n "${venv}" > my-version
run pyenv-version-file-read my-version
assert_failure
}