2015-08-06 10:59:51 +00:00
|
|
|
.. include:: global.rst.inc
|
2016-07-11 21:16:53 +00:00
|
|
|
.. highlight:: bash
|
2015-08-06 10:59:51 +00:00
|
|
|
.. _development:
|
|
|
|
|
|
|
|
Development
|
|
|
|
===========
|
|
|
|
|
2016-01-12 22:49:19 +00:00
|
|
|
This chapter will get you started with |project_name| development.
|
2015-08-06 10:59:51 +00:00
|
|
|
|
|
|
|
|project_name| is written in Python (with a little bit of Cython and C for
|
|
|
|
the performance critical parts).
|
|
|
|
|
2016-08-02 14:21:35 +00:00
|
|
|
Code and issues
|
|
|
|
---------------
|
|
|
|
|
|
|
|
Code is stored on Github, in the `Borgbackup organization
|
|
|
|
<https://github.com/borgbackup/borg/>`_. `Issues
|
|
|
|
<https://github.com/borgbackup/borg/issues>`_ and `pull requests
|
|
|
|
<https://github.com/borgbackup/borg/pulls>`_ should be sent there as
|
|
|
|
well. See also the :ref:`support` section for more details.
|
|
|
|
|
2015-10-20 18:40:09 +00:00
|
|
|
Style guide
|
|
|
|
-----------
|
|
|
|
|
|
|
|
We generally follow `pep8
|
|
|
|
<https://www.python.org/dev/peps/pep-0008/>`_, with 120 columns
|
|
|
|
instead of 79. We do *not* use form-feed (``^L``) characters to
|
2016-02-01 02:22:02 +00:00
|
|
|
separate sections either. Compliance is tested automatically when
|
|
|
|
you run the tests.
|
2015-08-06 10:59:51 +00:00
|
|
|
|
2016-07-27 21:54:15 +00:00
|
|
|
Continuous Integration
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
All pull requests go through Travis-CI_, which runs the tests on Linux
|
2016-07-29 22:01:19 +00:00
|
|
|
and Mac OS X as well as the flake8 style checker. Windows builds run on AppVeyor_,
|
|
|
|
while additional Unix-like platforms are tested on Golem_.
|
2016-07-27 21:54:15 +00:00
|
|
|
|
2016-07-29 22:01:19 +00:00
|
|
|
.. _AppVeyor: https://ci.appveyor.com/project/borgbackup/borg/
|
2016-07-27 21:54:15 +00:00
|
|
|
.. _Golem: https://golem.enkore.de/view/Borg/
|
|
|
|
.. _Travis-CI: https://travis-ci.org/borgbackup/borg
|
|
|
|
|
2015-12-08 00:45:22 +00:00
|
|
|
Output and Logging
|
|
|
|
------------------
|
|
|
|
When writing logger calls, always use correct log level (debug only for
|
|
|
|
debugging, info for informative messages, warning for warnings, error for
|
|
|
|
errors, critical for critical errors/states).
|
|
|
|
|
|
|
|
When directly talking to the user (e.g. Y/N questions), do not use logging,
|
|
|
|
but directly output to stderr (not: stdout, it could be connected to a pipe).
|
|
|
|
|
Print implied output without --info/-v
There are persistent questions why output from options like --list
and --stats doesn't show up. Also, borg currently isn't able to
show *just* the output for a given option (--list, --stats,
--show-rc, --show-version, or --progress), without other INFO level
messages.
The solution is to use more granular loggers, so that messages
specific to a given option goes to a logger designated for that
option. That option-specific logger can then be configured
separately from the regular loggers.
Those option-specific loggers can also be used as a hook in a
BORG_LOGGING_CONF config file to log the --list output to a separate
file, or send --stats output to a network socket where some daemon
could analyze it.
Steps:
- create an option-specific logger for each of the implied output options
- modify the messages specific to each option to go to the correct logger
- if an implied output option is passed, change the option-specific
logger (only) to log at INFO level
- test that root logger messages don't come through option-specific loggers
They shouldn't, per https://docs.python.org/3/howto/logging.html#logging-flow
but test just the same. Particularly test a message that can come from
remote repositories.
Fixes #526, #573, #665, #824
2016-05-18 02:59:58 +00:00
|
|
|
To control the amount and kinds of messages output emitted at info level, use
|
|
|
|
flags like ``--stats`` or ``--list``, then create a topic logger for messages
|
|
|
|
controlled by that flag. See ``_setup_implied_logging()`` in
|
|
|
|
``borg/archiver.py`` for the entry point to topic logging.
|
2015-12-08 00:45:22 +00:00
|
|
|
|
2015-08-06 10:59:51 +00:00
|
|
|
Building a development environment
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
|
First, just install borg into a virtual env as described before.
|
|
|
|
|
|
|
|
To install some additional packages needed for running the tests, activate your
|
|
|
|
virtual env and run::
|
|
|
|
|
|
|
|
pip install -r requirements.d/development.txt
|
|
|
|
|
|
|
|
|
|
|
|
Running the tests
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
The tests are in the borg/testsuite package.
|
|
|
|
|
2015-08-20 21:39:40 +00:00
|
|
|
To run all the tests, you need to have fakeroot installed. If you do not have
|
|
|
|
fakeroot, you still will be able to run most tests, just leave away the
|
|
|
|
`fakeroot -u` from the given command lines.
|
2015-08-06 10:59:51 +00:00
|
|
|
|
|
|
|
To run the test suite use the following command::
|
|
|
|
|
|
|
|
fakeroot -u tox # run all tests
|
|
|
|
|
|
|
|
Some more advanced examples::
|
|
|
|
|
|
|
|
# verify a changed tox.ini (run this after any change to tox.ini):
|
|
|
|
fakeroot -u tox --recreate
|
|
|
|
|
2015-12-14 20:11:38 +00:00
|
|
|
fakeroot -u tox -e py34 # run all tests, but only on python 3.4
|
2015-08-06 10:59:51 +00:00
|
|
|
|
|
|
|
fakeroot -u tox borg.testsuite.locking # only run 1 test module
|
|
|
|
|
|
|
|
fakeroot -u tox borg.testsuite.locking -- -k '"not Timer"' # exclude some tests
|
|
|
|
|
|
|
|
fakeroot -u tox borg.testsuite -- -v # verbose py.test
|
|
|
|
|
|
|
|
Important notes:
|
|
|
|
|
2016-02-01 02:22:02 +00:00
|
|
|
- When using ``--`` to give options to py.test, you MUST also give ``borg.testsuite[.module]``.
|
2015-08-06 10:59:51 +00:00
|
|
|
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2015-11-13 15:46:13 +00:00
|
|
|
Regenerate usage files
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
Usage and API documentation is currently committed directly to git,
|
|
|
|
although those files are generated automatically from the source
|
|
|
|
tree.
|
|
|
|
|
|
|
|
When a new module is added, the ``docs/api.rst`` file needs to be
|
|
|
|
regenerated::
|
|
|
|
|
|
|
|
./setup.py build_api
|
|
|
|
|
|
|
|
When a command is added, a commandline flag changed, added or removed,
|
|
|
|
the usage docs need to be rebuilt as well::
|
|
|
|
|
|
|
|
./setup.py build_usage
|
|
|
|
|
2015-08-06 10:59:51 +00:00
|
|
|
Building the docs with Sphinx
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
The documentation (in reStructuredText format, .rst) is in docs/.
|
|
|
|
|
|
|
|
To build the html version of it, you need to have sphinx installed::
|
|
|
|
|
2015-09-30 15:38:51 +00:00
|
|
|
pip3 install sphinx # important: this will install sphinx with Python 3
|
2015-08-06 10:59:51 +00:00
|
|
|
|
|
|
|
Now run::
|
|
|
|
|
|
|
|
cd docs/
|
|
|
|
make html
|
|
|
|
|
|
|
|
Then point a web browser at docs/_build/html/index.html.
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2015-10-09 19:54:02 +00:00
|
|
|
The website is updated automatically through Github web hooks on the
|
|
|
|
main repository.
|
2015-10-07 14:55:42 +00:00
|
|
|
|
2015-09-30 15:38:51 +00:00
|
|
|
Using Vagrant
|
|
|
|
-------------
|
|
|
|
|
2015-11-07 14:17:40 +00:00
|
|
|
We use Vagrant for the automated creation of testing environments and borgbackup
|
2015-09-30 15:38:51 +00:00
|
|
|
standalone binaries for various platforms.
|
|
|
|
|
|
|
|
For better security, there is no automatic sync in the VM to host direction.
|
|
|
|
The plugin `vagrant-scp` is useful to copy stuff from the VMs to the host.
|
|
|
|
|
|
|
|
Usage::
|
|
|
|
|
2016-02-01 02:22:02 +00:00
|
|
|
# To create and provision the VM:
|
|
|
|
vagrant up OS
|
|
|
|
# To create an ssh session to the VM:
|
2016-05-01 18:18:17 +00:00
|
|
|
vagrant ssh OS
|
|
|
|
# To execute a command via ssh in the VM:
|
|
|
|
vagrant ssh OS -c "command args"
|
2016-02-01 02:22:02 +00:00
|
|
|
# To shut down the VM:
|
|
|
|
vagrant halt OS
|
|
|
|
# To shut down and destroy the VM:
|
|
|
|
vagrant destroy OS
|
|
|
|
# To copy files from the VM (in this case, the generated binary):
|
|
|
|
vagrant scp OS:/vagrant/borg/borg.exe .
|
2015-09-30 15:38:51 +00:00
|
|
|
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2015-10-07 14:55:42 +00:00
|
|
|
Creating standalone binaries
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
Make sure you have everything built and installed (including llfuse and fuse).
|
|
|
|
When using the Vagrant VMs, pyinstaller will already be installed.
|
|
|
|
|
|
|
|
With virtual env activated::
|
|
|
|
|
2016-02-01 02:22:02 +00:00
|
|
|
pip install pyinstaller # or git checkout master
|
2015-11-15 14:52:02 +00:00
|
|
|
pyinstaller -F -n borg-PLATFORM borg/__main__.py
|
2015-10-07 14:55:42 +00:00
|
|
|
for file in dist/borg-*; do gpg --armor --detach-sign $file; done
|
|
|
|
|
|
|
|
If you encounter issues, see also our `Vagrantfile` for details.
|
|
|
|
|
|
|
|
.. note:: Standalone binaries built with pyinstaller are supposed to
|
|
|
|
work on same OS, same architecture (x86 32bit, amd64 64bit)
|
|
|
|
without external dependencies.
|
|
|
|
|
|
|
|
|
2015-09-19 19:35:02 +00:00
|
|
|
Creating a new release
|
|
|
|
----------------------
|
|
|
|
|
2015-10-07 13:53:19 +00:00
|
|
|
Checklist:
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2015-10-07 14:55:42 +00:00
|
|
|
- make sure all issues for this milestone are closed or moved to the
|
2015-10-07 14:01:12 +00:00
|
|
|
next milestone
|
2015-10-07 14:08:00 +00:00
|
|
|
- find and fix any low hanging fruit left on the issue tracker
|
2016-02-07 13:44:49 +00:00
|
|
|
- check that Travis CI is happy
|
2015-10-07 13:37:59 +00:00
|
|
|
- update ``CHANGES.rst``, based on ``git log $PREVIOUS_RELEASE..``
|
|
|
|
- check version number of upcoming release in ``CHANGES.rst``
|
|
|
|
- verify that ``MANIFEST.in`` and ``setup.py`` are complete
|
2016-01-12 22:49:19 +00:00
|
|
|
- ``python setup.py build_api ; python setup.py build_usage`` and commit
|
2015-09-19 19:35:02 +00:00
|
|
|
- tag the release::
|
|
|
|
|
2015-10-07 14:55:42 +00:00
|
|
|
git tag -s -m "tagged/signed release X.Y.Z" X.Y.Z
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2016-02-07 13:44:49 +00:00
|
|
|
- run tox and/or binary builds on all supported platforms via vagrant,
|
|
|
|
check for test failures
|
2015-10-07 14:12:56 +00:00
|
|
|
- create a release on PyPi::
|
2015-09-19 19:35:02 +00:00
|
|
|
|
|
|
|
python setup.py register sdist upload --identity="Thomas Waldmann" --sign
|
|
|
|
|
2015-10-07 14:12:56 +00:00
|
|
|
- close release milestone on Github
|
2015-10-19 15:09:28 +00:00
|
|
|
- announce on:
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2015-11-18 14:40:23 +00:00
|
|
|
- Mailing list
|
2015-10-07 14:55:42 +00:00
|
|
|
- Twitter (follow @ThomasJWaldmann for these tweets)
|
2015-11-18 14:40:23 +00:00
|
|
|
- IRC channel (change ``/topic``)
|
2015-09-19 19:35:02 +00:00
|
|
|
|
2015-10-07 14:16:07 +00:00
|
|
|
- create a Github release, include:
|
2016-01-12 22:49:19 +00:00
|
|
|
|
2015-10-07 14:55:42 +00:00
|
|
|
* standalone binaries (see above for how to create them)
|
2016-01-12 22:49:19 +00:00
|
|
|
|
2015-11-20 00:12:31 +00:00
|
|
|
+ for OS X, document the OS X Fuse version in the README of the binaries.
|
|
|
|
OS X FUSE uses a kernel extension that needs to be compatible with the
|
|
|
|
code contained in the binary.
|
2015-10-07 14:16:07 +00:00
|
|
|
* a link to ``CHANGES.rst``
|