diff --git a/.travis.yml b/.travis.yml index c1a9c2b2..76a20b00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,19 @@ os: linux dist: bionic -arch: arm64 language: python cache: - directories: - $HOME/.cache/pip -before_cache: - - sudo chown -R travis:travis $HOME/.cache/pip - - rm -f $HOME/.cache/pip/log/debug.log addons: firefox: "latest" install: + - env + - which python; python --version - make V=1 install - make V=1 gecko.driver - make V=1 node.env - - local/py3/bin/pip install codecov + - make V=1 travis.codecov script: - make V=1 themes - make V=1 test @@ -31,6 +29,7 @@ stages: jobs: include: - python: "2.7" + env: PY=2 - python: "3.5" - python: "3.6" - stage: docker diff --git a/Makefile b/Makefile index f38b5ca8..aefd005f 100644 --- a/Makefile +++ b/Makefile @@ -210,6 +210,10 @@ gecko.driver: PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot +ifeq ($(PY),2) +test.pylint: + @echo "LINT skip liniting py2" +else # TODO: balance linting with pylint test.pylint: pyenvinstall @@ -217,6 +221,7 @@ test.pylint: pyenvinstall searx/preferences.py \ searx/testing.py \ ) +endif # ignored rules: # E402 module level import not at top of file @@ -256,4 +261,11 @@ test.clean: @echo "CLEAN intermediate test stuff" $(Q)rm -rf geckodriver.log .coverage coverage/ + +# travis +# ------ + +travis.codecov: + $(Q)$(PY_ENV_BIN)/python -m pip install codecov + .PHONY: $(PHONY) diff --git a/manage.sh b/manage.sh index 4831fc1f..b2ffb638 100755 --- a/manage.sh +++ b/manage.sh @@ -121,8 +121,9 @@ docker_build() { SEARX_GIT_VERSION=$(git describe --match "v[0-9]*\.[0-9]*\.[0-9]*" HEAD 2>/dev/null | awk -F'-' '{OFS="-"; $1=substr($1, 2); $3=substr($3, 2); print}') # add the suffix "-dirty" if the repository has uncommited change + # /!\ HACK for searx/searx: ignore searx/brand.py and utils/brand.env git update-index -q --refresh - if [ ! -z "$(git diff-index --name-only HEAD --)" ]; then + if [ ! -z "$(git diff-index --name-only HEAD -- | grep -v 'searx/brand.py' | grep -v 'utils/brand.env')" ]; then SEARX_GIT_VERSION="${SEARX_GIT_VERSION}-dirty" fi diff --git a/utils/makefile.python b/utils/makefile.python index 2e488bf2..49944442 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/bin/python pyenv-python: pyenv-install