diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2020-04-02 18:59:43 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2020-04-02 18:59:43 +0200 |
commit | 2441e242884a196a21cbf11bd7726584849553e1 (patch) | |
tree | fd0aa9df0ca9eb881f4b81d1b1cac07215d0bb67 /utils | |
parent | 0a951d0e550089ec8499b87ca7077420b23ff368 (diff) | |
parent | 65e8af62b18d5776ebed02ae9d22e137d7f421ca (diff) | |
download | searxng-2441e242884a196a21cbf11bd7726584849553e1.tar.gz searxng-2441e242884a196a21cbf11bd7726584849553e1.zip |
Merge branch 'master' of https://github.com/asciimoo/searx into filtron
Diffstat (limited to 'utils')
-rw-r--r-- | utils/makefile.python | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/utils/makefile.python b/utils/makefile.python index 2e488bf2b..49944442e 100644 --- a/utils/makefile.python +++ b/utils/makefile.python @@ -12,9 +12,12 @@ PYDIST = ./$(LXC_ENV_FOLDER)dist # folder where the python intermediate build files take place PYBUILD = ./$(LXC_ENV_FOLDER)build # python version to use -PY =3 -PYTHON = python$(PY) -PIP = pip$(PY) +PY ?=3 +# $(PYTHON) points to the python interpreter from the OS! The python from the +# OS is needed e.g. to create a virtualenv. For tasks inside the virtualenv the +# interpeter from '$(PY_ENV_BIN)/python' is used. +PYTHON ?= python$(PY) +PIP ?= pip$(PY) PIP_INST ?= --user # https://www.python.org/dev/peps/pep-0508/#extras @@ -27,7 +30,7 @@ PYLINT_RC ?= .pylintrc TEST_FOLDER ?= ./tests TEST ?= . -VTENV_OPTS ?= +VTENV_OPTS = "--no-site-packages" PY_ENV = ./$(LXC_ENV_FOLDER)local/py$(PY) PY_ENV_BIN = $(PY_ENV)/bin PY_ENV_ACT = . $(PY_ENV_BIN)/activate @@ -38,6 +41,20 @@ ifeq ($(OS),Windows_NT) PY_ENV_ACT = $(PY_ENV_BIN)/activate endif +ifeq ($(PYTHON),python) + VIRTUALENV = virtualenv +else + VIRTUALENV = virtualenv --python=$(PYTHON) +endif + +ifeq ($(KBUILD_VERBOSE),1) + PIP_VERBOSE = + VIRTUALENV_VERBOSE = +else + PIP_VERBOSE = "-q" + VIRTUALENV_VERBOSE = "-q" +endif + python-help:: @echo 'makefile.python:' @echo ' pyenv | pyenv[un]install' @@ -81,22 +98,6 @@ python-exe: @: endif -msg-pip-exe: - @echo "\n $(PIP) is required\n\n\ - Make sure you have updated pip installed, grab it from\n\ - https://pip.pypa.io or install it from your package\n\ - manager. On debian based OS these requirements are\n\ - installed by::\n\n\ - sudo -H apt-get install python$(PY)-pip\n" | $(FMT) - -ifeq ($(shell which $(PIP) >/dev/null 2>&1; echo $$?), 1) -pip-exe: msg-pip-exe - $(error The '$(PIP)' command was not found) -else -pip-exe: - @: -endif - # ------------------------------------------------------------------------------ # commands # ------------------------------------------------------------------------------ @@ -107,9 +108,9 @@ quiet_cmd_pyinstall = INSTALL $2 # $2 path to folder with setup.py, this uses pip from pyenv (not OS!) quiet_cmd_pyenvinstall = PYENV install $2 - cmd_pyenvinstall = $(PY_ENV_BIN)/pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS) + cmd_pyenvinstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e $2$(PY_SETUP_EXTRAS) -# Uninstall the package. Since pip does not uninstall the no longer needed +# Uninstall the package. Since pip does not uninstall the no longer needed # depencies (something like autoremove) the depencies remain. # $2 package name to uninstall, this uses pip from the OS. @@ -118,25 +119,23 @@ quiet_cmd_pyuninstall = UNINSTALL $2 # $2 path to folder with setup.py, this uses pip from pyenv (not OS!) quiet_cmd_pyenvuninstall = PYENV uninstall $2 - cmd_pyenvuninstall = $(PY_ENV_BIN)/pip $(PIP_VERBOSE) uninstall --yes $2 + cmd_pyenvuninstall = $(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) uninstall --yes $2 # $2 path to folder where virtualenv take place quiet_cmd_virtualenv = PYENV usage: $ source ./$@/bin/activate cmd_virtualenv = \ - if [ ! -d "$(PY_ENV)" ];then \ - echo "PYENV create virtualenv $2"; \ - $(PYTHON) -m venv $(VTENV_OPTS) $2; \ + if [ ! -d "./$(PY_ENV)" ];then \ + $(VIRTUALENV) $(VIRTUALENV_VERBOSE) $(VTENV_OPTS) $2; \ else \ echo "PYENV using virtualenv from $2"; \ - fi; \ - echo "commands available at $(PY_ENV_BIN):"; ls $(PY_ENV_BIN) | $(FMT) ; + fi # $2 path to lint quiet_cmd_pylint = LINT $@ - cmd_pylint = $(PY_ENV_BIN)/pylint --rcfile $(PYLINT_RC) $2 + cmd_pylint = $(PY_ENV_BIN)/python -m pylint --rcfile $(PYLINT_RC) $2 quiet_cmd_pytest = TEST $@ - cmd_pytest = $(PY_ENV_BIN)/tox -vv + cmd_pytest = $(PY_ENV_BIN)/python -m tox -vv # setuptools, pip, easy_install its a mess full of cracks, a documentation hell # and broken by design ... all sucks, I really, really hate all this ... aaargh! @@ -203,7 +202,7 @@ PHONY += pyclean pyclean: $(call cmd,pyclean) -# to build *local* environment, python and virtualenv from the OS is needed! +# to build *local* environment, python from the OS is needed! pyenv: $(PY_ENV) $(PY_ENV): python-exe $(call cmd,virtualenv,$(PY_ENV)) @@ -212,7 +211,7 @@ $(PY_ENV): python-exe PHONY += pylint-exe pylint-exe: $(PY_ENV) - @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) install pylint + @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install pylint PHONY += pylint pylint: pylint-exe @@ -236,11 +235,11 @@ pydebug: $(PY_ENV) # install / uninstall python objects into virtualenv (PYENV) pyenv-install: $(PY_ENV) - @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) install -e . + @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) install -e . @echo "ACTIVATE $(call normpath,$(PY_ENV_ACT)) " pyenv-uninstall: $(PY_ENV) - @$(PY_ENV_BIN)/pip $(PIP_VERBOSE) uninstall --yes . + @$(PY_ENV_BIN)/python -m pip $(PIP_VERBOSE) uninstall --yes . # runs python interpreter from ./local/py<N>/bin/python pyenv-python: pyenv-install |