From cc4f95e713f92698b6b38a95c412895acb165b4a Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Fri, 15 Mar 2019 08:32:42 -0400 Subject: [PATCH] Use PYTHON_EXE env var as the python interpreter (#11212) Setting the PYTHON_EXE environment variable causes new Python virtual environments to be created using the specified interpreter. Both `make` and `mage` honor the variable. For example, `PYTHON_EXE=python2.7 make python-env`. (cherry picked from commit 9fb274aabb3e0ea0db0456a8f094ccc1ac7648d1) --- CHANGELOG-developer.next.asciidoc | 9 +++++++++ dev-tools/mage/pytest.go | 11 +++++++++-- libbeat/scripts/Makefile | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index 2f0bdf798f7c..f3975d0e66df 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -23,3 +23,12 @@ The list below covers the major changes between 7.0.0-rc1 and master only. ==== Bugfixes ==== Added + +- Metricset generator generates beta modules by default now. {pull}10657[10657] +- The `beat.Event` accessor methods now support `@metadata` keys. {pull}10761[10761] +- Assertion for documented fields in tests fails if any of the fields in the tested event is documented as an alias. {pull}10921[10921] +- Support for Logger in the Metricset base instance. {pull}11106[11106] +- Introduce processing.Support to instance.Setting. This allows Beats to fully modify the event processing. {pull}10801[10801] +- Filebeat modules can now use ingest pipelines in YAML format. {pull}11209[11209] +- 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 9aaf8a4b4e80..cdcce4c61668 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 a3c905d1b18e..fbdd3e8afb0e 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 ; \