From 9608870d3af1f319942685c3fdeeec714302007e Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Mon, 10 May 2021 15:48:50 +0200 Subject: [PATCH] Add pyenv shims to PATH (#1263) Recently the pyenv init command does not add pyenv shims to the `PATH` anymore. This needs to be done now explicitly with a new command. We add the command in build scripts and our documentation to make sure shims are available. --- .ci/build.sh | 4 ++++ Makefile | 9 ++------- docs/developing.rst | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 2f4f2114c..b4cacdfe2 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -44,6 +44,8 @@ function build { export LC_ALL=en_US.UTF-8 update_pyenv eval "$(pyenv init -)" + # ensure pyenv shims are added to PATH, see https://github.com/pyenv/pyenv/issues/1906 + eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)" make prereq @@ -58,6 +60,8 @@ function license-scan { export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" + # ensure pyenv shims are added to PATH, see https://github.com/pyenv/pyenv/issues/1906 + eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)" make prereq diff --git a/Makefile b/Makefile index 9128a26a9..975df825e 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,7 @@ VENV_ACTIVATE = . $(VENV_ACTIVATE_FILE) VEPYTHON = $(VENV_NAME)/bin/$(PY_BIN) VEPYLINT = $(VENV_NAME)/bin/pylint PYENV_ERROR = "\033[0;31mIMPORTANT\033[0m: Please install pyenv.\n" -PYENV_PATH_ERROR = "\033[0;31mIMPORTANT\033[0m: Please add $(HOME)/$(PYENV_REGEX) to your PATH env.\n" -PYENV_PREREQ_HELP = "\033[0;31mIMPORTANT\033[0m: please add \033[0;31meval \"\$$(pyenv init -)\"\033[0m to your bash profile and restart your terminal before proceeding any further.\n" +PYENV_PREREQ_HELP = "\033[0;31mIMPORTANT\033[0m: please type \033[0;31mpyenv init\033[0m, follow the instructions there and restart your terminal before proceeding any further.\n" VE_MISSING_HELP = "\033[0;31mIMPORTANT\033[0m: Couldn't find $(PWD)/$(VENV_NAME); have you executed make venv-create?\033[0m\n" prereq: @@ -46,12 +45,8 @@ venv-create: printf $(PYENV_ERROR); \ exit 1; \ fi; - @if [[ ! "$(PATH)" =~ $(PYENV_REGEX) ]]; then \ - printf $(PYENV_PATH_ERROR); \ - exit 1; \ - fi; @if [[ ! -f $(VENV_ACTIVATE_FILE) ]]; then \ - eval "$$(pyenv init -)" && $(PY_BIN) -mvenv $(VENV_NAME); \ + eval "$$(pyenv init -)" && eval "$$(pyenv init --path)" && $(PY_BIN) -mvenv $(VENV_NAME); \ printf "Created python3 venv under $(PWD)/$(VENV_NAME).\n"; \ fi; diff --git a/docs/developing.rst b/docs/developing.rst index bfd3b44ce..1be6820e3 100644 --- a/docs/developing.rst +++ b/docs/developing.rst @@ -6,7 +6,7 @@ Prerequisites Install the following software packages: -* Pyenv installed and ``eval "$(pyenv init -)"`` is added to the shell configuration file. For more details please refer to the PyEnv `installation instructions `_. +* Pyenv installed, Follow the instructions in the output of ``pyenv init`` to setup your shell and then restart it before proceeding. For more details please refer to the PyEnv `installation instructions `_. * JDK version required to build Elasticsearch. Please refer to the `build setup requirements `_. * `Docker `_ and on Linux additionally `docker-compose `_. * git 1.9 or better