makefile.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. .. _makefile:
  2. ================
  3. Makefile Targets
  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:`makefile setup`
  8. and :ref:`make pyenv`.
  9. To install system requirements follow :ref:`buildhosts`.
  10. With the aim to simplify development cycles, started with :pull:`1756` a
  11. ``Makefile`` based boilerplate was added. If you are not familiar with
  12. 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. .. _makefile setup:
  21. Makefile setup
  22. ==============
  23. .. _git stash: https://git-scm.com/docs/git-stash
  24. .. sidebar:: fork & upstream
  25. Commit changes in your (local) branch, fork or whatever, but do not push them
  26. upstream / `git stash`_ is your friend.
  27. The main setup is done in the :origin:`Makefile`.
  28. .. literalinclude:: ../../Makefile
  29. :start-after: START Makefile setup
  30. :end-before: END Makefile setup
  31. :GIT_URL: Changes this, to point to your searx fork.
  32. :GIT_BRANCH: Changes this, to point to your searx branch.
  33. :SEARX_URL: Changes this, to point to your searx instance.
  34. :DOCS_URL: If you host your own (*brand*) documentation, change this URL.
  35. If you change any of this build environment variables, you have to run ``make
  36. buildenv``::
  37. $ make buildenv
  38. build searx/brand.py
  39. build utils/brand.env
  40. .. _make pyenv:
  41. Python environment
  42. ==================
  43. .. sidebar:: activate environment
  44. ``source ./local/py3/bin/activate``
  45. With Makefile we do no longer need to build up the virtualenv manually (as
  46. described in the :ref:`devquickstart` guide). Jump into your git working tree
  47. and release a ``make pyenv``:
  48. .. code:: sh
  49. $ cd ~/searx-clone
  50. $ make pyenv
  51. PYENV usage: source ./local/py3/bin/activate
  52. ...
  53. With target ``pyenv`` a development environment (aka virtualenv) was build up in
  54. ``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`)
  55. into this environment, use make target ``install``:
  56. .. code:: sh
  57. $ make install
  58. PYENV usage: source ./local/py3/bin/activate
  59. PYENV using virtualenv from ./local/py3
  60. PYENV install .
  61. You have never to think about intermediate targets like ``pyenv`` or
  62. ``install``, the ``Makefile`` chains them as requisites. Just run your main
  63. target.
  64. .. sidebar:: drop environment
  65. To get rid of the existing environment before re-build use :ref:`clean target
  66. <make clean>` first.
  67. If you think, something goes wrong with your ./local environment or you change
  68. the :origin:`setup.py` file (or the requirements listed in
  69. :origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call
  70. :ref:`make clean`.
  71. .. _make run:
  72. ``make run``
  73. ============
  74. To get up a running a developer instance simply call ``make run``. This enables
  75. *debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
  76. instance, disables *debug* option again and opens the URL in your favorite WEB
  77. browser (:man:`xdg-open`):
  78. .. code:: sh
  79. $ make run
  80. PYENV usage: source ./local/py3/bin/activate
  81. PYENV install .
  82. ./local/py3/bin/python ./searx/webapp.py
  83. ...
  84. INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
  85. ...
  86. .. _make clean:
  87. ``make clean``
  88. ==============
  89. Drop all intermediate files, all builds, but keep sources untouched. Includes
  90. target ``pyclean`` which drops ./local environment. Before calling ``make
  91. clean`` stop all processes using :ref:`make pyenv`.
  92. .. code:: sh
  93. $ make clean
  94. CLEAN pyclean
  95. CLEAN clean
  96. .. _make docs:
  97. ``make docs docs-live docs-clean``
  98. ==================================
  99. We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
  100. Documentation <contrib docs>` section. If you want to edit the documentation
  101. read our :ref:`make docs-live` section. If you are working in your own brand,
  102. adjust your :ref:`Makefile setup <makefile setup>`.
  103. .. _make books:
  104. ``make books/{name}.html books/{name}.pdf``
  105. ===========================================
  106. .. _intersphinx: https://www.sphinx-doc.org/en/stable/ext/intersphinx.html
  107. .. _XeTeX: https://tug.org/xetex/
  108. .. sidebar:: info
  109. To build PDF a XeTeX_ is needed, see :ref:`buildhosts`.
  110. The ``books/{name}.*`` targets are building *books*. A *book* is a
  111. sub-directory containing a ``conf.py`` file. One example is the user handbook
  112. which can deployed separately (:origin:`docs/user/conf.py`). Such ``conf.py``
  113. do inherit from :origin:`docs/conf.py` and overwrite values to fit *book's*
  114. needs.
  115. With the help of Intersphinx_ (:ref:`reST smart ref`) the links to searx’s
  116. documentation outside of the book will be bound by the object inventory of
  117. ``DOCS_URL``. Take into account that URLs will be picked from the inventary at
  118. documentation's build time.
  119. Use ``make docs-help`` to see which books available:
  120. .. program-output:: bash -c "cd ..; make --no-print-directory docs-help"
  121. :ellipsis: 0,-6
  122. .. _make gh-pages:
  123. ``make gh-pages``
  124. =================
  125. To deploy on github.io first adjust your :ref:`Makefile setup <makefile
  126. setup>`. For any further read :ref:`deploy on github.io`.
  127. .. _make test:
  128. ``make test``
  129. =============
  130. Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
  131. additional :ref:`pylint checks <make pylint>`. You can run tests selective,
  132. e.g.:
  133. .. code:: sh
  134. $ make test.pep8 test.unit test.sh
  135. . ./local/py3/bin/activate; ./manage.sh pep8_check
  136. [!] Running pep8 check
  137. . ./local/py3/bin/activate; ./manage.sh unit_tests
  138. [!] Running unit tests
  139. .. _make pylint:
  140. ``make pylint``
  141. ===============
  142. .. _Pylint: https://www.pylint.org/
  143. Before commiting its recommend to do some (more) linting. Pylint_ is known as
  144. one of the best source-code, bug and quality checker for the Python programming
  145. language. Pylint_ is not yet a quality gate within our searx project (like
  146. :ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve code
  147. quality anyway. The pylint profile we use at searx project is found in
  148. project's root folder :origin:`.pylintrc`.
  149. Code quality is a ongoing process. Don't try to fix all messages from Pylint,
  150. run Pylint and check if your changed lines are bringing up new messages. If so,
  151. fix it. By this, code quality gets incremental better and if there comes the
  152. day, the linting is balanced out, we might decide to add Pylint as a quality
  153. gate.
  154. ``make pybuild``
  155. ================
  156. .. _PyPi: https://pypi.org/
  157. .. _twine: https://twine.readthedocs.io/en/latest/
  158. Build Python packages in ``./dist/py``.
  159. .. code:: sh
  160. $ make pybuild
  161. ...
  162. BUILD pybuild
  163. running sdist
  164. running egg_info
  165. ...
  166. $ ls ./dist/py/
  167. searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
  168. To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
  169. twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
  170. never need the latter.