Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 1 | Getting started |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 2 | =============== |
| 3 | |
| 4 | Working on ``cryptography`` requires the installation of a small number of |
Alex Gaynor | cefcf2d | 2014-06-26 11:00:33 -0700 | [diff] [blame] | 5 | development dependencies in addition to the dependencies for |
| 6 | :doc:`/installation`. These are listed in ``dev-requirements.txt`` and they can |
| 7 | be installed in a `virtualenv`_ using `pip`_. Once you've installed the |
| 8 | dependencies, install ``cryptography`` in ``editable`` mode. For example: |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 9 | |
| 10 | .. code-block:: console |
| 11 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 12 | $ # Create a virtualenv and activate it |
| 13 | $ pip install --requirement dev-requirements.txt |
| 14 | $ pip install --editable . |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 15 | |
| 16 | You are now ready to run the tests and build the documentation. |
| 17 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 18 | Running tests |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 19 | ~~~~~~~~~~~~~ |
| 20 | |
| 21 | ``cryptography`` unit tests are found in the ``tests/`` directory and are |
| 22 | designed to be run using `pytest`_. `pytest`_ will discover the tests |
| 23 | automatically, so all you have to do is: |
| 24 | |
| 25 | .. code-block:: console |
| 26 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 27 | $ py.test |
| 28 | ... |
| 29 | 62746 passed in 220.43 seconds |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 30 | |
| 31 | This runs the tests with the default Python interpreter. |
| 32 | |
| 33 | You can also verify that the tests pass on other supported Python interpreters. |
| 34 | For this we use `tox`_, which will automatically create a `virtualenv`_ for |
| 35 | each supported Python version and run the tests. For example: |
| 36 | |
| 37 | .. code-block:: console |
| 38 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 39 | $ tox |
| 40 | ... |
| 41 | ERROR: py26: InterpreterNotFound: python2.6 |
| 42 | py27: commands succeeded |
| 43 | ERROR: pypy: InterpreterNotFound: pypy |
| 44 | ERROR: py32: InterpreterNotFound: python3.2 |
| 45 | py33: commands succeeded |
| 46 | docs: commands succeeded |
| 47 | pep8: commands succeeded |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 48 | |
| 49 | You may not have all the required Python versions installed, in which case you |
| 50 | will see one or more ``InterpreterNotFound`` errors. |
| 51 | |
| 52 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 53 | Explicit backend selection |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 54 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 55 | |
| 56 | While testing you may want to run tests against a subset of the backends that |
| 57 | cryptography supports. Explicit backend selection can be done via the |
| 58 | ``--backend`` flag. This flag should be passed to ``py.test`` with a comma |
Paul Kehrer | 18962cc | 2014-02-11 22:54:40 -0600 | [diff] [blame] | 59 | delimited list of backend names. |
| 60 | |
| 61 | |
| 62 | .. code-block:: console |
| 63 | |
| 64 | $ tox -- --backend=openssl |
| 65 | $ py.test --backend=openssl,commoncrypto |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 66 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 67 | Building documentation |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 68 | ~~~~~~~~~~~~~~~~~~~~~~ |
| 69 | |
| 70 | ``cryptography`` documentation is stored in the ``docs/`` directory. It is |
| 71 | written in `reStructured Text`_ and rendered using `Sphinx`_. |
| 72 | |
| 73 | Use `tox`_ to build the documentation. For example: |
| 74 | |
| 75 | .. code-block:: console |
| 76 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 77 | $ tox -e docs |
| 78 | ... |
| 79 | docs: commands succeeded |
| 80 | congratulations :) |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 81 | |
| 82 | The HTML documentation index can now be found at |
| 83 | ``docs/_build/html/index.html``. |
| 84 | |
| 85 | .. _`pytest`: https://pypi.python.org/pypi/pytest |
| 86 | .. _`tox`: https://pypi.python.org/pypi/tox |
| 87 | .. _`virtualenv`: https://pypi.python.org/pypi/virtualenv |
| 88 | .. _`pip`: https://pypi.python.org/pypi/pip |
| 89 | .. _`sphinx`: https://pypi.python.org/pypi/Sphinx |
| 90 | .. _`reStructured Text`: http://sphinx-doc.org/rest.html |