on 5fc17de help sign in
searx/docs/dev/makefile.rst
221 lines 6.2 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 (``make help``):
23.. program-output:: bash -c "cd ..; make --no-print-directory help"
26.. contents:: Contents
27 :depth: 2
28 :local:
29 :backlinks: entry
32.. _makefile setup:
34Makefile setup
35==============
37.. _git stash: https://git-scm.com/docs/git-stash
39.. sidebar:: fork & upstream
41 Commit changes in your (local) branch, fork or whatever, but do not push them
42 upstream / `git stash`_ is your friend.
44The main setup is done in the :origin:`Makefile`.
46.. literalinclude:: ../../Makefile
47 :start-after: START Makefile setup
48 :end-before: END Makefile setup
50:GIT_URL: Changes this, to point to your searx fork.
51:GIT_BRANCH: Changes this, to point to your searx branch.
52:SEARX_URL: Changes this, to point to your searx instance.
53:DOCS_URL: If you host your own (*brand*) documentation, change this URL.
55If you change any of this build environment variables, you have to run ``make
56buildenv``::
58 $ make buildenv
59 build searx/brand.py
60 build utils/brand.env
62.. _make pyenv:
64Python environment
65==================
67.. sidebar:: activate environment
69 ``source ./local/py3/bin/activate``
71With Makefile we do no longer need to build up the virualenv manually (as
72described in the :ref:`devquickstart` guide). Jump into your git working tree
73and release a ``make pyenv``:
75.. code:: sh
77 $ cd ~/searx-clone
78 $ make pyenv
79 PYENV usage: source ./local/py3/bin/activate
80 ...
82With target ``pyenv`` a development environment (aka virtualenv) was build up in
83``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`)
84into this environment, use make target ``install``:
86.. code:: sh
88 $ make install
89 PYENV usage: source ./local/py3/bin/activate
90 PYENV using virtualenv from ./local/py3
91 PYENV install .
93You have never to think about intermediate targets like ``pyenv`` or
94``install``, the ``Makefile`` chains them as requisites. Just run your main
95target.
97.. sidebar:: drop environment
99 To get rid of the existing environment before re-build use :ref:`clean target
100 <make clean>` first.
102If you think, something goes wrong with your ./local environment or you change
103the :origin:`setup.py` file (or the requirements listed in
104:origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call
105:ref:`make clean`.
108.. _make run:
110``make run``
111============
113To get up a running a developer instance simply call ``make run``. This enables
114*debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
115instance, disables *debug* option again and opens the URL in your favorite WEB
116browser (:man:`xdg-open`):
118.. code:: sh
120 $ make run
121 PYENV usage: source ./local/py3/bin/activate
122 PYENV install .
123 ./local/py3/bin/python ./searx/webapp.py
124 ...
125 INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
126 ...
128.. _make clean:
130``make clean``
131==============
133Drop all intermediate files, all builds, but keep sources untouched. Includes
134target ``pyclean`` which drops ./local environment. Before calling ``make
135clean`` stop all processes using :ref:`make pyenv`.
137.. code:: sh
139 $ make clean
140 CLEAN pyclean
141 CLEAN clean
143.. _make docs:
145``make docs docs-live docs-clean``
146==================================
148We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
149Documentation <contrib docs>` section. If you want to edit the documentation
150read our :ref:`make docs-live` section. If you are working in your own brand,
151adjust your :ref:`Makefile setup <makefile setup>`.
154.. _make gh-pages:
156``make gh-pages``
157=================
159To deploy on github.io first adjust your :ref:`Makefile setup <makefile
160setup>`. For any further read :ref:`deploy on github.io`.
162.. _make test:
164``make test``
165=============
167Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
168additional :ref:`pylint checks <make pylint>`. You can run tests selective,
169e.g.:
171.. code:: sh
173 $ make test.pep8 test.unit test.sh
174 . ./local/py3/bin/activate; ./manage.sh pep8_check
175 [!] Running pep8 check
176 . ./local/py3/bin/activate; ./manage.sh unit_tests
177 [!] Running unit tests
179.. _make pylint:
181``make pylint``
182===============
184.. _Pylint: https://www.pylint.org/
186Before commiting its recommend to do some (more) linting. Pylint_ is known as
187one of the best source-code, bug and quality checker for the Python programming
188language. Pylint_ is not yet a quality gate within our searx project (like
189:ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve code
190quality anyway. The pylint profile we use at searx project is found in
191project's root folder :origin:`.pylintrc`.
193Code quality is a ongoing process. Don't try to fix all messages from Pylint,
194run Pylint and check if your changed lines are bringing up new messages. If so,
195fix it. By this, code quality gets incremental better and if there comes the
196day, the linting is balanced out, we might decide to add Pylint as a quality
197gate.
200``make pybuild``
201================
203.. _PyPi: https://pypi.org/
204.. _twine: https://twine.readthedocs.io/en/latest/
206Build Python packages in ``./dist/py``.
208.. code:: sh
210 $ make pybuild
211 ...
212 BUILD pybuild
213 running sdist
214 running egg_info
215 ...
216 $ ls ./dist/py/
217 searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
219To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
220twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
221never need the latter.