makefile.rst 6.4 KB

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