1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-12 21:33:54 -05:00

Compare commits

...

47 Commits

Author SHA1 Message Date
Josh Friend
b55ac8cd78 v20160310 2016-03-10 20:28:11 -05:00
Josh Friend
4684507021 Add PyPy 5.0.0
closes #555
2016-03-10 19:37:50 -05:00
Yamashita, Yuu
12069a1118 Merge pull request #549 from yyuu/rbenv-1.0
rbenv 1.0+
2016-03-04 09:37:56 +09:00
Yamashita, Yuu
30538b0672 Fix broken tests for pyenv---version
I need to use release date versioning at least for now until preparing
custom version comparator for brew's formula.
2016-03-04 00:31:04 +00:00
Yamashita, Yuu
fd893ea3b0 Fix broken test for pyenv-version-name 2016-03-04 00:10:48 +00:00
Yamashita, Yuu
be3fc6d8cb Fix broken pyenv local 2016-03-04 00:00:53 +00:00
Yamashita, Yuu
41ce3aade2 Merge remote-tracking branch 'rbenv/master' into rbenv-1.0 2016-03-02 01:39:52 +00:00
Sam Stephenson
29b4da7737 Adopt Contributor Covenant 1.4 2016-02-19 12:28:40 -06:00
Mislav Marohnić
ad7dfa63ab Merge pull request #870 from davidcelis/patch-1
Update `rbenv init` instructions
2016-02-15 10:23:29 +13:00
David Celis
35ca51fe88 Update rbenv init instructions
The README details `eval`ing `rbenv init -`, but for some shells (such as fish) there's a difference in what should be run. It turns out that `rbenv init` on its own will print correct instructions, so we should point users to running that command instead.
2016-02-14 09:08:00 -08:00
Mislav Marohnić
d6ab394efd Merge pull request #863 from ErikAGriffin/patch-1
Updated Mac OSX brew install command
2016-02-01 22:48:28 +11:00
Erik Griffn
d29ba1f80e Updated Mac OSX brew install command
It seems rbenv now comes with ruby-build.  I have not investigated fully, but the previously shown command: `brew install rbenv ruby-build` caused issues on my machine.  After uninstalling both and simply running `brew install rbenv` everything worked fine.
2016-02-01 11:17:56 +00:00
Mislav Marohnić
c38833179b Merge pull request #852 from jasonkarns/extract-hook-helper
Extract hook helper
2016-01-04 18:48:10 +01:00
Jason Karns
565798d617 Test IFS handling in version-name/version-origin hooks 2016-01-04 09:14:28 -05:00
Jason Karns
0f7a2cad8d Use create_hook helper
Use extracted create_hook helper in tests for:

- exec
- hooks
- rehash
- version-name
- version-origin
- which
2016-01-04 09:14:25 -05:00
Jason Karns
5ccba5d7cc Extract common create_hook helper 2016-01-04 09:14:04 -05:00
Jason Karns
2cc2ec160e Remove redundant test
Spaces in hook path is tested in test/hooks.bats
2016-01-04 09:13:58 -05:00
Mislav Marohnić
a95ccd09a2 Simplify fallback to global version file 2015-12-29 14:44:32 +01:00
Mislav Marohnić
e199a3d8f7 Merge pull request #850 from jasonkarns/remove-legacy-global-version-file
Remove support for legacy global version files
2015-12-29 14:40:37 +01:00
Mislav Marohnić
fec0f56d0b Merge pull request #849 from jasonkarns/remove-legacy-version-file-handling
Remove all handling/support of .rbenv-version files
2015-12-29 14:34:08 +01:00
Jason Karns
fe809ea90d Remove support for legacy global version files
`default` was made legacy back in 2011 with
5be66da9f4 (the command was renamed from
`rbenv-default` to `rbenv-global`, and so the global file was renamed
from `$RBENV_ROOT/default` to `$RBENV_ROOT/global` (the latter taking
precedence)

`global` was then made legacy about a month later in Sep 2011 when the
preferred filename was changed to `$RBENV_ROOT/version`.
2015-12-28 22:05:00 -05:00
Jason Karns
f880dc6d6f Remove support for legacy version file 2015-12-28 21:34:07 -05:00
Jason Karns
3c9674453f fix local --unset test 2015-12-28 21:33:50 -05:00
Mislav Marohnić
22f4980a21 🔥 deprecated ruby-local-exec
It was useless for a while now. I should have nuked it prior to the
1.0.0 release but I forgot :(
2015-12-25 00:26:46 +01:00
Mislav Marohnić
abbcde665c Fix ToC level
[ci skip]
2015-12-24 20:02:37 +01:00
Mislav Marohnić
c9c9415154 Update ToC 2015-12-24 20:01:36 +01:00
Mislav Marohnić
3997a394d9 rbenv 1.0.0 2015-12-24 19:12:47 +01:00
Mislav Marohnić
e0b85397c8 Point out that it's not necessary to sudo gem install
Closes #532
2015-12-24 19:12:47 +01:00
Mislav Marohnić
e554cd86c3 Strip leading : from RBENV_HOOK_PATH 2015-12-24 19:12:47 +01:00
Mislav Marohnić
38692f97fe vim ignores, the-silver-searcher ignores 2015-12-24 18:18:44 +01:00
Mislav Marohnić
7e5680a0d8 Add configure + make step to installation instructions
This compiles the `realpath` dynamic extension for bash which speeds up
symlink resolution. If the extension doesn't compile due to
cross-platform issues, rbenv will still work normally, although not as fast.
2015-12-24 18:04:17 +01:00
Mislav Marohnić
d51f6d4376 Merge branch 'detect-shell-from-script'
Closes #730
2015-12-24 13:24:54 +01:00
Mislav Marohnić
a9a9636d1e Tweak sanitizing shell name
Handles situation when the output is `/bin/shell- args...`. First strip
away the arguments, then the trailing dash.
2015-12-24 13:23:01 +01:00
Daniel Hahler
32030e2ed9 Fix shell version when invoked from a script
When invoked from a shell script, `$(rbenv init -)` did not get the
shell name correct.
It needs to look at the `args` value from `ps`.

Ref: https://github.com/yyuu/pyenv/issues/373
2015-12-24 13:21:22 +01:00
Mislav Marohnić
f9d8b551dc Add test for detecting shell when rbenv init is called from script
References #730
2015-12-24 13:20:49 +01:00
Mislav Marohnić
2c7960102c Simplify reference to realpath.dylib within rbenv-versions
The `../libexec` dance isn't necessary here. It was only necessary in
main `rbenv` command because that one might have been pointed to
directly via a symlink.
2015-12-24 03:54:32 +01:00
Mislav Marohnić
1a0be6f0ad Improve git --version git revision lookup
It doesn't try to chdir into RBENV_ROOT anymore because that might be
a location of an unrelated rbenv install that might have a different
version than the current one that is installed e.g. via a package
manager such as Homebrew.

Now just tries the repo where the source files (`libexec/*`) are
located, and if that isn't a valid rbenv repo, bail out early.
2015-12-24 03:52:33 +01:00
Mislav Marohnić
6481cbb172 Merge branch 'version-hooks'
Closes #739
2015-12-23 17:42:44 +01:00
Mislav Marohnić
6e30032278 Simplify version-name, version-origin hook tests
No need for helper function that's gonna be used just once.
2015-12-23 17:39:14 +01:00
Mislav Marohnić
4fde4ecbaf Ensure RBENV_VERSION_ORIGIN is not inherited from environment
It's only supposed to be set from `version-origin` hooks, but not
inherited from environment in case it was set.
2015-12-23 17:26:53 +01:00
Mislav Marohnić
40c1d27445 Merge remote-tracking branch 'origin/master' into version-hooks 2015-12-23 17:22:43 +01:00
Jason Karns
97f0499f43 add version-name/version-origin to hooks completion 2015-12-23 17:22:31 +01:00
Jason Karns
c3a5f91ed0 create hook: version-origin
Expose a `version-origin` hook.

It is invoked *before* the traditional `rbenv-version-file` lookup. Because `version-origin` is traditionally run immediately after `version-name`, then any plugin hooks that alter `version-name` would have done so. Thus, running `version-origin` prior to printing the origin gives those plugins a chance to alter the `version-origin` to match.

If any of the hooks set `$RBENV_VERSION_ORIGIN`, then it is used as the return value. Otherwise, the existing logic continues to return "environment variable" or "filename" as appropriate.

This change, in conjunction with the `version-name` hook, makes a clean seam by which plugins can inject their own ruby version setting logic. Using this seam, as opposed to altering `$RBENV_COMMAND_PATH` from the `which` hook, means that the version name and origin are set more reliably and so `version`, `version-name`, `version-origin` and `which` all work as expected. Indeed, even PS1 works now.
2015-12-23 17:22:31 +01:00
Jason Karns
258e4413b1 create hook: version-name
Expose a `version-name` hook.

It is invoked *after* the traditional `RBENV_VERSION` lookup. Which means hook scripts can interrogate `$RBENV_VERSION_FILE` and/or `$RBENV_VERSION` (or use the executables).

The hooks are then run, giving plugins a chance to alter `RBENV_VERSION`. Once the hooks have run, we now have (in `$RBENV_VERSION`) the actual version we want to use (or it's empty which defaults to `system` per normal). Lastly, the same logic remains for checking if the version exists, or trimming the `ruby-` prefix.

Prime example: the ruby-bundler-ruby-version plugin can select a ruby by using the `ruby` directive from the `Gemfile` if a local `.ruby-version` doesn't exist.
2015-12-23 17:22:30 +01:00
Mislav Marohnić
a62a75369e Merge branch 'rbenv-local-respects-ancestry' 2015-12-23 15:30:18 +01:00
Mislav Marohnić
ba072adcb9 Have rbenv local read version from parent directories as well
Fixes #807
2015-12-23 15:21:24 +01:00
Mislav Marohnić
ca25259900 Allow explicit target directory argument to rbenv-version-file
Can be used for `.ruby-version` file lookup in the ancestry of a
specific directory. In this mode of operation, global version files
aren't taken into consideration, and the command fails unless a local
version file was found.
2015-12-23 15:19:54 +01:00
29 changed files with 323 additions and 257 deletions

2
.agignore Normal file
View File

@@ -0,0 +1,2 @@
./versions
./cache

1
.vimrc Normal file
View File

@@ -0,0 +1 @@
set wildignore+=versions/*,cache/*

View File

@@ -1,5 +1,10 @@
## Version History
## 20160310
* python-build: Add PyPy-5.0.0 (#555)
* pyenv: Import recent changes from rbenv 1.0 (#549)
## 20160303
* python-build: Add anaconda[23]-2.5.0 (#543)

80
CONDUCT.md Normal file
View File

@@ -0,0 +1,80 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting one of the project maintainers listed below. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Project Maintainers
* Sam Stephenson <<sstephenson@gmail.com>>
* Mislav Marohnić <<mislav.marohnic@gmail.com>>
* Erik Michaels-Ober <<sferik@gmail.com>>
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -1,23 +0,0 @@
#!/usr/bin/env bash
#
# `python-local-exec` is a drop-in replacement for the standard Python
# shebang line:
#
# #!/usr/bin/env python-local-exec
#
# Use it for scripts inside a project with an `.pyenv-version`
# file. When you run the scripts, they'll use the project-specified
# Python version, regardless of what directory they're run from. Useful
# for e.g. running project tasks in cron scripts without needing to
# `cd` into the project first.
set -e
export PYENV_DIR="${1%/*}"
[ -n "$PYENV_SILENCE_WARNINGS" ] || {
echo "pyenv: \`python-local-exec' is deprecated and will be removed in the next release."
echo " To upgrade: https://github.com/yyuu/pyenv/wiki/python-local-exec"
echo
} >&2
exec python "$@"

View File

@@ -97,6 +97,7 @@ PYENV_HOOK_PATH="${PYENV_HOOK_PATH}:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib
for plugin_hook in "${PYENV_ROOT}/plugins/"*/etc/pyenv.d; do
PYENV_HOOK_PATH="${PYENV_HOOK_PATH}:${plugin_hook}"
done
PYENV_HOOK_PATH="${PYENV_HOOK_PATH#:}"
export PYENV_HOOK_PATH
shopt -u nullglob

View File

@@ -12,15 +12,12 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
version="20160303"
version="20150310"
git_revision=""
for source_dir in "${BASH_SOURCE%/*}" "$PYENV_ROOT"; do
if cd "$source_dir" 2>/dev/null && git remote -v 2>/dev/null | grep -q pyenv; then
if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q pyenv; then
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
git_revision="${git_revision#v}"
[ -z "$git_revision" ] || break
fi
done
fi
echo "pyenv ${git_revision:-$version}"

View File

@@ -9,6 +9,8 @@ set -e
if [ "$1" = "--complete" ]; then
echo exec
echo rehash
echo version-name
echo version-origin
echo which
exit
fi

View File

@@ -33,9 +33,9 @@ done
shell="$1"
if [ -z "$shell" ]; then
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
shell="${shell##-}"
shell="$(ps -p "$PPID" -o 'args=' 2>/dev/null || true)"
shell="${shell%% *}"
shell="${shell##-}"
shell="${shell:-$SHELL}"
shell="${shell##*/}"
fi

View File

@@ -15,10 +15,6 @@
# `PYENV_VERSION' environment variable takes precedence over local
# and global versions.
#
# For backwards compatibility, pyenv will also read version
# specifications from `.pyenv-version' files, but a `.python-version'
# file in the same directory takes precedence.
#
# <version> should be a string matching a Python version known to pyenv.
# The special version string `system' will use your default system Python.
# Run `pyenv versions' for a list of available Python versions.
@@ -36,27 +32,17 @@ fi
versions=("$@")
if [ "$versions" = "--unset" ]; then
rm -f .python-version .pyenv-version
rm -f .python-version
elif [ -n "$versions" ]; then
previous_file="$(PYENV_VERSION= pyenv-version-origin || true)"
pyenv-version-file-write .python-version "${versions[@]}"
if [ "$previous_file" -ef .pyenv-version ]; then
rm -f .pyenv-version
{ echo "pyenv: removed existing \`.pyenv-version' file and migrated"
echo " local version specification to \`.python-version' file"
} >&2
fi
else
OLDIFS="$IFS"
IFS=: versions=($(
pyenv-version-file-read .python-version ||
pyenv-version-file-read .pyenv-version ||
{ echo "pyenv: no local version configured for this directory"
exit 1
} >&2
))
IFS="$OLDIFS"
if version_file="$(pyenv-version-file "$PWD")"; then
IFS=: versions=($(pyenv-version-file-read "$version_file"))
for version in "${versions[@]}"; do
echo "$version"
done
else
echo "pyenv: no local version configured for this directory" >&2
exit 1
fi
fi

View File

@@ -1,35 +1,28 @@
#!/usr/bin/env bash
# Usage: pyenv version-file [<dir>]
# Summary: Detect the file that sets the current pyenv version
set -e
[ -n "$PYENV_DEBUG" ] && set -x
target_dir="$1"
find_local_version_file() {
local root="$1"
while true; do
[[ "$root" =~ ^//[^/]*$ ]] && break
while ! [[ "$root" =~ ^//[^/]*$ ]]; do
if [ -e "${root}/.python-version" ]; then
echo "${root}/.python-version"
exit
elif [ -e "${root}/.pyenv-version" ]; then
echo "${root}/.pyenv-version"
exit
return 0
fi
[ -n "$root" ] || break
root="${root%/*}"
done
return 1
}
find_local_version_file "$PYENV_DIR"
[ "$PYENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
global_version_file="${PYENV_ROOT}/version"
if [ -e "$global_version_file" ]; then
echo "$global_version_file"
elif [ -e "${PYENV_ROOT}/global" ]; then
echo "${PYENV_ROOT}/global"
elif [ -e "${PYENV_ROOT}/default" ]; then
echo "${PYENV_ROOT}/default"
if [ -n "$target_dir" ]; then
find_local_version_file "$target_dir"
else
echo "$global_version_file"
find_local_version_file "$PYENV_DIR" || {
[ "$PYENV_DIR" != "$PWD" ] && find_local_version_file "$PWD"
} || echo "${PYENV_ROOT}/version"
fi

View File

@@ -8,6 +8,13 @@ if [ -z "$PYENV_VERSION" ]; then
PYENV_VERSION="$(pyenv-version-file-read "$PYENV_VERSION_FILE" || true)"
fi
OLDIFS="$IFS"
IFS=$'\n' scripts=(`pyenv-hooks version-name`)
IFS="$OLDIFS"
for script in "${scripts[@]}"; do
source "$script"
done
if [ -z "$PYENV_VERSION" ] || [ "$PYENV_VERSION" = "system" ]; then
echo "system"
exit

View File

@@ -3,7 +3,18 @@
set -e
[ -n "$PYENV_DEBUG" ] && set -x
if [ -n "$PYENV_VERSION" ]; then
unset PYENV_VERSION_ORIGIN
OLDIFS="$IFS"
IFS=$'\n' scripts=(`pyenv-hooks version-origin`)
IFS="$OLDIFS"
for script in "${scripts[@]}"; do
source "$script"
done
if [ -n "$PYENV_VERSION_ORIGIN" ]; then
echo "$PYENV_VERSION_ORIGIN"
elif [ -n "$PYENV_VERSION" ]; then
echo "PYENV_VERSION environment variable"
else
pyenv-version-file

View File

@@ -27,7 +27,7 @@ done
versions_dir="${PYENV_ROOT}/versions"
if ! enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; then
if [ -n "$PYENV_NATIVE_EXT" ]; then
echo "pyenv: failed to load \`realpath' builtin" >&2
exit 1

View File

@@ -0,0 +1,46 @@
case "$(pypy_architecture 2>/dev/null || true)" in
"linux" )
require_distro "Ubuntu 12.04" "Ubuntu 12.10" "Ubuntu 13.04" "Ubuntu 13.10" "Ubuntu 14.04" || true
install_package "pypy-5.0.0-linux" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-linux.tar.bz2#a9cc9afa94ff1cde811626a70081c477c9840e7816c0562d1903fd823d222ceb" "pypy" verify_py27 ensurepip
;;
"linux-armel" )
require_distro "Ubuntu 12.04" "Ubuntu 12.10" "Ubuntu 13.04" "Ubuntu 13.10" "Ubuntu 14.04" || true
install_package "pypy-5.0.0-linux-armel" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-linux-armel.tar.bz2#87bd85441b16ecca0d45ba6e9c0e9d26bb7bd8867afbf79d80312cf79b032dc1" "pypy" verify_py27 ensurepip
;;
"linux-armhf" )
if [[ "$(cat /etc/issue 2>/dev/null || true)" == "Raspbian"* ]]; then
install_package "pypy-5.0.0-linux-armhf-raspbian" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-linux-armhf-raspbian.tar.bz2#8033c0cc39e9f6771688f2eda95c726595f5453b3e73e1cd5f7ebbe3dae1f685" "pypy" verify_py27 ensurepip
else
require_distro "Ubuntu 13.04" || true
install_package "pypy-5.0.0-linux-armhf-raring" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-linux-armhf-raring.tar.bz2#5bb52cf5db4ae8497c4e03cd8a70e49867e6b93d9f29ad335d030fcd3a375769" "pypy" verify_py27 ensurepip
fi
;;
"linux-ppc64" )
require_distro "Fedora 20" || true
install_package "pypy-5.0.0-ppc64" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-ppc64.tar.bz2#334a37e68cb543cf2cbcdd12379b9b770064bb70ba7fd104f1e451cfa10cdda5" "pypy" verify_py27 ensurepip
;;
"linux-ppc64le" )
require_distro "Fedora 21" || true
install_package "pypy-5.0.0-ppc64le" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-ppc64le.tar.bz2#e72fe5c094186f79c997000ddbaa01616def652a8d1338b75a27dfa3755eb86c" "pypy" verify_py27 ensurepip
;;
"linux64" )
require_distro "Ubuntu 12.04" "Ubuntu 12.10" "Ubuntu 13.04" "Ubuntu 13.10" "Ubuntu 14.04" || true
install_package "pypy-5.0.0-linux64" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-linux64.tar.bz2#b9c73be8e3c3b0835df83bdb86335712005240071cdd4dc245ac30b457063ae0" "pypy" verify_py27 ensurepip
;;
"osx64" )
install_package "pypy-5.0.0-osx64" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-osx64.tar.bz2#45ed8bf799d0fd8eb051cbcc427173fba74dc9c2f6c309d7a3cc90f4917e6a10" "pypy" verify_py27 ensurepip
;;
"win32" )
# FIXME: never tested on Windows
install_zip "pypy-5.0.0-win32" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-win32.zip#c53f0946703f5e4885484c7cde2554a0320537135bf8965e054757c214412438" "pypy" verify_py27 ensurepip
;;
* )
{ echo
colorize 1 "ERROR"
echo ": The binary distribution of PyPy is not available for $(pypy_architecture 2>/dev/null || true)."
echo "try 'pypy-5.0.0-src' to build from soruce."
echo
} >&2
exit 1
;;
esac

View File

@@ -0,0 +1,2 @@
require_gcc
install_package "pypy-5.0.0-src" "https://bitbucket.org/pypy/pypy/downloads/pypy-5.0.0-src.tar.bz2#89027b1b33553b53ff7733dc4838f0a76af23552c0d915d9f6de5875b8d7d4ab" "pypy_builder" verify_py27 ensurepip

View File

@@ -2,22 +2,13 @@
load test_helper
export GIT_DIR="${PYENV_TEST_DIR}/.git"
setup() {
mkdir -p "$HOME"
git config --global user.name "Tester"
git config --global user.email "tester@test.local"
mkdir -p "${PYENV_TEST_DIR}/bin"
cat > "${PYENV_TEST_DIR}/bin/git" <<CMD
#!$BASH
if [[ \$1 == remote && \$PWD != "\$PYENV_TEST_DIR"/* ]]; then
echo "not allowed" >&2
exit 1
else
exec $(which git) "\$@"
fi
CMD
chmod +x "${PYENV_TEST_DIR}/bin/git"
cd "$PYENV_TEST_DIR"
}
git_commit() {
@@ -32,22 +23,17 @@ git_commit() {
}
@test "doesn't read version from non-pyenv repo" {
mkdir -p "$PYENV_ROOT"
cd "$PYENV_ROOT"
git init
git remote add origin https://github.com/homebrew/homebrew.git
git_commit
git tag v1.0
cd "$PYENV_TEST_DIR"
run pyenv---version
assert_success
[[ $output == "pyenv 20"* ]]
}
@test "reads version from git repo" {
mkdir -p "$PYENV_ROOT"
cd "$PYENV_ROOT"
git init
git remote add origin https://github.com/yyuu/pyenv.git
git_commit
@@ -55,20 +41,15 @@ git_commit() {
git_commit
git_commit
cd "$PYENV_TEST_DIR"
run pyenv---version
assert_success
[[ $output == "pyenv 20380119-2-g"* ]]
assert_success "pyenv 20380119-2-g$(git rev-parse --short HEAD)"
}
@test "prints default version if no tags in git repo" {
mkdir -p "$PYENV_ROOT"
cd "$PYENV_ROOT"
git init
git remote add origin https://github.com/yyuu/pyenv.git
git_commit
cd "$PYENV_TEST_DIR"
run pyenv---version
[[ $output == "pyenv 20"* ]]
}

View File

@@ -43,27 +43,14 @@ python
OUT
}
@test "supports hook path with spaces" {
hook_path="${PYENV_TEST_DIR}/custom stuff/pyenv hooks"
mkdir -p "${hook_path}/exec"
echo "export HELLO='from hook'" > "${hook_path}/exec/hello.bash"
export PYENV_VERSION=system
PYENV_HOOK_PATH="$hook_path" run pyenv-exec env
assert_success
assert_line "HELLO=from hook"
}
@test "carries original IFS within hooks" {
hook_path="${PYENV_TEST_DIR}/pyenv.d"
mkdir -p "${hook_path}/exec"
cat > "${hook_path}/exec/hello.bash" <<SH
create_hook exec hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
SH
export PYENV_VERSION=system
PYENV_HOOK_PATH="$hook_path" IFS=$' \t\n' run pyenv-exec env
IFS=$' \t\n' run pyenv-exec env
assert_success
assert_line "HELLO=:hello:ugly:world:again"
}

View File

@@ -3,7 +3,7 @@
load test_helper
@test "default" {
run pyenv global
run pyenv-global
assert_success
assert_output "system"
}
@@ -20,7 +20,7 @@ load test_helper
mkdir -p "$PYENV_ROOT/versions/1.2.3"
run pyenv-global "1.2.3"
assert_success
run pyenv global
run pyenv-global
assert_success "1.2.3"
}

View File

@@ -2,11 +2,6 @@
load test_helper
create_hook() {
mkdir -p "$1/$2"
touch "$1/$2/$3"
}
@test "prints usage help given no argument" {
run pyenv-hooks
assert_failure "Usage: pyenv hooks <command>"
@@ -15,11 +10,13 @@ create_hook() {
@test "prints list of hooks" {
path1="${PYENV_TEST_DIR}/pyenv.d"
path2="${PYENV_TEST_DIR}/etc/pyenv_hooks"
create_hook "$path1" exec "hello.bash"
create_hook "$path1" exec "ahoy.bash"
create_hook "$path1" exec "invalid.sh"
create_hook "$path1" which "boom.bash"
create_hook "$path2" exec "bueno.bash"
PYENV_HOOK_PATH="$path1"
create_hook exec "hello.bash"
create_hook exec "ahoy.bash"
create_hook exec "invalid.sh"
create_hook which "boom.bash"
PYENV_HOOK_PATH="$path2"
create_hook exec "bueno.bash"
PYENV_HOOK_PATH="$path1:$path2" run pyenv-hooks exec
assert_success
@@ -33,8 +30,10 @@ OUT
@test "supports hook paths with spaces" {
path1="${PYENV_TEST_DIR}/my hooks/pyenv.d"
path2="${PYENV_TEST_DIR}/etc/pyenv hooks"
create_hook "$path1" exec "hello.bash"
create_hook "$path2" exec "ahoy.bash"
PYENV_HOOK_PATH="$path1"
create_hook exec "hello.bash"
PYENV_HOOK_PATH="$path2"
create_hook exec "ahoy.bash"
PYENV_HOOK_PATH="$path1:$path2" run pyenv-hooks exec
assert_success
@@ -45,8 +44,8 @@ OUT
}
@test "resolves relative paths" {
path="${PYENV_TEST_DIR}/pyenv.d"
create_hook "$path" exec "hello.bash"
PYENV_HOOK_PATH="${PYENV_TEST_DIR}/pyenv.d"
create_hook exec "hello.bash"
mkdir -p "$HOME"
PYENV_HOOK_PATH="${HOME}/../pyenv.d" run pyenv-hooks exec

View File

@@ -25,12 +25,24 @@ load test_helper
}
@test "detect parent shell" {
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
SHELL=/bin/false run pyenv-init -
assert_success
assert_line "export PYENV_SHELL=bash"
}
@test "detect parent shell from script" {
mkdir -p "$PYENV_TEST_DIR"
cd "$PYENV_TEST_DIR"
cat > myscript.sh <<OUT
#!/bin/sh
eval "\$(pyenv-init -)"
echo \$PYENV_SHELL
OUT
chmod +x myscript.sh
run ./myscript.sh /bin/zsh
assert_success "sh"
}
@test "setup shell completions (fish)" {
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
run pyenv-init - fish

View File

@@ -19,24 +19,11 @@ setup() {
assert_success "1.2.3"
}
@test "supports legacy .pyenv-version file" {
echo "1.2.3" > .pyenv-version
run pyenv-local
assert_success "1.2.3"
}
@test "local .python-version has precedence over .pyenv-version" {
echo "2.7" > .pyenv-version
echo "3.4" > .python-version
run pyenv-local
assert_success "3.4"
}
@test "ignores version in parent directory" {
@test "discovers version file in parent directory" {
echo "1.2.3" > .python-version
mkdir -p "subdir" && cd "subdir"
run pyenv-local
assert_failure
assert_success "1.2.3"
}
@test "ignores PYENV_DIR" {
@@ -64,40 +51,9 @@ setup() {
assert [ "$(cat .python-version)" = "1.2.3" ]
}
@test "renames .pyenv-version to .python-version" {
echo "2.7.6" > .pyenv-version
mkdir -p "${PYENV_ROOT}/versions/3.3.3"
run pyenv-local
assert_success "2.7.6"
run pyenv-local "3.3.3"
assert_success
assert_output <<OUT
pyenv: removed existing \`.pyenv-version' file and migrated
local version specification to \`.python-version' file
OUT
assert [ ! -e .pyenv-version ]
assert [ "$(cat .python-version)" = "3.3.3" ]
}
@test "doesn't rename .pyenv-version if changing the version failed" {
echo "2.7.6" > .pyenv-version
assert [ ! -e "${PYENV_ROOT}/versions/3.3.3" ]
run pyenv-local "3.3.3"
assert_failure "pyenv: version \`3.3.3' not installed"
assert [ ! -e .python-version ]
assert [ "$(cat .pyenv-version)" = "2.7.6" ]
}
@test "unsets local version" {
touch .python-version
run pyenv-local --unset
assert_success ""
assert [ ! -e .pyenv-version ]
}
@test "unsets alternate version file" {
touch .pyenv-version
run pyenv-local --unset
assert_success ""
assert [ ! -e .pyenv-version ]
assert [ ! -e .python-version ]
}

View File

@@ -70,6 +70,7 @@ load test_helper
}
@test "PYENV_HOOK_PATH includes pyenv built-in plugins" {
unset PYENV_HOOK_PATH
run pyenv echo "PYENV_HOOK_PATH"
assert_success ":${PYENV_ROOT}/pyenv.d:${BATS_TEST_DIRNAME%/*}/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks"
assert_success "${PYENV_ROOT}/pyenv.d:${BATS_TEST_DIRNAME%/*}/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks"
}

View File

@@ -86,15 +86,13 @@ OUT
}
@test "carries original IFS within hooks" {
hook_path="${PYENV_TEST_DIR}/pyenv.d"
mkdir -p "${hook_path}/rehash"
cat > "${hook_path}/rehash/hello.bash" <<SH
create_hook rehash hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
exit
SH
PYENV_HOOK_PATH="$hook_path" IFS=$' \t\n' run pyenv-rehash
IFS=$' \t\n' run pyenv-rehash
assert_success
assert_output "HELLO=:hello:ugly:world:again"
}

View File

@@ -17,6 +17,7 @@ if [ -z "$PYENV_TEST_DIR" ]; then
export PYENV_ROOT="${PYENV_TEST_DIR}/root"
export HOME="${PYENV_TEST_DIR}/home"
export PYENV_HOOK_PATH="${PYENV_ROOT}/pyenv.d"
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
PATH="${PYENV_TEST_DIR}/bin:$PATH"
@@ -129,3 +130,11 @@ path_without() {
path="${path#:}"
echo "${path%:}"
}
create_hook() {
mkdir -p "${PYENV_HOOK_PATH}/$1"
touch "${PYENV_HOOK_PATH}/$1/$2"
if [ ! -t 0 ]; then
cat > "${PYENV_HOOK_PATH}/$1/$2"
fi
}

View File

@@ -12,6 +12,12 @@ create_file() {
touch "$1"
}
@test "detects global 'version' file" {
create_file "${PYENV_ROOT}/version"
run pyenv-version-file
assert_success "${PYENV_ROOT}/version"
}
@test "prints global file if no version files exist" {
assert [ ! -e "${PYENV_ROOT}/version" ]
assert [ ! -e ".python-version" ]
@@ -19,45 +25,12 @@ create_file() {
assert_success "${PYENV_ROOT}/version"
}
@test "detects 'global' file" {
create_file "${PYENV_ROOT}/global"
run pyenv-version-file
assert_success "${PYENV_ROOT}/global"
}
@test "detects 'default' file" {
create_file "${PYENV_ROOT}/default"
run pyenv-version-file
assert_success "${PYENV_ROOT}/default"
}
@test "'version' has precedence over 'global' and 'default'" {
create_file "${PYENV_ROOT}/version"
create_file "${PYENV_ROOT}/global"
create_file "${PYENV_ROOT}/default"
run pyenv-version-file
assert_success "${PYENV_ROOT}/version"
}
@test "in current directory" {
create_file ".python-version"
run pyenv-version-file
assert_success "${PYENV_TEST_DIR}/.python-version"
}
@test "legacy file in current directory" {
create_file ".pyenv-version"
run pyenv-version-file
assert_success "${PYENV_TEST_DIR}/.pyenv-version"
}
@test ".python-version has precedence over legacy file" {
create_file ".python-version"
create_file ".pyenv-version"
run pyenv-version-file
assert_success "${PYENV_TEST_DIR}/.python-version"
}
@test "in parent directory" {
create_file ".python-version"
mkdir -p project
@@ -74,14 +47,6 @@ create_file() {
assert_success "${PYENV_TEST_DIR}/project/.python-version"
}
@test "legacy file has precedence if higher" {
create_file ".python-version"
create_file "project/.pyenv-version"
cd project
run pyenv-version-file
assert_success "${PYENV_TEST_DIR}/project/.pyenv-version"
}
@test "PYENV_DIR has precedence over PWD" {
create_file "widget/.python-version"
create_file "project/.python-version"
@@ -97,3 +62,14 @@ create_file() {
PYENV_DIR="${PYENV_TEST_DIR}/widget/blank" run pyenv-version-file
assert_success "${PYENV_TEST_DIR}/project/.python-version"
}
@test "finds version file in target directory" {
create_file "project/.python-version"
run pyenv-version-file "${PWD}/project"
assert_success "${PYENV_TEST_DIR}/project/.python-version"
}
@test "fails when no version file in target directory" {
run pyenv-version-file "$PWD"
assert_failure ""
}

View File

@@ -22,29 +22,50 @@ setup() {
assert_success "system"
}
@test "PYENV_VERSION can be overridden by hook" {
create_version "2.7.11"
create_version "3.5.1"
create_hook version-name test.bash <<<"PYENV_VERSION=3.5.1"
PYENV_VERSION=2.7.11 run pyenv-version-name
assert_success "3.5.1"
}
@test "carries original IFS within hooks" {
create_hook version-name hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
SH
export PYENV_VERSION=system
IFS=$' \t\n' run pyenv-version-name env
assert_success
assert_line "HELLO=:hello:ugly:world:again"
}
@test "PYENV_VERSION has precedence over local" {
create_version "2.7.6"
create_version "3.3.3"
create_version "2.7.11"
create_version "3.5.1"
cat > ".python-version" <<<"2.7.6"
cat > ".python-version" <<<"2.7.11"
run pyenv-version-name
assert_success "2.7.6"
assert_success "2.7.11"
PYENV_VERSION=3.3.3 run pyenv-version-name
assert_success "3.3.3"
PYENV_VERSION=3.5.1 run pyenv-version-name
assert_success "3.5.1"
}
@test "local file has precedence over global" {
create_version "2.7.6"
create_version "3.3.3"
create_version "2.7.11"
create_version "3.5.1"
cat > "${PYENV_ROOT}/version" <<<"2.7.6"
cat > "${PYENV_ROOT}/version" <<<"2.7.11"
run pyenv-version-name
assert_success "2.7.6"
assert_success "2.7.11"
cat > ".python-version" <<<"3.3.3"
cat > ".python-version" <<<"3.5.1"
run pyenv-version-name
assert_success "3.3.3"
assert_success "3.5.1"
}
@test "missing version" {
@@ -53,22 +74,22 @@ setup() {
}
@test "one missing version (second missing)" {
create_version "3.4.2"
PYENV_VERSION="3.4.2:1.2" run pyenv-version-name
create_version "3.5.1"
PYENV_VERSION="3.5.1:1.2" run pyenv-version-name
assert_failure
assert_output <<OUT
pyenv: version \`1.2' is not installed (set by PYENV_VERSION environment variable)
3.4.2
3.5.1
OUT
}
@test "one missing version (first missing)" {
create_version "3.4.2"
PYENV_VERSION="1.2:3.4.2" run pyenv-version-name
create_version "3.5.1"
PYENV_VERSION="1.2:3.5.1" run pyenv-version-name
assert_failure
assert_output <<OUT
pyenv: version \`1.2' is not installed (set by PYENV_VERSION environment variable)
3.4.2
3.5.1
OUT
}
@@ -77,18 +98,18 @@ pyenv-version-name-without-stderr() {
}
@test "one missing version (without stderr)" {
create_version "3.4.2"
PYENV_VERSION="1.2:3.4.2" run pyenv-version-name-without-stderr
create_version "3.5.1"
PYENV_VERSION="1.2:3.5.1" run pyenv-version-name-without-stderr
assert_failure
assert_output <<OUT
3.4.2
3.5.1
OUT
}
@test "version with prefix in name" {
create_version "2.7.6"
cat > ".python-version" <<<"python-2.7.6"
create_version "2.7.11"
cat > ".python-version" <<<"python-2.7.11"
run pyenv-version-name
assert_success
assert_output "2.7.6"
assert_output "2.7.11"
}

View File

@@ -31,8 +31,26 @@ setup() {
assert_success "${PWD}/.python-version"
}
@test "detects alternate version file" {
touch .pyenv-version
run pyenv-version-origin
assert_success "${PWD}/.pyenv-version"
@test "reports from hook" {
create_hook version-origin test.bash <<<"PYENV_VERSION_ORIGIN=plugin"
PYENV_VERSION=1 run pyenv-version-origin
assert_success "plugin"
}
@test "carries original IFS within hooks" {
create_hook version-origin hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
SH
export PYENV_VERSION=system
IFS=$' \t\n' run pyenv-version-origin env
assert_success
assert_line "HELLO=:hello:ugly:world:again"
}
@test "doesn't inherit PYENV_VERSION_ORIGIN from environment" {
PYENV_VERSION_ORIGIN=ignored run pyenv-version-origin
assert_success "${PYENV_ROOT}/version"
}

View File

@@ -113,15 +113,13 @@ OUT
}
@test "carries original IFS within hooks" {
hook_path="${PYENV_TEST_DIR}/pyenv.d"
mkdir -p "${hook_path}/which"
cat > "${hook_path}/which/hello.bash" <<SH
create_hook which hello.bash <<SH
hellos=(\$(printf "hello\\tugly world\\nagain"))
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
exit
SH
PYENV_HOOK_PATH="$hook_path" IFS=$' \t\n' PYENV_VERSION=system run pyenv-which anything
IFS=$' \t\n' PYENV_VERSION=system run pyenv-which anything
assert_success
assert_output "HELLO=:hello:ugly:world:again"
}