Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate pydoc executable after creating new virtualenv #230

Merged
merged 3 commits into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bin/pyenv-virtualenv
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,17 @@ if [ -d "${VIRTUALENV_PATH}" ] && [ -n "${COMPAT_VIRTUALENV_PATH}" ]; then
ln -fs "${VIRTUALENV_PATH}" "${COMPAT_VIRTUALENV_PATH}"
fi

if [ ! -e "${VIRTUALENV_PATH}/bin/pydoc" ]; then
mkdir -p "${VIRTUALENV_PATH}/bin"
cat <<EOS > "${VIRTUALENV_PATH}/bin/pydoc"
#!${VIRTUALENV_PATH}/bin/python
import pydoc
if __name__ == '__main__':
pydoc.cli()
EOS
chmod +x "${VIRTUALENV_PATH}/bin/pydoc"
fi

if [ -z "${NO_ENSUREPIP}" ]; then
## Install setuptools and pip.
PYENV_VERSION="${VIRTUALENV_NAME}" build_package_ensurepip
Expand Down
16 changes: 11 additions & 5 deletions test/pyvenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ unstub_pyenv() {

run pyenv-virtualenv venv

assert_success
assert_output <<OUT
PYENV_VERSION=3.5.1 python -m venv ${PYENV_ROOT}/versions/3.5.1/envs/venv
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/3.5.1/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-virtualenv-prefix
Expand All @@ -57,19 +58,20 @@ OUT

run pyenv-virtualenv venv

assert_success
assert_output <<OUT
PYENV_VERSION=3.5.1 virtualenv ${PYENV_ROOT}/versions/3.5.1/envs/venv
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/3.5.1/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-virtualenv-prefix
unstub pyenv-exec
teardown_m_venv "3.5.1"
}

@test "install virtualenv if venv is not avaialble" {
@test "install virtualenv if venv is not available" {
export PYENV_VERSION="3.2.1"
setup_version "3.2.1"
stub_pyenv "${PYENV_VERSION}"
Expand All @@ -81,12 +83,13 @@ OUT

run pyenv-virtualenv venv

assert_success
assert_output <<OUT
PYENV_VERSION=3.2.1 pip install virtualenv==13.1.2
PYENV_VERSION=3.2.1 virtualenv ${PYENV_ROOT}/versions/3.2.1/envs/venv
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/3.2.1/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-virtualenv-prefix
Expand All @@ -112,6 +115,7 @@ PYENV_VERSION=3.5.1 pip install virtualenv
PYENV_VERSION=3.5.1 virtualenv --python=${TMP}/python3 ${PYENV_ROOT}/versions/3.5.1/envs/venv
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/3.5.1/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
Expand All @@ -138,6 +142,7 @@ PYENV_VERSION=3.5.1 pip install virtualenv
PYENV_VERSION=3.5.1 virtualenv --python=${TMP}/python3 ${PYENV_ROOT}/versions/3.5.1/envs/venv
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/3.5.1/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
Expand All @@ -158,12 +163,13 @@ OUT

PIP_REQUIRE_VENV="true" run pyenv-virtualenv venv

assert_success
assert_output <<OUT
PIP_REQUIRE_VENV= PYENV_VERSION=3.2.1 pip install virtualenv==13.1.2
PIP_REQUIRE_VENV= PYENV_VERSION=3.2.1 virtualenv ${PYENV_ROOT}/versions/3.2.1/envs/venv
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/3.2.1/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-virtualenv-prefix
Expand Down
11 changes: 8 additions & 3 deletions test/virtualenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ unstub_pyenv() {

run pyenv-virtualenv "2.7.11" "venv"

assert_success
assert_output <<OUT
PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/venv
Installing pip from https://bootstrap.pypa.io/get-pip.py...
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-virtualenv-prefix
Expand All @@ -60,12 +61,13 @@ OUT

run pyenv-virtualenv venv

assert_success
assert_output <<OUT
PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/venv
Installing pip from https://bootstrap.pypa.io/get-pip.py...
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-version-name
Expand All @@ -92,6 +94,7 @@ PYENV_VERSION=2.7.11 virtualenv --verbose --python=${TMP}/python ${PYENV_ROOT}/v
Installing pip from https://bootstrap.pypa.io/get-pip.py...
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
Expand Down Expand Up @@ -119,6 +122,7 @@ PYENV_VERSION=2.7.11 virtualenv --verbose --python=${TMP}/python ${PYENV_ROOT}/v
Installing pip from https://bootstrap.pypa.io/get-pip.py...
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
assert_success

unstub_pyenv
Expand Down Expand Up @@ -176,12 +180,13 @@ OUT

run pyenv-virtualenv "2.7.11" "2.7.11/envs/foo"

assert_success
assert_output <<OUT
PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/foo
Installing pip from https://bootstrap.pypa.io/get-pip.py...
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/foo/bin/pydoc" ]
assert_success

unstub_pyenv
unstub pyenv-virtualenv-prefix
Expand Down