@@ -1,33 +1,33 @@
1.. _makefile:
1.. _makefile:
3−================
3+========
4−Makefile Targets
4+Makefile
5−================
5+========
7.. _gnu-make: https://www.gnu.org/software/make/manual/make.html#Introduction
7.. _gnu-make: https://www.gnu.org/software/make/manual/make.html#Introduction
9.. sidebar:: build environment
9.. sidebar:: build environment
11− Before looking deeper at the targets, first read about :ref:`make pyenv`.
11+ Before looking deeper at the targets, first read about :ref:`make
13 To install system requirements follow :ref:`buildhosts`.
14 To install system requirements follow :ref:`buildhosts`.
15−With the aim to simplify development cycles, started with :pull:`1756` a
16+All relevant build tasks are implemented in :origin:`manage.sh` and for CI or
16−``Makefile`` based boilerplate was added. If you are not familiar with
17+IDE integration a small ``Makefile`` wrapper is available. If you are not
17−Makefiles, we recommend to read gnu-make_ introduction.
18+familiar with Makefiles, we recommend to read gnu-make_ introduction.
19The usage is simple, just type ``make {target-name}`` to *build* a target.
20The usage is simple, just type ``make {target-name}`` to *build* a target.
20Calling the ``help`` target gives a first overview (``make help``):
21Calling the ``help`` target gives a first overview (``make help``):
22.. program-output:: bash -c "cd ..; make --no-print-directory help"
23.. program-output:: bash -c "cd ..; make --no-print-directory help"
25.. contents:: Contents
25.. contents:: Contents
28 :backlinks: entry
28 :backlinks: entry
30−.. _make pyenv:
30+.. _make install:
32Python environment
32Python environment
33==================
33==================
@@ -36,31 +36,42 @@ Python environment
37 ``source ./local/py3/bin/activate``
37 ``source ./local/py3/bin/activate``
39−With Makefile we do no longer need to build up the virtualenv manually (as
39+We do no longer need to build up the virtualenv manually. Jump into your git
40−described in the :ref:`devquickstart` guide). Jump into your git working tree
41−and release a ``make pyenv``:
40+working tree and release a ``make install`` to get a virtualenv with a
42−
41+*developer install* of searx (:origin:`setup.py`). ::
45 $ cd ~/searx-clone
43 $ cd ~/searx-clone
46− $ make pyenv
44+ $ make install
47− PYENV usage: source ./local/py3/bin/activate
45+ PYENV [virtualenv] installing ./requirements*.txt into local/py3
48+ PYENV [install] pip install -e 'searx[test]'
50+ Successfully installed argparse-1.4.0 searx
51+ BUILDENV INFO:searx:load the default settings from ./searx/settings.yml
52+ BUILDENV INFO:searx:Initialisation done
53+ BUILDENV build utils/brand.env
50−With target ``pyenv`` a development environment (aka virtualenv) was build up in
55+If you release ``make install`` multiple times the installation will only
51−``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`)
56+rebuild if the sha256 sum of the *requirement files* fails. With other words:
52−into this environment, use make target ``install``:
57+the check fails if you edit the requirements listed in
53−
58+:origin:`requirements-dev.txt` and :origin:`requirements.txt`). ::
56 $ make install
60 $ make install
57− PYENV usage: source ./local/py3/bin/activate
61+ PYENV OK
58− PYENV using virtualenv from ./local/py3
62+ PYENV [virtualenv] requirements.sha256 failed
59− PYENV install .
63+ [virtualenv] - 6cea6eb6def9e14a18bf32f8a3e... ./requirements-dev.txt
60−
64+ [virtualenv] - 471efef6c73558e391c3adb35f4... ./requirements.txt
61−You have never to think about intermediate targets like ``pyenv`` or
65+ ...
62−``install``, the ``Makefile`` chains them as requisites. Just run your main
66+ PYENV [virtualenv] installing ./requirements*.txt into local/py3
69+ PYENV [install] pip install -e 'searx[test]'
71+ Successfully installed argparse-1.4.0 searx
72+ BUILDENV INFO:searx:load the default settings from ./searx/settings.yml
73+ BUILDENV INFO:searx:Initialisation done
74+ BUILDENV build utils/brand.env
65.. sidebar:: drop environment
76.. sidebar:: drop environment
@@ -68,10 +79,7 @@ target.
68 <make clean>` first.
79 <make clean>` first.
70If you think, something goes wrong with your ./local environment or you change
81If you think, something goes wrong with your ./local environment or you change
71−the :origin:`setup.py` file (or the requirements listed in
82+the :origin:`setup.py` file, you have to call :ref:`make clean`.
72−:origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call
76.. _make run:
84.. _make run:
@@ -81,117 +89,113 @@ the :origin:`setup.py` file (or the requirements listed in
81To get up a running a developer instance simply call ``make run``. This enables
89To 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``
90*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
91instance, disables *debug* option again and opens the URL in your favorite WEB
84−browser (:man:`xdg-open`):
92+browser (:man:`xdg-open`)::
88− $ make run
94+ $ make run
89− PYENV usage: source ./local/py3/bin/activate
95+ PYENV OK
91− ./local/py3/bin/python ./searx/webapp.py
96+ SEARX_DEBUG=1 ./manage.sh pyenv.cmd python ./searx/webapp.py
93− INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
98+ INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
96.. _make clean:
100.. _make clean:
98``make clean``
102``make clean``
99==============
103==============
101−Drop all intermediate files, all builds, but keep sources untouched. Includes
105+Drop all intermediate files, all builds, but keep sources untouched. Before
102−target ``pyclean`` which drops ./local environment. Before calling ``make
103−clean`` stop all processes using :ref:`make pyenv`.
106+calling ``make clean`` stop all processes using :ref:`make install`. ::
107 $ make clean
108 $ make clean
108− CLEAN pyclean
109+ CLEAN pyenv
109− CLEAN clean
110+ PYENV [virtualenv] drop ./local/py3
111+ CLEAN docs -- ./build/docs ./dist/docs
112+ CLEAN locally installed npm dependencies
111.. _make docs:
116.. _make docs:
113−``make docs docs-live docs-clean``
118+``make docs docs.autobuild docs.clean``
114−==================================
119+=======================================
116−We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
121+We describe the usage of the ``doc.*`` targets in the :ref:`How to contribute /
117Documentation <contrib docs>` section. If you want to edit the documentation
122Documentation <contrib docs>` section. If you want to edit the documentation
118−read our :ref:`make docs-live` section. If you are working in your own brand,
123+read our :ref:`make docs.live` section. If you are working in your own brand,
119adjust your :ref:`settings global`.
124adjust your :ref:`settings global`.
121−.. _make books:
126+.. _make docs.gh-pages:
123−``make books/{name}.html books/{name}.pdf``
128+``make docs.gh-pages``
124−===========================================
129+======================
126−.. _intersphinx: https://www.sphinx-doc.org/en/stable/ext/intersphinx.html
131+To deploy on github.io first adjust your :ref:`settings global`. For any
127−.. _XeTeX: https://tug.org/xetex/
132+further read :ref:`deploy on github.io`.
129−.. sidebar:: info
134+.. _make test:
131− To build PDF a XeTeX_ is needed, see :ref:`buildhosts`.
136+``make test``
139+Runs a series of tests: :ref:`make test.pylint`, ``test.pep8``, ``test.unit``
140+and ``test.robot``. You can run tests selective, e.g.::
134−The ``books/{name}.*`` targets are building *books*. A *book* is a
142+ $ make test.pep8 test.unit test.sh
135−sub-directory containing a ``conf.py`` file. One example is the user handbook
143+ TEST test.pep8 OK
136−which can deployed separately (:origin:`docs/user/conf.py`). Such ``conf.py``
144+ ...
137−do inherit from :origin:`docs/conf.py` and overwrite values to fit *book's*
145+ TEST test.unit OK
140−With the help of Intersphinx_ (:ref:`reST smart ref`) the links to searx’s
149+.. _make test.sh:
141−documentation 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
143−documentation's build time.
145−Use ``make docs-help`` to see which books available:
151+``make test.sh``
147−.. program-output:: bash -c "cd ..; make --no-print-directory docs-help"
154+:ref:`sh lint` / if you have changed some bash scripting run this test before
148− :ellipsis: 0,-6
155+commit.
157+.. _make test.pylint:
151−.. _make gh-pages:
159+``make test.pylint``
153−``make gh-pages``
162+.. _Pylint: https://www.pylint.org/
156−To deploy on github.io first adjust your :ref:`settings global`. For any
164+Pylint_ is known as one of the best source-code, bug and quality checker for the
157−further read :ref:`deploy on github.io`.
165+Python programming language. The pylint profile we use at searx project is
166+found in project's root folder :origin:`.pylintrc`.
159−.. _make test:
168+.. _make search.checker:
161−``make test``
170+``search.checker.{engine name}``
162−=============
171+================================
164−Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
173+To check all engines::
165−additional :ref:`pylint checks <make pylint>`. You can run tests selective,
168−.. code:: sh
175+ make search.checker
170− $ make test.pep8 test.unit test.sh
177+To check a engine with whitespace in the name like *google news* replace space
171− . ./local/py3/bin/activate; ./manage.sh pep8_check
178+by underline::
172− [!] Running pep8 check
173− . ./local/py3/bin/activate; ./manage.sh unit_tests
174− [!] Running unit tests
176−.. _make pylint:
180+ make search.checker.google_news
178−``make pylint``
182+To see HTTP requests and more use SEARX_DEBUG::
181−.. _Pylint: https://www.pylint.org/
184+ make SEARX_DEBUG=1 search.checker.google_news
186+.. _3xx: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection
183−Before commiting its recommend to do some (more) linting. Pylint_ is known as
188+To filter out HTTP redirects (3xx_)::
184−one of the best source-code, bug and quality checker for the Python programming
185−language. 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
187−quality anyway. The pylint profile we use at searx project is found in
188−project's root folder :origin:`.pylintrc`.
190−Code quality is a ongoing process. Don't try to fix all messages from Pylint,
190+ make SEARX_DEBUG=1 search.checker.google_news | grep -A1 "HTTP/1.1\" 3[0-9][0-9]"
191−run Pylint and check if your changed lines are bringing up new messages. If so,
191+ ...
192−fix it. By this, code quality gets incremental better and if there comes the
192+ Engine google news Checking
193−day, the linting is balanced out, we might decide to add Pylint as a quality
193+ https://news.google.com:443 "GET /search?q=life&hl=en&lr=lang_en&ie=utf8&oe=utf8&ceid=US%3Aen&gl=US HTTP/1.1" 302 0
194−gate.
194+ https://news.google.com:443 "GET /search?q=life&hl=en-US&lr=lang_en&ie=utf8&oe=utf8&ceid=US:en&gl=US HTTP/1.1" 200 None
196+ https://news.google.com:443 "GET /search?q=computer&hl=en&lr=lang_en&ie=utf8&oe=utf8&ceid=US%3Aen&gl=US HTTP/1.1" 302 0
197+ https://news.google.com:443 "GET /search?q=computer&hl=en-US&lr=lang_en&ie=utf8&oe=utf8&ceid=US:en&gl=US HTTP/1.1" 200 None
197``make pybuild``
201``make pybuild``
@@ -200,9 +204,7 @@ gate.
200.. _PyPi: https://pypi.org/
204.. _PyPi: https://pypi.org/
201.. _twine: https://twine.readthedocs.io/en/latest/
205.. _twine: https://twine.readthedocs.io/en/latest/
203−Build Python packages in ``./dist/py``.
207+Build Python packages in ``./dist/py``::
207 $ make pybuild
209 $ make pybuild
@@ -210,9 +212,11 @@ Build Python packages in ``./dist/py``.
210 running sdist
212 running sdist
211 running egg_info
213 running egg_info
213− $ ls ./dist/py/
217+ $ ls ./dist
214− searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
218+ searx-0.18.0-py3-none-any.whl searx-0.18.0.tar.gz
216−To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
220+To upload packages to PyPi_, there is also a ``pypi.upload`` target (to test use
217−twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
221+``pypi.upload.test``). Since you are not the owner of :pypi:`searx` you will
218−never need the latter.
222+never need to upload.