diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index 2f0bdf798f7..a851ce989c1 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -23,3 +23,6 @@ The list below covers the major changes between 7.0.0-rc1 and master only. ==== Bugfixes ==== Added + +- Added support for using PYTHON_EXE to control what Python interpreter is used + by `make` and `mage`. Example: `export PYTHON_EXE=python2.7`. {pull}11212[11212] diff --git a/dev-tools/mage/pytest.go b/dev-tools/mage/pytest.go index 9aaf8a4b4e8..cdcce4c6166 100644 --- a/dev-tools/mage/pytest.go +++ b/dev-tools/mage/pytest.go @@ -167,10 +167,17 @@ func PythonVirtualenv() (string, error) { return pythonVirtualenvDir, nil } + // If set use PYTHON_EXE env var as the python interpreter. + var args []string + if pythonExe := os.Getenv("PYTHON_EXE"); pythonExe != "" { + args = append(args, "-p", pythonExe) + } + args = append(args, ve) + // Execute virtualenv. if _, err := os.Stat(ve); err != nil { // Run virtualenv if the dir does not exist. - if err := sh.Run("virtualenv", ve); err != nil { + if err := sh.Run("virtualenv", args...); err != nil { return "", err } } @@ -181,7 +188,7 @@ func PythonVirtualenv() (string, error) { } pip := virtualenvPath(ve, "pip") - args := []string{"install"} + args = []string{"install"} if !mg.Verbose() { args = append(args, "--quiet") } diff --git a/libbeat/scripts/Makefile b/libbeat/scripts/Makefile index a3c905d1b18..fbdd3e8afb0 100755 --- a/libbeat/scripts/Makefile +++ b/libbeat/scripts/Makefile @@ -250,7 +250,7 @@ load-tests: ## @testing Runs load tests # Sets up the virtual python environment .PHONY: python-env python-env: ${ES_BEATS}/libbeat/tests/system/requirements.txt - @test -d ${PYTHON_ENV} || virtualenv ${VIRTUALENV_PARAMS} ${PYTHON_ENV} + @test -d ${PYTHON_ENV} || virtualenv $(if ${PYTHON_EXE},-p ${PYTHON_EXE}) ${VIRTUALENV_PARAMS} ${PYTHON_ENV} @. ${PYTHON_ENV}/bin/activate && pip install ${PIP_INSTALL_PARAMS} -q --upgrade pip ; \ if [ -a ./tests/system/requirements.txt ] && [ ! ${ES_BEATS}/libbeat/tests/system/requirements.txt -ef ./tests/system/requirements.txt ] ; then \ . ${PYTHON_ENV}/bin/activate && pip install ${PIP_INSTALL_PARAMS} -qUr ${ES_BEATS}/libbeat/tests/system/requirements.txt -Ur ./tests/system/requirements.txt ; \