makefile.rst 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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::
  15. $ make help
  16. test - run developer tests
  17. docs - build documentation
  18. docs-live - autobuild HTML documentation while editing
  19. run - run developer instance
  20. install - developer install (./local)
  21. uninstall - uninstall (./local)
  22. gh-pages - build docs & deploy on gh-pages branch
  23. clean - drop builds and environments
  24. ...
  25. .. contents:: Contents
  26. :depth: 2
  27. :local:
  28. :backlinks: entry
  29. .. _makefile setup:
  30. Makefile setup
  31. ==============
  32. .. _git stash: https://git-scm.com/docs/git-stash
  33. The main setup is done in the :origin:`Makefile`::
  34. export GIT_URL=https://github.com/asciimoo/searx
  35. export GIT_BRANCH=master
  36. export SEARX_URL=https://searx.me
  37. export DOCS_URL=https://asciimoo.github.io/searx
  38. .. sidebar:: fork & upstream
  39. Commit changes in your (local) branch, fork or whatever, but do not push them
  40. upstream / `git stash`_ is your friend.
  41. :GIT_URL: Changes this, to point to your searx fork.
  42. :GIT_BRANCH: Changes this, to point to your searx branch.
  43. :SEARX_URL: Changes this, to point to your searx instance.
  44. :DOCS_URL: If you host your own (branded) documentation, change this URL.
  45. .. _make pyenv:
  46. Python environment
  47. ==================
  48. .. sidebar:: activate environment
  49. ``source ./local/py3/bin/activate``
  50. With Makefile we do no longer need to build up the virualenv manually (as
  51. described in the :ref:`devquickstart` guide). Jump into your git working tree
  52. and release a ``make pyenv``:
  53. .. code:: sh
  54. $ cd ~/searx-clone
  55. $ make pyenv
  56. PYENV usage: source ./local/py3/bin/activate
  57. ...
  58. With target ``pyenv`` a development environment (aka virtualenv) was build up in
  59. ``./local/py3/``. To make a *developer install* of searx (:origin:`setup.py`)
  60. into this environment, use make target ``install``:
  61. .. code:: sh
  62. $ make install
  63. PYENV usage: source ./local/py3/bin/activate
  64. PYENV using virtualenv from ./local/py3
  65. PYENV install .
  66. You have never to think about intermediate targets like ``pyenv`` or
  67. ``install``, the ``Makefile`` chains them as requisites. Just run your main
  68. target.
  69. .. sidebar:: drop environment
  70. To get rid of the existing environment before re-build use :ref:`clean target
  71. <make clean>` first.
  72. If you think, something goes wrong with your ./local environment or you change
  73. the :origin:`setup.py` file (or the requirements listed in
  74. :origin:`requirements-dev.txt` and :origin:`requirements.txt`), you have to call
  75. :ref:`make clean`.
  76. .. _make run:
  77. ``make run``
  78. ============
  79. To get up a running a developer instance simply call ``make run``. This enables
  80. *debug* option in :origin:`searx/settings.yml`, starts a ``./searx/webapp.py``
  81. instance, disables *debug* option again and opens the URL in your favorite WEB
  82. browser (:man:`xdg-open`):
  83. .. code:: sh
  84. $ make run
  85. PYENV usage: source ./local/py3/bin/activate
  86. PYENV install .
  87. ./local/py3/bin/python ./searx/webapp.py
  88. ...
  89. INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
  90. ...
  91. .. _make clean:
  92. ``make clean``
  93. ==============
  94. Drop all intermediate files, all builds, but keep sources untouched. Includes
  95. target ``pyclean`` which drops ./local environment. Before calling ``make
  96. clean`` stop all processes using :ref:`make pyenv`.
  97. .. code:: sh
  98. $ make clean
  99. CLEAN pyclean
  100. CLEAN clean
  101. .. _make docs:
  102. ``make docs docs-live docs-clean``
  103. ==================================
  104. We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
  105. Documentation <contrib docs>` section. If you want to edit the documentation
  106. read our :ref:`make docs-live` section. If you are working in your own brand,
  107. adjust your :ref:`Makefile setup <makefile setup>`.
  108. .. _make gh-pages:
  109. ``make gh-pages``
  110. =================
  111. To deploy on github.io first adjust your :ref:`Makefile setup <makefile
  112. setup>`. For any further read :ref:`deploy on github.io`.
  113. .. _make test:
  114. ``make test``
  115. =============
  116. Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
  117. additional :ref:`pylint checks <make pylint>`. You can run tests selective,
  118. e.g.:
  119. .. code:: sh
  120. $ make test.pep8 test.unit test.sh
  121. . ./local/py3/bin/activate; ./manage.sh pep8_check
  122. [!] Running pep8 check
  123. . ./local/py3/bin/activate; ./manage.sh unit_tests
  124. [!] Running unit tests
  125. .. _make pylint:
  126. ``make pylint``
  127. ===============
  128. .. _Pylint: https://www.pylint.org/
  129. Before commiting its recommend to do some (more) linting. Pylint_ is known as
  130. one of the best source-code, bug and quality checker for the Python programming
  131. language. Pylint_ is not yet a quality gate within our searx project (like
  132. :ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve code
  133. quality anyway. The pylint profile we use at searx project is found in
  134. project's root folder :origin:`.pylintrc`.
  135. Code quality is a ongoing process. Don't try to fix all messages from Pylint,
  136. run Pylint and check if your changed lines are bringing up new messages. If so,
  137. fix it. By this, code quality gets incremental better and if there comes the
  138. day, the linting is balanced out, we might decide to add Pylint as a quality
  139. gate.
  140. ``make pybuild``
  141. ================
  142. .. _PyPi: https://pypi.org/
  143. .. _twine: https://twine.readthedocs.io/en/latest/
  144. Build Python packages in ``./dist/py``.
  145. .. code:: sh
  146. $ make pybuild
  147. ...
  148. BUILD pybuild
  149. running sdist
  150. running egg_info
  151. ...
  152. $ ls ./dist/py/
  153. searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
  154. To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
  155. twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
  156. never need the latter.