From 8896fd319a257f3e0783119a7dd8d0978ef62197 Mon Sep 17 00:00:00 2001 From: Andres Rodriguez Date: Thu, 2 Dec 2021 21:09:46 +0100 Subject: [PATCH] Fix Python environment activation (#29252) --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 40b081bf3ed..179d54f7855 100644 --- a/Makefile +++ b/Makefile @@ -128,8 +128,9 @@ check-no-changes: ## check-python : Python Linting. .PHONY: check-python check-python: python-env - @$(FIND) -name *.py -name *.py -not -path "*/build/*" -exec $(PYTHON_ENV)/bin/autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false) - @$(FIND) -name *.py -not -path "*/build/*" | xargs $(PYTHON_ENV)/bin/pylint --py3k -E || (echo "Code is not compatible with Python 3" && false) + @. $(PYTHON_ENV)/bin/activate; \ + $(FIND) -name *.py -name *.py -not -path "*/build/*" -exec $(PYTHON_ENV)/bin/autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false); \ + $(FIND) -name *.py -not -path "*/build/*" | xargs $(PYTHON_ENV)/bin/pylint --py3k -E || (echo "Code is not compatible with Python 3" && false) ## check-headers : Check the license headers. .PHONY: check-headers @@ -184,9 +185,10 @@ notice: .PHONY: python-env python-env: @test -d $(PYTHON_ENV) || ${PYTHON_EXE} -m venv $(VENV_PARAMS) $(PYTHON_ENV) - @$(PYTHON_ENV)/bin/pip install -q --upgrade pip autopep8==1.5.4 pylint==2.4.4 + @. $(PYTHON_ENV)/bin/activate; \ + ${PYTHON_EXE} -m pip install -q --upgrade pip autopep8==1.5.4 pylint==2.4.4; \ + find $(PYTHON_ENV) -type d -name dist-packages -exec sh -c "echo dist-packages > {}.pth" ';' @# Work around pip bug. See: https://github.com/pypa/pip/issues/4464 - @find $(PYTHON_ENV) -type d -name dist-packages -exec sh -c "echo dist-packages > {}.pth" ';' ## test-apm : Tests if apm works with the current code .PHONY: test-apm