makefile.rst 6.2 KB

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