Просмотр исходного кода

Merge pull request #504 from blueyed/merge-rbenv

Merge rbenv/master
pull/511/head
Daniel Hahler 10 лет назад
Родитель
Сommit
66bd348600
4 измененных файлов: 30 добавлений и 22 удалений
  1. +0
    -3
      README.md
  2. +18
    -18
      libexec/pyenv
  3. +2
    -1
      libexec/pyenv-which
  4. +10
    -0
      test/which.bats

+ 0
- 3
README.md Просмотреть файл

@ -67,7 +67,6 @@ executables injected into your `PATH`, determines which Python version
has been specified by your application, and passes your commands along has been specified by your application, and passes your commands along
to the correct Python installation. to the correct Python installation.
### Understanding PATH ### Understanding PATH
When you run a command like `python` or `pip`, your operating system When you run a command like `python` or `pip`, your operating system
@ -83,7 +82,6 @@ precedence over another one at the end. In this example, the
`/usr/local/bin` directory will be searched first, then `/usr/bin`, `/usr/local/bin` directory will be searched first, then `/usr/bin`,
then `/bin`. then `/bin`.
### Understanding Shims ### Understanding Shims
pyenv works by inserting a directory of _shims_ at the front of your pyenv works by inserting a directory of _shims_ at the front of your
@ -104,7 +102,6 @@ operating system will do the following:
* Run the shim named `pip`, which in turn passes the command along to * Run the shim named `pip`, which in turn passes the command along to
pyenv pyenv
### Choosing the Python Version ### Choosing the Python Version
When you execute a shim, pyenv determines which Python version to use by When you execute a shim, pyenv determines which Python version to use by

+ 18
- 18
libexec/pyenv Просмотреть файл

@ -28,26 +28,26 @@ if enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath 2>/dev
else else
[ -z "$PYENV_NATIVE_EXT" ] || abort "failed to load \`realpath' builtin" [ -z "$PYENV_NATIVE_EXT" ] || abort "failed to load \`realpath' builtin"
READLINK=$(type -p greadlink readlink | head -1)
[ -n "$READLINK" ] || abort "cannot find readlink - are you missing GNU coreutils?"
READLINK=$(type -p greadlink readlink | head -1)
[ -n "$READLINK" ] || abort "cannot find readlink - are you missing GNU coreutils?"
resolve_link() {
$READLINK "$1"
}
resolve_link() {
$READLINK "$1"
}
abs_dirname() {
local cwd="$(pwd)"
local path="$1"
abs_dirname() {
local cwd="$PWD"
local path="$1"
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
}
pwd
cd "$cwd"
}
fi fi
if [ -z "${PYENV_ROOT}" ]; then if [ -z "${PYENV_ROOT}" ]; then
@ -71,10 +71,10 @@ if [ -z "${PYENV_DIR}" ]; then
fi fi
if [ -z "${PYENV_DIR}" ]; then if [ -z "${PYENV_DIR}" ]; then
PYENV_DIR="$(pwd)"
PYENV_DIR="$PWD"
else else
cd "$PYENV_DIR" 2>/dev/null || abort "cannot change working directory to \`$PYENV_DIR'" cd "$PYENV_DIR" 2>/dev/null || abort "cannot change working directory to \`$PYENV_DIR'"
PYENV_DIR="$(pwd)"
PYENV_DIR="$PWD"
cd "$OLDPWD" cd "$OLDPWD"
fi fi
export PYENV_DIR export PYENV_DIR

+ 2
- 1
libexec/pyenv-which Просмотреть файл

@ -23,7 +23,8 @@ remove_from_path() {
path_before="$result" path_before="$result"
result="${result//:$path_to_remove:/:}" result="${result//:$path_to_remove:/:}"
done done
echo "${result%:}"
result="${result%:}"
echo "${result#:}"
} }
PYENV_COMMAND="$1" PYENV_COMMAND="$1"

+ 10
- 0
test/which.bats Просмотреть файл

@ -59,6 +59,16 @@ create_executable() {
assert_success "${PYENV_TEST_DIR}/bin/kill-all-humans" assert_success "${PYENV_TEST_DIR}/bin/kill-all-humans"
} }
@test "doesn't include current directory in PATH search" {
export PATH="$(path_without "kill-all-humans")"
mkdir -p "$PYENV_TEST_DIR"
cd "$PYENV_TEST_DIR"
touch kill-all-humans
chmod +x kill-all-humans
PYENV_VERSION=system run pyenv-which kill-all-humans
assert_failure "pyenv: kill-all-humans: command not found"
}
@test "version not installed" { @test "version not installed" {
create_executable "3.4" "py.test" create_executable "3.4" "py.test"
PYENV_VERSION=3.3 run pyenv-which py.test PYENV_VERSION=3.3 run pyenv-which py.test

Загрузка…
Отмена
Сохранить