makefile.rst 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. .. _makefile:
  2. ========
  3. Makefile
  4. ========
  5. .. _gnu-make: https://www.gnu.org/software/make/manual/make.html#Introduction
  6. .. sidebar:: build environment
  7. Before looking deeper at the targets, first read about :ref:`make
  8. install`.
  9. To install system requirements follow :ref:`buildhosts`.
  10. All relevant build tasks are implemented in :origin:`manage.sh` and for CI or
  11. IDE integration a small ``Makefile`` wrapper is available. If you are not
  12. familiar with Makefiles, we recommend to read gnu-make_ introduction.
  13. The usage is simple, just type ``make {target-name}`` to *build* a target.
  14. Calling the ``help`` target gives a first overview (``make help``):
  15. .. program-output:: bash -c "cd ..; make --no-print-directory help"
  16. .. contents:: Contents
  17. :depth: 2
  18. :local:
  19. :backlinks: entry
  20. .. _make install:
  21. Python Environment (``make install``)
  22. =====================================
  23. .. sidebar:: activate environment
  24. ``source ./local/py3/bin/activate``
  25. We do no longer need to build up the virtualenv manually. Jump into your git
  26. working tree and release a ``make install`` to get a virtualenv with a
  27. *developer install* of SearXNG (:origin:`setup.py`). ::
  28. $ cd ~/searx-clone
  29. $ make install
  30. PYENV [virtualenv] installing ./requirements*.txt into local/py3
  31. ...
  32. PYENV OK
  33. PYENV [install] pip install -e 'searx[test]'
  34. ...
  35. Successfully installed argparse-1.4.0 searx
  36. BUILDENV INFO:searx:load the default settings from ./searx/settings.yml
  37. BUILDENV INFO:searx:Initialisation done
  38. BUILDENV build utils/brand.env
  39. If you release ``make install`` multiple times the installation will only
  40. rebuild if the sha256 sum of the *requirement files* fails. With other words:
  41. the check fails if you edit the requirements listed in
  42. :origin:`requirements-dev.txt` and :origin:`requirements.txt`). ::
  43. $ make install
  44. PYENV OK
  45. PYENV [virtualenv] requirements.sha256 failed
  46. [virtualenv] - 6cea6eb6def9e14a18bf32f8a3e... ./requirements-dev.txt
  47. [virtualenv] - 471efef6c73558e391c3adb35f4... ./requirements.txt
  48. ...
  49. PYENV [virtualenv] installing ./requirements*.txt into local/py3
  50. ...
  51. PYENV OK
  52. PYENV [install] pip install -e 'searx[test]'
  53. ...
  54. Successfully installed argparse-1.4.0 searx
  55. BUILDENV INFO:searx:load the default settings from ./searx/settings.yml
  56. BUILDENV INFO:searx:Initialisation done
  57. BUILDENV build utils/brand.env
  58. .. sidebar:: drop environment
  59. To get rid of the existing environment before re-build use :ref:`clean target
  60. <make clean>` first.
  61. If you think, something goes wrong with your ./local environment or you change
  62. the :origin:`setup.py` file, you have to call :ref:`make clean`.
  63. .. _make buildenv:
  64. ``make buildenv``
  65. =================
  66. Rebuild instance's environment with the modified settings from the
  67. :ref:`settings global brand` and :ref:`settings global server` section of your
  68. :ref:`settings.yml <settings location>`.
  69. We have all SearXNG setups are centralized in the :ref:`settings.yml` file.
  70. This setup is available as long we are in a *installed instance*. E.g. the
  71. *installed instance* on the server or the *installed developer instance* at
  72. ``./local`` (the later one is created by a :ref:`make install <make
  73. install>` or :ref:`make run <make run>`).
  74. Tasks running outside of an *installed instance*, especially those tasks and
  75. scripts running at (pre-) installation time do not have access to the SearXNG
  76. setup (from a *installed instance*). Those tasks need a *build environment*.
  77. The ``make buildenv`` target will update the *build environment* in:
  78. - :origin:`utils/brand.env`
  79. Tasks running outside of an *installed instance*, need the following settings
  80. from the YAML configuration:
  81. - ``SEARXNG_URL`` from :ref:`server.base_url <settings global server>` (aka
  82. ``PUBLIC_URL``)
  83. - ``SEARXNG_BIND_ADDRESS`` from :ref:`server.bind_address <settings global server>`
  84. - ``SEARXNG_PORT`` from :ref:`server.port <settings global server>`
  85. .. _make run:
  86. ``make run``
  87. ============
  88. To get up a running a developer instance simply call ``make run``. This enables
  89. *debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
  90. instance, disables *debug* option again and opens the URL in your favorite WEB
  91. browser (:man:`xdg-open`)::
  92. $ make run
  93. PYENV OK
  94. SEARXNG_DEBUG=1 ./manage.sh pyenv.cmd python ./searx/webapp.py
  95. ...
  96. INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
  97. .. _make clean:
  98. ``make clean``
  99. ==============
  100. Drop all intermediate files, all builds, but keep sources untouched. Before
  101. calling ``make clean`` stop all processes using :ref:`make install`. ::
  102. $ make clean
  103. CLEAN pyenv
  104. PYENV [virtualenv] drop ./local/py3
  105. CLEAN docs -- ./build/docs ./dist/docs
  106. CLEAN locally installed npm dependencies
  107. CLEAN test stuff
  108. CLEAN common files
  109. .. _make docs:
  110. ``make docs docs.autobuild docs.clean``
  111. =======================================
  112. We describe the usage of the ``doc.*`` targets in the :ref:`How to contribute /
  113. Documentation <contrib docs>` section. If you want to edit the documentation
  114. read our :ref:`make docs.live` section. If you are working in your own brand,
  115. adjust your :ref:`settings global`.
  116. .. _make docs.gh-pages:
  117. ``make docs.gh-pages``
  118. ======================
  119. To deploy on github.io first adjust your :ref:`settings global`. For any
  120. further read :ref:`deploy on github.io`.
  121. .. _make test:
  122. ``make test``
  123. =============
  124. Runs a series of tests: :ref:`make test.pylint`, ``test.pep8``, ``test.unit``
  125. and ``test.robot``. You can run tests selective, e.g.::
  126. $ make test.pep8 test.unit test.sh
  127. TEST test.pep8 OK
  128. ...
  129. TEST test.unit OK
  130. ...
  131. TEST test.sh OK
  132. .. _make test.sh:
  133. ``make test.sh``
  134. ================
  135. :ref:`sh lint` / if you have changed some bash scripting run this test before
  136. commit.
  137. .. _make test.pylint:
  138. ``make test.pylint``
  139. ====================
  140. .. _Pylint: https://www.pylint.org/
  141. Pylint_ is known as one of the best source-code, bug and quality checker for the
  142. Python programming language. The pylint profile used in the SearXNG project is
  143. found in project's root folder :origin:`.pylintrc`.
  144. .. _make search.checker:
  145. ``search.checker.{engine name}``
  146. ================================
  147. To check all engines::
  148. make search.checker
  149. To check a engine with whitespace in the name like *google news* replace space
  150. by underline::
  151. make search.checker.google_news
  152. To see HTTP requests and more use SEARXNG_DEBUG::
  153. make SEARXNG_DEBUG=1 search.checker.google_news
  154. .. _3xx: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection
  155. To filter out HTTP redirects (3xx_)::
  156. make SEARXNG_DEBUG=1 search.checker.google_news | grep -A1 "HTTP/1.1\" 3[0-9][0-9]"
  157. ...
  158. Engine google news Checking
  159. 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
  160. 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
  161. --
  162. 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
  163. 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
  164. --
  165. ``make pybuild``
  166. ================
  167. .. _PyPi: https://pypi.org/
  168. .. _twine: https://twine.readthedocs.io/en/latest/
  169. Build Python packages in ``./dist/py``::
  170. $ make pybuild
  171. ...
  172. BUILD pybuild
  173. running sdist
  174. running egg_info
  175. ...
  176. running bdist_wheel
  177. $ ls ./dist
  178. searx-0.18.0-py3-none-any.whl searx-0.18.0.tar.gz
  179. To upload packages to PyPi_, there is also a ``pypi.upload`` target (to test use
  180. ``pypi.upload.test``). Since you are not the owner of :pypi:`searx` you will
  181. never need to upload.