development.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. Building a development environment
  17. ----------------------------------
  18. First, just install borg into a virtual env as described before.
  19. To install some additional packages needed for running the tests, activate your
  20. virtual env and run::
  21. pip install -r requirements.d/development.txt
  22. Running the tests
  23. -----------------
  24. The tests are in the borg/testsuite package.
  25. To run all the tests, you need to have fakeroot installed. If you do not have
  26. fakeroot, you still will be able to run most tests, just leave away the
  27. `fakeroot -u` from the given command lines.
  28. To run the test suite use the following command::
  29. fakeroot -u tox # run all tests
  30. Some more advanced examples::
  31. # verify a changed tox.ini (run this after any change to tox.ini):
  32. fakeroot -u tox --recreate
  33. fakeroot -u tox -e py32 # run all tests, but only on python 3.2
  34. fakeroot -u tox borg.testsuite.locking # only run 1 test module
  35. fakeroot -u tox borg.testsuite.locking -- -k '"not Timer"' # exclude some tests
  36. fakeroot -u tox borg.testsuite -- -v # verbose py.test
  37. Important notes:
  38. - When using -- to give options to py.test, you MUST also give borg.testsuite[.module].
  39. Building the docs with Sphinx
  40. -----------------------------
  41. The documentation (in reStructuredText format, .rst) is in docs/.
  42. To build the html version of it, you need to have sphinx installed::
  43. pip3 install sphinx # important: this will install sphinx with Python 3
  44. Now run::
  45. cd docs/
  46. make html
  47. Then point a web browser at docs/_build/html/index.html.
  48. The website is updated automatically through Github web hooks on the
  49. main repository.
  50. Using Vagrant
  51. -------------
  52. We use Vagrant for the automated creation of testing environment and borgbackup
  53. standalone binaries for various platforms.
  54. For better security, there is no automatic sync in the VM to host direction.
  55. The plugin `vagrant-scp` is useful to copy stuff from the VMs to the host.
  56. Usage::
  57. To create and provision the VM:
  58. vagrant up OS
  59. To create an ssh session to the VM:
  60. vagrant ssh OS command
  61. To shut down the VM:
  62. vagrant halt OS
  63. To shut down and destroy the VM:
  64. vagrant destroy OS
  65. To copy files from the VM (in this case, the generated binary):
  66. vagrant scp OS:/vagrant/borg/borg/dist/borg .
  67. Creating standalone binaries
  68. ----------------------------
  69. Make sure you have everything built and installed (including llfuse and fuse).
  70. When using the Vagrant VMs, pyinstaller will already be installed.
  71. With virtual env activated::
  72. pip install pyinstaller>=3.0 # or git checkout master
  73. pyinstaller -F -n borg-PLATFORM --hidden-import=logging.config borg/__main__.py
  74. for file in dist/borg-*; do gpg --armor --detach-sign $file; done
  75. If you encounter issues, see also our `Vagrantfile` for details.
  76. .. note:: Standalone binaries built with pyinstaller are supposed to
  77. work on same OS, same architecture (x86 32bit, amd64 64bit)
  78. without external dependencies.
  79. Creating a new release
  80. ----------------------
  81. Checklist:
  82. - make sure all issues for this milestone are closed or moved to the
  83. next milestone
  84. - find and fix any low hanging fruit left on the issue tracker
  85. - run tox on all supported platforms via vagrant, check for test failures
  86. - check that Travis CI is also happy
  87. - update ``CHANGES.rst``, based on ``git log $PREVIOUS_RELEASE..``
  88. - check version number of upcoming release in ``CHANGES.rst``
  89. - verify that ``MANIFEST.in`` and ``setup.py`` are complete
  90. - tag the release::
  91. git tag -s -m "tagged/signed release X.Y.Z" X.Y.Z
  92. - build fresh docs and update the web site with them
  93. - create a release on PyPi::
  94. python setup.py register sdist upload --identity="Thomas Waldmann" --sign
  95. - close release milestone on Github
  96. - announce on:
  97. - `mailing list <mailto:borgbackup@librelist.org>`_
  98. - Twitter (follow @ThomasJWaldmann for these tweets)
  99. - `IRC channel <irc://irc.freenode.net/borgbackup>`_ (change ``/topic``)
  100. - create a Github release, include:
  101. * standalone binaries (see above for how to create them)
  102. * a link to ``CHANGES.rst``