makefile.rst 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. .. _makefile:
  2. ================
  3. Makefile Targets
  4. ================
  5. .. sidebar:: build environment
  6. Before looking deeper at the targets, first read about :ref:`makefile setup`
  7. and :ref:`make pyenv`.
  8. With the aim to simplify development cycles, started with :pull:`1756` a
  9. ``Makefile`` based boilerplate was added.
  10. The usage is simple, just type ``make {target-name}`` to *build* a target.
  11. Calling the ``help`` target gives a first overview::
  12. $ make help
  13. test - run developer tests
  14. docs - build documentation
  15. docs-live - autobuild HTML documentation while editing
  16. run - run developer instance
  17. install - developer install (./local)
  18. uninstall - uninstall (./local)
  19. gh-pages - build docs & deploy on gh-pages branch
  20. clean - drop builds and environments
  21. ...
  22. .. contents:: Contents
  23. :depth: 2
  24. :local:
  25. :backlinks: entry
  26. .. _makefile setup:
  27. Setup
  28. =====
  29. .. _git stash: https://git-scm.com/docs/git-stash
  30. The main setup is done in the :origin:`Makefile`::
  31. export GIT_URL=https://github.com/asciimoo/searx
  32. export SEARX_URL=https://searx.me
  33. export DOCS_URL=https://asciimoo.github.io/searx
  34. .. sidebar:: fork & upstream
  35. Commit changes in your (local) branch, fork or whatever, but do not push them
  36. upstream / `git stash`_ is your friend.
  37. :GIT_URL: Changes this, to point to your searx fork.
  38. :SEARX_URL: Changes this, to point to your searx instance.
  39. :DOCS_URL: If you host your own (branded) documentation, change this URL.
  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 virualenv 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 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 ``./searx/webapp.py``
  76. instance, disables *debug* option and opens the site (xdg-open):
  77. .. code:: sh
  78. $ make run
  79. PYENV usage: source ./local/py3/bin/activate
  80. PYENV install .
  81. ./local/py3/bin/python ./searx/webapp.py
  82. ...
  83. INFO:werkzeug: * Running on http://127.0.0.1:8888/ (Press CTRL+C to quit)
  84. ...
  85. .. _make clean:
  86. ``make clean``
  87. ==============
  88. Drop all intermediate files, all builds, but keep sources untouched. Includes
  89. target ``pyclean`` which drops ./local environment. Before calling ``make
  90. clean`` stop all processes using :ref:`make pyenv`.
  91. .. code:: sh
  92. $ make clean
  93. CLEAN pyclean
  94. CLEAN clean
  95. .. _make docs:
  96. ``make docs docs-live docs-clean``
  97. ==================================
  98. We describe the usage of the ``doc*`` targets in the :ref:`How to contribute /
  99. Documentation <contrib docs>` section. If you want to edit the documentation
  100. read our :ref:`make docs-live` section. If you are working in your own brand,
  101. adjust your :ref:`Makefile setup <makefile setup>`.
  102. .. _make gh-pages:
  103. ``make gh-pages``
  104. =================
  105. To deploy on github.io first adjust your :ref:`Makefile setup <makefile
  106. setup>`. For any further read :ref:`deploy on github.io`.
  107. .. _make test:
  108. ``make test``
  109. =============
  110. Runs a series of tests: ``test.pep8``, ``test.unit``, ``test.robot`` and does
  111. additional :ref:`pylint checks <make pylint>`. You can run tests selective,
  112. e.g.:
  113. .. code:: sh
  114. $ make test.pep8 test.unit
  115. . ./local/py3/bin/activate; ./manage.sh pep8_check
  116. [!] Running pep8 check
  117. . ./local/py3/bin/activate; ./manage.sh unit_tests
  118. [!] Running unit tests
  119. .. _make pylint:
  120. ``make pylint``
  121. ===============
  122. .. _Pylint: https://www.pylint.org/
  123. Before commiting its recommend to do some (more) linting. Pylint_ is known as
  124. one of the best source-code, bug and quality checker for the Python programming
  125. language. Pylint_ is not yet a quality gate within our searx project (like
  126. :ref:`test.pep8 <make test>` it is), but Pylint_ can help to improve code
  127. quality anyway. The pylint profile we use at searx project is found in
  128. project's root folder :origin:`.pylintrc`.
  129. Code quality is a ongoing process. Don't try to fix all messages from Pylint,
  130. run Pylint and check if your changed lines are bringing up new messages. If so,
  131. fix it. By this, code quality gets incremental better and if there comes the
  132. day, the linting is balanced out, we might decide to add Pylint as a quality
  133. gate.
  134. ``make pybuild``
  135. ================
  136. .. _PyPi: https://pypi.org/
  137. .. _twine: https://twine.readthedocs.io/en/latest/
  138. Build Python packages in ``./dist/py``.
  139. .. code:: sh
  140. $ make pybuild
  141. ...
  142. BUILD pybuild
  143. running sdist
  144. running egg_info
  145. ...
  146. $ ls ./dist/py/
  147. searx-0.15.0-py3-none-any.whl searx-0.15.0.tar.gz
  148. To upload packages to PyPi_, there is also a ``upload-pypi`` target. It needs
  149. twine_ to be installed. Since you are not the owner of :pypi:`searx` you will
  150. never need the latter.