development.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. .. include:: global.rst.inc
  2. .. highlight:: bash
  3. .. _development:
  4. Development
  5. ===========
  6. This chapter will get you started with |project_name| development.
  7. |project_name| is written in Python (with a little bit of Cython and C for
  8. the performance critical parts).
  9. Style guide
  10. -----------
  11. We generally follow `pep8
  12. <https://www.python.org/dev/peps/pep-0008/>`_, with 120 columns
  13. instead of 79. We do *not* use form-feed (``^L``) characters to
  14. separate sections either. Compliance is tested automatically when
  15. you run the tests.
  16. Continuous Integration
  17. ----------------------
  18. All pull requests go through Travis-CI_, which runs the tests on Linux
  19. and Mac OS X as well as the flake8 style checker. Additional Unix-like platforms
  20. are tested on Golem_.
  21. .. _Golem: https://golem.enkore.de/view/Borg/
  22. .. _Travis-CI: https://travis-ci.org/borgbackup/borg
  23. Output and Logging
  24. ------------------
  25. When writing logger calls, always use correct log level (debug only for
  26. debugging, info for informative messages, warning for warnings, error for
  27. errors, critical for critical errors/states).
  28. When directly talking to the user (e.g. Y/N questions), do not use logging,
  29. but directly output to stderr (not: stdout, it could be connected to a pipe).
  30. To control the amount and kinds of messages output to stderr or emitted at
  31. info level, use flags like ``--stats`` or ``--list``.
  32. Building a development environment
  33. ----------------------------------
  34. First, just install borg into a virtual env as described before.
  35. To install some additional packages needed for running the tests, activate your
  36. virtual env and run::
  37. pip install -r requirements.d/development.txt
  38. Running the tests
  39. -----------------
  40. The tests are in the borg/testsuite package.
  41. To run all the tests, you need to have fakeroot installed. If you do not have
  42. fakeroot, you still will be able to run most tests, just leave away the
  43. `fakeroot -u` from the given command lines.
  44. To run the test suite use the following command::
  45. fakeroot -u tox # run all tests
  46. Some more advanced examples::
  47. # verify a changed tox.ini (run this after any change to tox.ini):
  48. fakeroot -u tox --recreate
  49. fakeroot -u tox -e py34 # run all tests, but only on python 3.4
  50. fakeroot -u tox borg.testsuite.locking # only run 1 test module
  51. fakeroot -u tox borg.testsuite.locking -- -k '"not Timer"' # exclude some tests
  52. fakeroot -u tox borg.testsuite -- -v # verbose py.test
  53. Important notes:
  54. - When using ``--`` to give options to py.test, you MUST also give ``borg.testsuite[.module]``.
  55. Regenerate usage files
  56. ----------------------
  57. Usage and API documentation is currently committed directly to git,
  58. although those files are generated automatically from the source
  59. tree.
  60. When a new module is added, the ``docs/api.rst`` file needs to be
  61. regenerated::
  62. ./setup.py build_api
  63. When a command is added, a commandline flag changed, added or removed,
  64. the usage docs need to be rebuilt as well::
  65. ./setup.py build_usage
  66. Building the docs with Sphinx
  67. -----------------------------
  68. The documentation (in reStructuredText format, .rst) is in docs/.
  69. To build the html version of it, you need to have sphinx installed::
  70. pip3 install sphinx # important: this will install sphinx with Python 3
  71. Now run::
  72. cd docs/
  73. make html
  74. Then point a web browser at docs/_build/html/index.html.
  75. The website is updated automatically through Github web hooks on the
  76. main repository.
  77. Using Vagrant
  78. -------------
  79. We use Vagrant for the automated creation of testing environments and borgbackup
  80. standalone binaries for various platforms.
  81. For better security, there is no automatic sync in the VM to host direction.
  82. The plugin `vagrant-scp` is useful to copy stuff from the VMs to the host.
  83. Usage::
  84. # To create and provision the VM:
  85. vagrant up OS
  86. # To create an ssh session to the VM:
  87. vagrant ssh OS command
  88. # To shut down the VM:
  89. vagrant halt OS
  90. # To shut down and destroy the VM:
  91. vagrant destroy OS
  92. # To copy files from the VM (in this case, the generated binary):
  93. vagrant scp OS:/vagrant/borg/borg.exe .
  94. Creating standalone binaries
  95. ----------------------------
  96. Make sure you have everything built and installed (including llfuse and fuse).
  97. When using the Vagrant VMs, pyinstaller will already be installed.
  98. With virtual env activated::
  99. pip install pyinstaller # or git checkout master
  100. pyinstaller -F -n borg-PLATFORM borg/__main__.py
  101. for file in dist/borg-*; do gpg --armor --detach-sign $file; done
  102. If you encounter issues, see also our `Vagrantfile` for details.
  103. .. note:: Standalone binaries built with pyinstaller are supposed to
  104. work on same OS, same architecture (x86 32bit, amd64 64bit)
  105. without external dependencies.
  106. Creating a new release
  107. ----------------------
  108. Checklist:
  109. - make sure all issues for this milestone are closed or moved to the
  110. next milestone
  111. - find and fix any low hanging fruit left on the issue tracker
  112. - check that Travis CI is happy
  113. - update ``CHANGES.rst``, based on ``git log $PREVIOUS_RELEASE..``
  114. - check version number of upcoming release in ``CHANGES.rst``
  115. - verify that ``MANIFEST.in`` and ``setup.py`` are complete
  116. - ``python setup.py build_api ; python setup.py build_usage`` and commit
  117. - tag the release::
  118. git tag -s -m "tagged/signed release X.Y.Z" X.Y.Z
  119. - run tox and/or binary builds on all supported platforms via vagrant,
  120. check for test failures
  121. - create a release on PyPi::
  122. python setup.py register sdist upload --identity="Thomas Waldmann" --sign
  123. - close release milestone on Github
  124. - announce on:
  125. - Mailing list
  126. - Twitter (follow @ThomasJWaldmann for these tweets)
  127. - IRC channel (change ``/topic``)
  128. - create a Github release, include:
  129. * standalone binaries (see above for how to create them)
  130. + for OS X, document the OS X Fuse version in the README of the binaries.
  131. OS X FUSE uses a kernel extension that needs to be compatible with the
  132. code contained in the binary.
  133. * a link to ``CHANGES.rst``