Skip to content

Commit

Permalink
Add pyenv shims to PATH (#1263)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danielmitterdorfer authored May 10, 2021
1 parent 058e115 commit 9608870
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion docs/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/pyenv/pyenv#installation>`_.
* 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 <https://github.com/pyenv/pyenv#installation>`_.
* JDK version required to build Elasticsearch. Please refer to the `build setup requirements <https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md#contributing-to-the-elasticsearch-codebase>`_.
* `Docker <https://docs.docker.com/install/>`_ and on Linux additionally `docker-compose <https://docs.docker.com/compose/install/>`_.
* git 1.9 or better
Expand Down

0 comments on commit 9608870

Please sign in to comment.