development.rst 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. 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 emitted at info level, use
  24. flags like ``--stats`` or ``--list``, then create a topic logger for messages
  25. controlled by that flag. See ``_setup_implied_logging()`` in
  26. ``borg/archiver.py`` for the entry point to topic logging.
  27. Building a development environment
  28. ----------------------------------
  29. First, just install borg into a virtual env as described before.
  30. To install some additional packages needed for running the tests, activate your
  31. virtual env and run::
  32. pip install -r requirements.d/development.txt
  33. Running the tests
  34. -----------------
  35. The tests are in the borg/testsuite package.
  36. To run all the tests, you need to have fakeroot installed. If you do not have
  37. fakeroot, you still will be able to run most tests, just leave away the
  38. `fakeroot -u` from the given command lines.
  39. To run the test suite use the following command::
  40. fakeroot -u tox # run all tests
  41. Some more advanced examples::
  42. # verify a changed tox.ini (run this after any change to tox.ini):
  43. fakeroot -u tox --recreate
  44. fakeroot -u tox -e py34 # run all tests, but only on python 3.4
  45. fakeroot -u tox borg.testsuite.locking # only run 1 test module
  46. fakeroot -u tox borg.testsuite.locking -- -k '"not Timer"' # exclude some tests
  47. fakeroot -u tox borg.testsuite -- -v # verbose py.test
  48. Important notes:
  49. - When using ``--`` to give options to py.test, you MUST also give ``borg.testsuite[.module]``.
  50. Regenerate usage files
  51. ----------------------
  52. Usage and API documentation is currently committed directly to git,
  53. although those files are generated automatically from the source
  54. tree.
  55. When a new module is added, the ``docs/api.rst`` file needs to be
  56. regenerated::
  57. ./setup.py build_api
  58. When a command is added, a commandline flag changed, added or removed,
  59. the usage docs need to be rebuilt as well::
  60. ./setup.py build_usage
  61. Building the docs with Sphinx
  62. -----------------------------
  63. The documentation (in reStructuredText format, .rst) is in docs/.
  64. To build the html version of it, you need to have sphinx installed::
  65. pip3 install sphinx # important: this will install sphinx with Python 3
  66. Now run::
  67. cd docs/
  68. make html
  69. Then point a web browser at docs/_build/html/index.html.
  70. The website is updated automatically through Github web hooks on the
  71. main repository.
  72. Using Vagrant
  73. -------------
  74. We use Vagrant for the automated creation of testing environments and borgbackup
  75. standalone binaries for various platforms.
  76. For better security, there is no automatic sync in the VM to host direction.
  77. The plugin `vagrant-scp` is useful to copy stuff from the VMs to the host.
  78. Usage::
  79. # To create and provision the VM:
  80. vagrant up OS
  81. # To create an ssh session to the VM:
  82. vagrant ssh OS
  83. # To execute a command via ssh in the VM:
  84. vagrant ssh OS -c "command args"
  85. # To shut down the VM:
  86. vagrant halt OS
  87. # To shut down and destroy the VM:
  88. vagrant destroy OS
  89. # To copy files from the VM (in this case, the generated binary):
  90. vagrant scp OS:/vagrant/borg/borg.exe .
  91. Creating standalone binaries
  92. ----------------------------
  93. Make sure you have everything built and installed (including llfuse and fuse).
  94. When using the Vagrant VMs, pyinstaller will already be installed.
  95. With virtual env activated::
  96. pip install pyinstaller # or git checkout master
  97. pyinstaller -F -n borg-PLATFORM borg/__main__.py
  98. for file in dist/borg-*; do gpg --armor --detach-sign $file; done
  99. If you encounter issues, see also our `Vagrantfile` for details.
  100. .. note:: Standalone binaries built with pyinstaller are supposed to
  101. work on same OS, same architecture (x86 32bit, amd64 64bit)
  102. without external dependencies.
  103. Creating a new release
  104. ----------------------
  105. Checklist:
  106. - make sure all issues for this milestone are closed or moved to the
  107. next milestone
  108. - find and fix any low hanging fruit left on the issue tracker
  109. - check that Travis CI is happy
  110. - update ``CHANGES.rst``, based on ``git log $PREVIOUS_RELEASE..``
  111. - check version number of upcoming release in ``CHANGES.rst``
  112. - verify that ``MANIFEST.in`` and ``setup.py`` are complete
  113. - ``python setup.py build_api ; python setup.py build_usage`` and commit
  114. - tag the release::
  115. git tag -s -m "tagged/signed release X.Y.Z" X.Y.Z
  116. - run tox and/or binary builds on all supported platforms via vagrant,
  117. check for test failures
  118. - create a release on PyPi::
  119. python setup.py register sdist upload --identity="Thomas Waldmann" --sign
  120. - close release milestone on Github
  121. - announce on:
  122. - Mailing list
  123. - Twitter (follow @ThomasJWaldmann for these tweets)
  124. - IRC channel (change ``/topic``)
  125. - create a Github release, include:
  126. * standalone binaries (see above for how to create them)
  127. + for OS X, document the OS X Fuse version in the README of the binaries.
  128. OS X FUSE uses a kernel extension that needs to be compatible with the
  129. code contained in the binary.
  130. * a link to ``CHANGES.rst``