makefile.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 searx (: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. - ``GIT_URL`` from :ref:`brand.git_url <settings global brand>`
  82. - ``GIT_BRANCH`` from :ref:`brand.git_branch <settings global brand>`
  83. - ``SEARX_URL`` from :ref:`server.base_url <settings global server>` (aka
  84. ``PUBLIC_URL``)
  85. - ``SEARX_BIND_ADDRESS`` from :ref:`server.bind_address <settings global server>`
  86. - ``SEARX_PORT`` from :ref:`server.port <settings global server>`
  87. .. _make run:
  88. ``make run``
  89. ============
  90. To get up a running a developer instance simply call ``make run``. This enables
  91. *debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
  92. instance, disables *debug* option again and opens the URL in your favorite WEB
  93. browser (:man:`xdg-open`)::
  94. $ make run
  95. PYENV OK
  96. SEARX_DEBUG=1 ./manage.sh pyenv.cmd python ./searx/webapp.py
  97. ...
  98. INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
  99. .. _make clean:
  100. ``make clean``
  101. ==============
  102. Drop all intermediate files, all builds, but keep sources untouched. Before
  103. calling ``make clean`` stop all processes using :ref:`make install`. ::
  104. $ make clean
  105. CLEAN pyenv
  106. PYENV [virtualenv] drop ./local/py3
  107. CLEAN docs -- ./build/docs ./dist/docs
  108. CLEAN locally installed npm dependencies
  109. CLEAN test stuff
  110. CLEAN common files
  111. .. _make docs:
  112. ``make docs docs.autobuild docs.clean``
  113. =======================================
  114. We describe the usage of the ``doc.*`` targets in the :ref:`How to contribute /
  115. Documentation <contrib docs>` section. If you want to edit the documentation
  116. read our :ref:`make docs.live` section. If you are working in your own brand,
  117. adjust your :ref:`settings global`.
  118. .. _make docs.gh-pages:
  119. ``make docs.gh-pages``
  120. ======================
  121. To deploy on github.io first adjust your :ref:`settings global`. For any
  122. further read :ref:`deploy on github.io`.
  123. .. _make test:
  124. ``make test``
  125. =============
  126. Runs a series of tests: :ref:`make test.pylint`, ``test.pep8``, ``test.unit``
  127. and ``test.robot``. You can run tests selective, e.g.::
  128. $ make test.pep8 test.unit test.sh
  129. TEST test.pep8 OK
  130. ...
  131. TEST test.unit OK
  132. ...
  133. TEST test.sh OK
  134. .. _make test.sh:
  135. ``make test.sh``
  136. ================
  137. :ref:`sh lint` / if you have changed some bash scripting run this test before
  138. commit.
  139. .. _make test.pylint:
  140. ``make test.pylint``
  141. ====================
  142. .. _Pylint: https://www.pylint.org/
  143. Pylint_ is known as one of the best source-code, bug and quality checker for the
  144. Python programming language. The pylint profile we use at searx project is
  145. found in project's root folder :origin:`.pylintrc`.
  146. .. _make search.checker:
  147. ``search.checker.{engine name}``
  148. ================================
  149. To check all engines::
  150. make search.checker
  151. To check a engine with whitespace in the name like *google news* replace space
  152. by underline::
  153. make search.checker.google_news
  154. To see HTTP requests and more use SEARX_DEBUG::
  155. make SEARX_DEBUG=1 search.checker.google_news
  156. .. _3xx: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection
  157. To filter out HTTP redirects (3xx_)::
  158. make SEARX_DEBUG=1 search.checker.google_news | grep -A1 "HTTP/1.1\" 3[0-9][0-9]"
  159. ...
  160. Engine google news Checking
  161. 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
  162. 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
  163. --
  164. 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
  165. 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
  166. --
  167. ``make pybuild``
  168. ================
  169. .. _PyPi: https://pypi.org/
  170. .. _twine: https://twine.readthedocs.io/en/latest/
  171. Build Python packages in ``./dist/py``::
  172. $ make pybuild
  173. ...
  174. BUILD pybuild
  175. running sdist
  176. running egg_info
  177. ...
  178. running bdist_wheel
  179. $ ls ./dist
  180. searx-0.18.0-py3-none-any.whl searx-0.18.0.tar.gz
  181. To upload packages to PyPi_, there is also a ``pypi.upload`` target (to test use
  182. ``pypi.upload.test``). Since you are not the owner of :pypi:`searx` you will
  183. never need to upload.