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 | |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 4 | Development dependencies |
| 5 | ------------------------ |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 6 | Working on ``cryptography`` requires the installation of a small number of |
Alex Gaynor | cefcf2d | 2014-06-26 11:00:33 -0700 | [diff] [blame] | 7 | development dependencies in addition to the dependencies for |
| 8 | :doc:`/installation`. These are listed in ``dev-requirements.txt`` and they can |
| 9 | be installed in a `virtualenv`_ using `pip`_. Once you've installed the |
| 10 | dependencies, install ``cryptography`` in ``editable`` mode. For example: |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 11 | |
| 12 | .. code-block:: console |
| 13 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 14 | $ # Create a virtualenv and activate it |
| 15 | $ pip install --requirement dev-requirements.txt |
| 16 | $ pip install --editable . |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 17 | |
Paul Kehrer | 2ac8778 | 2014-06-27 11:12:24 -0600 | [diff] [blame] | 18 | You will also need to install ``enchant`` using your system's package manager |
| 19 | to check spelling in the documentation. |
| 20 | |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 21 | You are now ready to run the tests and build the documentation. |
| 22 | |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 23 | OpenSSL on OS X |
| 24 | ~~~~~~~~~~~~~~~ |
| 25 | |
| 26 | You must have installed `OpenSSL`_ via `Homebrew`_ or `MacPorts`_ and must set |
| 27 | ``CFLAGS`` and ``LDFLAGS`` environment variables before installing the |
| 28 | ``dev-requirements.txt`` otherwise pip will fail with include errors. |
| 29 | |
Alex Gaynor | 0c11d04 | 2016-06-02 22:24:22 -0700 | [diff] [blame] | 30 | For example, with `Homebrew`_: |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 31 | |
| 32 | .. code-block:: console |
| 33 | |
| 34 | $ env LDFLAGS="-L$(brew --prefix openssl)/lib" \ |
| 35 | CFLAGS="-I$(brew --prefix openssl)/include" \ |
| 36 | pip install --requirement ./dev-requirements.txt |
| 37 | |
| 38 | Alternatively for a static build you can specify |
| 39 | ``CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1`` and ensure ``LDFLAGS`` points to the |
| 40 | absolute path for the `OpenSSL`_ libraries before calling pip. |
| 41 | |
| 42 | .. tip:: |
| 43 | You will also need to set these values when `Building documentation`_. |
| 44 | |
| 45 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 46 | Running tests |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 47 | ------------- |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 48 | |
| 49 | ``cryptography`` unit tests are found in the ``tests/`` directory and are |
| 50 | designed to be run using `pytest`_. `pytest`_ will discover the tests |
| 51 | automatically, so all you have to do is: |
| 52 | |
| 53 | .. code-block:: console |
| 54 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 55 | $ py.test |
| 56 | ... |
| 57 | 62746 passed in 220.43 seconds |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 58 | |
| 59 | This runs the tests with the default Python interpreter. |
| 60 | |
| 61 | You can also verify that the tests pass on other supported Python interpreters. |
| 62 | For this we use `tox`_, which will automatically create a `virtualenv`_ for |
| 63 | each supported Python version and run the tests. For example: |
| 64 | |
| 65 | .. code-block:: console |
| 66 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 67 | $ tox |
| 68 | ... |
| 69 | ERROR: py26: InterpreterNotFound: python2.6 |
| 70 | py27: commands succeeded |
| 71 | ERROR: pypy: InterpreterNotFound: pypy |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 72 | py33: commands succeeded |
| 73 | docs: commands succeeded |
| 74 | pep8: commands succeeded |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 75 | |
| 76 | You may not have all the required Python versions installed, in which case you |
| 77 | will see one or more ``InterpreterNotFound`` errors. |
| 78 | |
| 79 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 80 | Explicit backend selection |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 81 | -------------------------- |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 82 | |
| 83 | While testing you may want to run tests against a subset of the backends that |
| 84 | cryptography supports. Explicit backend selection can be done via the |
| 85 | ``--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] | 86 | delimited list of backend names. |
| 87 | |
| 88 | |
| 89 | .. code-block:: console |
| 90 | |
| 91 | $ tox -- --backend=openssl |
| 92 | $ py.test --backend=openssl,commoncrypto |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 93 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 94 | Building documentation |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 95 | ---------------------- |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 96 | |
| 97 | ``cryptography`` documentation is stored in the ``docs/`` directory. It is |
| 98 | written in `reStructured Text`_ and rendered using `Sphinx`_. |
| 99 | |
| 100 | Use `tox`_ to build the documentation. For example: |
| 101 | |
| 102 | .. code-block:: console |
| 103 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 104 | $ tox -e docs |
| 105 | ... |
| 106 | docs: commands succeeded |
| 107 | congratulations :) |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 108 | |
| 109 | The HTML documentation index can now be found at |
| 110 | ``docs/_build/html/index.html``. |
| 111 | |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 112 | .. _`Homebrew`: http://brew.sh |
| 113 | .. _`MacPorts`: https://www.macports.org |
| 114 | .. _`OpenSSL`: https://openssl.org |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 115 | .. _`pytest`: https://pypi.python.org/pypi/pytest |
| 116 | .. _`tox`: https://pypi.python.org/pypi/tox |
| 117 | .. _`virtualenv`: https://pypi.python.org/pypi/virtualenv |
| 118 | .. _`pip`: https://pypi.python.org/pypi/pip |
| 119 | .. _`sphinx`: https://pypi.python.org/pypi/Sphinx |
| 120 | .. _`reStructured Text`: http://sphinx-doc.org/rest.html |