on ddab00a help sign in
searx/docs/dev/makefile.rst
218 lines 6.3 kB history raw
1.. _makefile:
3================
4Makefile Targets
5================
7.. _gnu-make: https://www.gnu.org/software/make/manual/make.html#Introduction
9.. sidebar:: build environment
11 Before looking deeper at the targets, first read about :ref:`make pyenv`.
13 To install system requirements follow :ref:`buildhosts`.
15With the aim to simplify development cycles, started with :pull:`1756` a
16``Makefile`` based boilerplate was added. If you are not familiar with
17Makefiles, we recommend to read gnu-make_ introduction.
19The usage is simple, just type ``make {target-name}`` to *build* a target.
20Calling the ``help`` target gives a first overview (``make help``):
22.. program-output:: bash -c "cd ..; make --no-print-directory help"
25.. contents:: Contents
26 :depth: 2
27 :local:
28 :backlinks: entry
30.. _make pyenv:
32Python environment
33==================
35.. sidebar:: activate environment
37 ``source ./local/py3/bin/activate``
39With Makefile we do no longer need to build up the virtualenv manually (as
40described in the :ref:`devquickstart` guide). Jump into your git working tree
41and release a ``make pyenv``:
43.. code:: sh
45 $ cd ~/searx-clone
46 $ make pyenv
47 PYENV usage: source ./local/py3/bin/activate
48 ...
50With target ``pyenv`` a development environment (aka virtualenv) was build up in
51``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`)
52into this environment, use make target ``install``:
54.. code:: sh
56 $ make install
57 PYENV usage: source ./local/py3/bin/activate
58 PYENV using virtualenv from ./local/py3
59 PYENV install .
61You have never to think about intermediate targets like ``pyenv`` or
62``install``, the ``Makefile`` chains them as requisites. Just run your main
63target.
65.. sidebar:: drop environment
67 To get rid of the existing environment before re-build use :ref:`clean target
68 <make clean>` first.
70If you think, something goes wrong with your ./local environment or you change
71the :origin:`setup.py` file (or the requirements listed in
72:origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call
73:ref:`make clean`.
76.. _make run:
78``make run``
79============
81To get up a running a developer instance simply call ``make run``. This enables
82*debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
83instance, disables *debug* option again and opens the URL in your favorite WEB
84browser (:man:`xdg-open`):
86.. code:: sh
88 $ make run
89 PYENV usage: source ./local/py3/bin/activate
90 PYENV install .
91 ./local/py3/bin/python ./searx/webapp.py
92 ...
93 INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
94 ...
96.. _make clean:
98``make clean``
99==============
101Drop all intermediate files, all builds, but keep sources untouched. Includes
102target ``pyclean`` which drops ./local environment. Before calling ``make
103clean`` stop all processes using :ref:`make pyenv`.
105.. code:: sh
107 $ make clean
108 CLEAN pyclean
109 CLEAN clean
111.. _make docs:
113``make docs docs-live docs-clean``
114==================================
116We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
117Documentation <contrib docs>` section. If you want to edit the documentation
118read our :ref:`make docs-live` section. If you are working in your own brand,
119adjust your :ref:`settings global`.
121.. _make books:
123``make books/{name}.html books/{name}.pdf``
124===========================================
126.. _intersphinx: https://www.sphinx-doc.org/en/stable/ext/intersphinx.html
127.. _XeTeX: https://tug.org/xetex/
129.. sidebar:: info
131 To build PDF a XeTeX_ is needed, see :ref:`buildhosts`.
134The ``books/{name}.*`` targets are building *books*. A *book* is a
135sub-directory containing a ``conf.py`` file. One example is the user handbook
136which can deployed separately (:origin:`docs/user/conf.py`). Such ``conf.py``
137do inherit from :origin:`docs/conf.py` and overwrite values to fit *book's*
138needs.
140With the help of Intersphinx_ (:ref:`reST smart ref`) the links to searx’s
141documentation outside of the book will be bound by the object inventory of
142``DOCS_URL``. Take into account that URLs will be picked from the inventary at
143documentation's build time.
145Use ``make docs-help`` to see which books available:
147.. program-output:: bash -c "cd ..; make --no-print-directory docs-help"
148 :ellipsis: 0,-6
151.. _make gh-pages:
153``make gh-pages``
154=================
156To deploy on github.io first adjust your :ref:`settings global`. For any
157further read :ref:`deploy on github.io`.
159.. _make test:
161``make test``
162=============
164Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
165additional :ref:`pylint checks <make pylint>`. You can run tests selective,
166e.g.:
168.. code:: sh
170 $ make test.pep8 test.unit test.sh
171 . ./local/py3/bin/activate; ./manage.sh pep8_check
172 [!] Running pep8 check
173 . ./local/py3/bin/activate; ./manage.sh unit_tests
174 [!] Running unit tests
176.. _make pylint:
178``make pylint``
179===============
181.. _Pylint: https://www.pylint.org/
183Before commiting its recommend to do some (more) linting. Pylint_ is known as
184one of the best source-code, bug and quality checker for the Python programming
185language. Pylint_ is not yet a quality gate within our searx project (like
186:ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve code
187quality anyway. The pylint profile we use at searx project is found in
188project's root folder :origin:`.pylintrc`.
190Code quality is a ongoing process. Don't try to fix all messages from Pylint,
191run Pylint and check if your changed lines are bringing up new messages. If so,
192fix it. By this, code quality gets incremental better and if there comes the
193day, the linting is balanced out, we might decide to add Pylint as a quality
194gate.
197``make pybuild``
198================
200.. _PyPi: https://pypi.org/
201.. _twine: https://twine.readthedocs.io/en/latest/
203Build Python packages in ``./dist/py``.
205.. code:: sh
207 $ make pybuild
208 ...
209 BUILD pybuild
210 running sdist
211 running egg_info
212 ...
213 $ ls ./dist/py/
214 searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
216To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
217twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
218never need the latter.