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