| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 | .. _makefile:================Makefile Targets================.. _gnu-make: https://www.gnu.org/software/make/manual/make.html.. sidebar:: build environment   Before looking deeper at the targets, first read about :ref:`makefile setup`   and :ref:`make pyenv`.   To install system requirements follow :ref:`buildhosts`.With the aim to simplify development cycles, started with :pull:`1756` a``Makefile`` based boilerplate was added.  If you are not familiar withMakefiles, we recommend to read gnu-make_ introduction.The usage is simple, just type ``make {target-name}`` to *build* a target.Calling the ``help`` target gives a first overview (``make help``):.. program-output:: bash -c "cd ..; make --no-print-directory help".. contents:: Contents   :depth: 2   :local:   :backlinks: entry.. _makefile setup:Makefile setup==============.. _git stash: https://git-scm.com/docs/git-stash.. sidebar:: fork & upstream   Commit changes in your (local) branch, fork or whatever, but do not push them   upstream / `git stash`_ is your friend.The main setup is done in the :origin:`Makefile`... literalinclude:: ../../Makefile   :start-after: START Makefile setup   :end-before: END Makefile setup:GIT_URL:    Changes this, to point to your searx fork.:GIT_BRANCH: Changes this, to point to your searx branch.:SEARX_URL:  Changes this, to point to your searx instance.:DOCS_URL:   If you host your own (*brand*) documentation, change this URL.If you change any of this build environment variables, you have to run ``makebuildenv``::  $ make buildenv  build searx/brand.py  build utils/brand.env.. _make pyenv:Python environment==================.. sidebar:: activate environment   ``source ./local/py3/bin/activate``With Makefile we do no longer need to build up the virualenv manually (asdescribed in the :ref:`devquickstart` guide).  Jump into your git working treeand release a ``make pyenv``:.. code:: sh   $ cd ~/searx-clone   $ make pyenv   PYENV     usage: source ./local/py3/bin/activate   ...With target ``pyenv`` a development environment (aka virtualenv) was build up in``./local/py3/``.  To make a *developer install* of searx (:origin:`setup.py`)into this environment, use make target ``install``:.. code:: sh   $ make install   PYENV     usage: source ./local/py3/bin/activate   PYENV     using virtualenv from ./local/py3   PYENV     install .You have never to think about intermediate targets like ``pyenv`` or``install``, the ``Makefile`` chains them as requisites.  Just run your maintarget... sidebar:: drop environment   To get rid of the existing environment before re-build use :ref:`clean target   <make clean>` first.If you think, something goes wrong with your ./local environment or you changethe :origin:`setup.py` file (or the requirements listed in:origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call:ref:`make clean`... _make run:``make run``============To get up a running a developer instance simply call ``make run``.  This enables*debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``instance, disables *debug* option again and opens the URL in your favorite WEBbrowser (:man:`xdg-open`):.. code:: sh  $ make run  PYENV     usage: source ./local/py3/bin/activate  PYENV     install .  ./local/py3/bin/python ./searx/webapp.py  ...  INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)  ..... _make clean:``make clean``==============Drop all intermediate files, all builds, but keep sources untouched.  Includestarget ``pyclean`` which drops ./local environment.  Before calling ``makeclean`` stop all processes using :ref:`make pyenv`... code:: sh   $ make clean   CLEAN     pyclean   CLEAN     clean.. _make docs:``make docs docs-live docs-clean``==================================We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /Documentation <contrib docs>` section.  If you want to edit the documentationread our :ref:`make docs-live` section.  If you are working in your own brand,adjust your :ref:`Makefile setup <makefile setup>`... _make gh-pages:``make gh-pages``=================To deploy on github.io first adjust your :ref:`Makefile setup <makefilesetup>`.  For any further read :ref:`deploy on github.io`... _make test:``make test``=============Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and doesadditional :ref:`pylint checks <make pylint>`.  You can run tests selective,e.g.:.. code:: sh  $ make test.pep8 test.unit test.sh  . ./local/py3/bin/activate; ./manage.sh pep8_check  [!] Running pep8 check  . ./local/py3/bin/activate; ./manage.sh unit_tests  [!] Running unit tests.. _make pylint:``make pylint``===============.. _Pylint: https://www.pylint.org/Before commiting its recommend to do some (more) linting.  Pylint_ is known asone of the best source-code, bug and quality checker for the Python programminglanguage.  Pylint_ is not yet a quality gate within our searx project (like:ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve codequality anyway.  The pylint profile we use at searx project is found inproject's root folder :origin:`.pylintrc`.Code quality is a ongoing process.  Don't try to fix all messages from Pylint,run Pylint and check if your changed lines are bringing up new messages.  If so,fix it.  By this, code quality gets incremental better and if there comes theday, the linting is balanced out, we might decide to add Pylint as a qualitygate.``make pybuild``================.. _PyPi: https://pypi.org/.. _twine: https://twine.readthedocs.io/en/latest/Build Python packages in ``./dist/py``... code:: sh  $ make pybuild  ...  BUILD     pybuild  running sdist  running egg_info  ...  $ ls  ./dist/py/  searx-0.15.0-py3-none-any.whl  searx-0.15.0.tar.gzTo upload packages to PyPi_, there is also a ``upload-pypi`` target.  It needstwine_ to be installed.  Since you are not the owner of :pypi:`searx` you willnever need the latter.
 |