development.rst 5.6 KB

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