Skip to content

Commit

Permalink
Link python*-config into VE (#460)
Browse files Browse the repository at this point in the history
Required to build binaries that link against Python.
Carl Meyer, the champion for PEP 0405, has confirmed that there isn't a particular reason why `venv` doesn't do that.
  • Loading branch information
native-api authored Jun 26, 2023
1 parent cd6a51a commit c85c1c9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 9 additions & 0 deletions bin/pyenv-virtualenv
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,15 @@ else
fi
fi

(
shopt -s nullglob
for extra_binary in "$PREFIX"/bin/python*-config; do
extra_binary_linkname="$VIRTUALENV_PATH/bin/$(basename $extra_binary)"
[[ -e "$extra_binary_linkname" ]] || \
ln -s "$extra_binary" "$extra_binary_linkname"
done
)

## Create symlink in the `versions` directory for backward compatibility
if [ -d "${VIRTUALENV_PATH}" ] && [ -n "${COMPAT_VIRTUALENV_PATH}" ]; then
ln -fs "${VIRTUALENV_PATH}" "${COMPAT_VIRTUALENV_PATH}"
Expand Down
9 changes: 7 additions & 2 deletions test/virtualenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ unstub_pyenv() {
stub pyenv-exec "python2.7 -m venv --help : false"
stub pyenv-exec "python2 -m venv --help : false"
stub pyenv-exec "python -m venv --help : false"
stub pyenv-exec "virtualenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\""
stub pyenv-exec "virtualenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\"; mkdir -p \"\$2/bin\""
stub pyenv-exec "python -s -m ensurepip : false"
stub pyenv-exec "python -s */get-pip.py : true"
stub curl true
create_executable "${PYENV_VERSION}" "python-config"
create_executable "${PYENV_VERSION}" "python2-config"
create_executable "${PYENV_VERSION}" "python2.7-config"

run pyenv-virtualenv "2.7.11" "venv"

Expand All @@ -41,8 +44,10 @@ PYENV_VERSION=2.7.11 virtualenv ${PYENV_ROOT}/versions/2.7.11/envs/venv
Installing pip from https://bootstrap.pypa.io/pip/2.7/get-pip.py...
rehashed
OUT
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/pydoc" ]
assert_success
for x in pydoc python-config python2-config python2.7-config; do
assert [ -x "${PYENV_ROOT}/versions/2.7.11/envs/venv/bin/$x" ]
done

unstub_pyenv
unstub pyenv-virtualenv-prefix
Expand Down

0 comments on commit c85c1c9

Please sign in to comment.