on c2b27d9 help sign in
searx/docs/dev/makefile.rst
223 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:`makefile setup`
12 and :ref:`make pyenv`.
14 To install system requirements follow :ref:`buildhosts`.
16With the aim to simplify development cycles, started with :pull:`1756` a
17``Makefile`` based boilerplate was added. If you are not familiar with
18Makefiles, we recommend to read gnu-make_ introduction.
20The usage is simple, just type ``make {target-name}`` to *build* a target.
21Calling the ``help`` target gives a first overview::
23 $ make help
24 test - run developer tests
25 docs - build documentation
26 docs-live - autobuild HTML documentation while editing
27 run - run developer instance
28 install - developer install (./local)
29 uninstall - uninstall (./local)
30 gh-pages - build docs & deploy on gh-pages branch
31 clean - drop builds and environments
32 ...
34.. contents:: Contents
35 :depth: 2
36 :local:
37 :backlinks: entry
40.. _makefile setup:
42Setup
43=====
45.. _git stash: https://git-scm.com/docs/git-stash
47The main setup is done in the :origin:`Makefile`::
49 export GIT_URL=https://github.com/asciimoo/searx
50 export SEARX_URL=https://searx.me
51 export DOCS_URL=https://asciimoo.github.io/searx
53.. sidebar:: fork & upstream
55 Commit changes in your (local) branch, fork or whatever, but do not push them
56 upstream / `git stash`_ is your friend.
58:GIT_URL: Changes this, to point to your searx fork.
60:SEARX_URL: Changes this, to point to your searx instance.
62:DOCS_URL: If you host your own (branded) documentation, change this URL.
64.. _make pyenv:
66Python environment
67==================
69.. sidebar:: activate environment
71 ``source ./local/py3/bin/activate``
73With Makefile we do no longer need to build up the virualenv manually (as
74described in the :ref:`devquickstart` guide). Jump into your git working tree
75and release a ``make pyenv``:
77.. code:: sh
79 $ cd ~/searx-clone
80 $ make pyenv
81 PYENV usage: source ./local/py3/bin/activate
82 ...
84With target ``pyenv`` a development environment (aka virtualenv) was build up in
85``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`)
86into this environment, use make target ``install``:
88.. code:: sh
90 $ make install
91 PYENV usage: source ./local/py3/bin/activate
92 PYENV using virtualenv from ./local/py3
93 PYENV install .
95You have never to think about intermediate targets like ``pyenv`` or
96``install``, the ``Makefile`` chains them as requisites. Just run your main
97target.
99.. sidebar:: drop environment
101 To get rid of the existing environment before re-build use :ref:`clean target
102 <make clean>` first.
104If you think, something goes wrong with your ./local environment or you change
105the :origin:`setup.py` file (or the requirements listed in
106:origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call
107:ref:`make clean`.
110.. _make run:
112``make run``
113============
115To get up a running a developer instance simply call ``make run``. This enables
116*debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
117instance, disables *debug* option again and opens the URL in your favorite WEB
118browser (:man:`xdg-open`):
120.. code:: sh
122 $ make run
123 PYENV usage: source ./local/py3/bin/activate
124 PYENV install .
125 ./local/py3/bin/python ./searx/webapp.py
126 ...
127 INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
128 ...
130.. _make clean:
132``make clean``
133==============
135Drop all intermediate files, all builds, but keep sources untouched. Includes
136target ``pyclean`` which drops ./local environment. Before calling ``make
137clean`` stop all processes using :ref:`make pyenv`.
139.. code:: sh
141 $ make clean
142 CLEAN pyclean
143 CLEAN clean
145.. _make docs:
147``make docs docs-live docs-clean``
148==================================
150We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
151Documentation <contrib docs>` section. If you want to edit the documentation
152read our :ref:`make docs-live` section. If you are working in your own brand,
153adjust your :ref:`Makefile setup <makefile setup>`.
156.. _make gh-pages:
158``make gh-pages``
159=================
161To deploy on github.io first adjust your :ref:`Makefile setup <makefile
162setup>`. For any further read :ref:`deploy on github.io`.
164.. _make test:
166``make test``
167=============
169Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
170additional :ref:`pylint checks <make pylint>`. You can run tests selective,
171e.g.:
173.. code:: sh
175 $ make test.pep8 test.unit test.sh
176 . ./local/py3/bin/activate; ./manage.sh pep8_check
177 [!] Running pep8 check
178 . ./local/py3/bin/activate; ./manage.sh unit_tests
179 [!] Running unit tests
181.. _make pylint:
183``make pylint``
184===============
186.. _Pylint: https://www.pylint.org/
188Before commiting its recommend to do some (more) linting. Pylint_ is known as
189one of the best source-code, bug and quality checker for the Python programming
190language. Pylint_ is not yet a quality gate within our searx project (like
191:ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve code
192quality anyway. The pylint profile we use at searx project is found in
193project's root folder :origin:`.pylintrc`.
195Code quality is a ongoing process. Don't try to fix all messages from Pylint,
196run Pylint and check if your changed lines are bringing up new messages. If so,
197fix it. By this, code quality gets incremental better and if there comes the
198day, the linting is balanced out, we might decide to add Pylint as a quality
199gate.
202``make pybuild``
203================
205.. _PyPi: https://pypi.org/
206.. _twine: https://twine.readthedocs.io/en/latest/
208Build Python packages in ``./dist/py``.
210.. code:: sh
212 $ make pybuild
213 ...
214 BUILD pybuild
215 running sdist
216 running egg_info
217 ...
218 $ ls ./dist/py/
219 searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
221To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
222twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
223never need the latter.