From 1ca0c84ed694f66ef71a88856f90605906a21a92 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Tue, 22 Sep 2015 22:55:13 +0900 Subject: [PATCH] find `python-config` from source version if current version is a virtualenv --- etc/pyenv.d/which/python-config.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 etc/pyenv.d/which/python-config.bash diff --git a/etc/pyenv.d/which/python-config.bash b/etc/pyenv.d/which/python-config.bash new file mode 100644 index 0000000..41d54f6 --- /dev/null +++ b/etc/pyenv.d/which/python-config.bash @@ -0,0 +1,14 @@ +# some of libraries require `python-config` in PATH to build native extensions. +# as a workaround, this hook will try to find the executable from the source +# version of the virtualenv. +# https://github.com/yyuu/pyenv/issues/397 + +if [ ! -x "${PYENV_COMMAND_PATH}" ] && [[ "python"*"-config" == "${PYENV_COMMAND_PATH##*/}" ]]; then + virtualenv_prefix="$(pyenv-virtualenv-prefix 2>/dev/null || true)" + if [ -d "${virtualenv_prefix}" ]; then + virtualenv_command_path="${virtualenv_prefix}/bin/${PYENV_COMMAND_PATH##*/}" + if [ -x "${virtualenv_command_path}" ]; then + PYENV_COMMAND_PATH="${virtualenv_command_path}" + fi + fi +fi