2
0

development.rst 6.8 KB

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