Skip to content

Commit cc4f95e

Browse files
committed
Use PYTHON_EXE env var as the python interpreter (elastic#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 9fb274a)
1 parent 250c2dd commit cc4f95e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CHANGELOG-developer.next.asciidoc

+9
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ The list below covers the major changes between 7.0.0-rc1 and master only.
2323
==== Bugfixes
2424

2525
==== Added
26+
27+
- Metricset generator generates beta modules by default now. {pull}10657[10657]
28+
- The `beat.Event` accessor methods now support `@metadata` keys. {pull}10761[10761]
29+
- Assertion for documented fields in tests fails if any of the fields in the tested event is documented as an alias. {pull}10921[10921]
30+
- Support for Logger in the Metricset base instance. {pull}11106[11106]
31+
- Introduce processing.Support to instance.Setting. This allows Beats to fully modify the event processing. {pull}10801[10801]
32+
- Filebeat modules can now use ingest pipelines in YAML format. {pull}11209[11209]
33+
- Added support for using PYTHON_EXE to control what Python interpreter is used
34+
by `make` and `mage`. Example: `export PYTHON_EXE=python2.7`. {pull}11212[11212]

dev-tools/mage/pytest.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,17 @@ func PythonVirtualenv() (string, error) {
167167
return pythonVirtualenvDir, nil
168168
}
169169

170+
// If set use PYTHON_EXE env var as the python interpreter.
171+
var args []string
172+
if pythonExe := os.Getenv("PYTHON_EXE"); pythonExe != "" {
173+
args = append(args, "-p", pythonExe)
174+
}
175+
args = append(args, ve)
176+
170177
// Execute virtualenv.
171178
if _, err := os.Stat(ve); err != nil {
172179
// Run virtualenv if the dir does not exist.
173-
if err := sh.Run("virtualenv", ve); err != nil {
180+
if err := sh.Run("virtualenv", args...); err != nil {
174181
return "", err
175182
}
176183
}
@@ -181,7 +188,7 @@ func PythonVirtualenv() (string, error) {
181188
}
182189

183190
pip := virtualenvPath(ve, "pip")
184-
args := []string{"install"}
191+
args = []string{"install"}
185192
if !mg.Verbose() {
186193
args = append(args, "--quiet")
187194
}

libbeat/scripts/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ load-tests: ## @testing Runs load tests
250250
# Sets up the virtual python environment
251251
.PHONY: python-env
252252
python-env: ${ES_BEATS}/libbeat/tests/system/requirements.txt
253-
@test -d ${PYTHON_ENV} || virtualenv ${VIRTUALENV_PARAMS} ${PYTHON_ENV}
253+
@test -d ${PYTHON_ENV} || virtualenv $(if ${PYTHON_EXE},-p ${PYTHON_EXE}) ${VIRTUALENV_PARAMS} ${PYTHON_ENV}
254254
@. ${PYTHON_ENV}/bin/activate && pip install ${PIP_INSTALL_PARAMS} -q --upgrade pip ; \
255255
if [ -a ./tests/system/requirements.txt ] && [ ! ${ES_BEATS}/libbeat/tests/system/requirements.txt -ef ./tests/system/requirements.txt ] ; then \
256256
. ${PYTHON_ENV}/bin/activate && pip install ${PIP_INSTALL_PARAMS} -qUr ${ES_BEATS}/libbeat/tests/system/requirements.txt -Ur ./tests/system/requirements.txt ; \

0 commit comments

Comments
 (0)