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 |
Nick Badger | 63bbf18 | 2016-09-03 10:10:36 -0700 | [diff] [blame] | 9 | be installed in a `virtualenv`_ using `pip`_. Before you install them, follow |
| 10 | the **build** instructions in :doc:`/installation` (be sure to stop before |
| 11 | actually installing ``cryptography``). Once you've done that, install the |
| 12 | development dependencies, and then install ``cryptography`` in ``editable`` |
| 13 | mode. For example: |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 14 | |
| 15 | .. code-block:: console |
| 16 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 17 | $ # Create a virtualenv and activate it |
Nick Badger | 63bbf18 | 2016-09-03 10:10:36 -0700 | [diff] [blame] | 18 | $ # Set up your cryptography build environment |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 19 | $ pip install --requirement dev-requirements.txt |
| 20 | $ pip install --editable . |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 21 | |
Paul Kehrer | 2ac8778 | 2014-06-27 11:12:24 -0600 | [diff] [blame] | 22 | You will also need to install ``enchant`` using your system's package manager |
| 23 | to check spelling in the documentation. |
| 24 | |
Nick Badger | 63bbf18 | 2016-09-03 10:10:36 -0700 | [diff] [blame] | 25 | .. note:: |
| 26 | There is an upstream bug in ``enchant`` that prevents its installation on |
| 27 | Windows with 64-bit Python. See `this Github issue`_ for more information. |
| 28 | The easiest workaround is to use 32-bit Python for ``cryptography`` |
| 29 | development, even on 64-bit Windows. |
| 30 | |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 31 | You are now ready to run the tests and build the documentation. |
| 32 | |
Paul Kehrer | 4ce11b1 | 2017-03-14 13:50:47 -0400 | [diff] [blame] | 33 | OpenSSL on macOS |
| 34 | ~~~~~~~~~~~~~~~~ |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 35 | |
| 36 | You must have installed `OpenSSL`_ via `Homebrew`_ or `MacPorts`_ and must set |
| 37 | ``CFLAGS`` and ``LDFLAGS`` environment variables before installing the |
| 38 | ``dev-requirements.txt`` otherwise pip will fail with include errors. |
| 39 | |
Alex Gaynor | 0c11d04 | 2016-06-02 22:24:22 -0700 | [diff] [blame] | 40 | For example, with `Homebrew`_: |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 41 | |
| 42 | .. code-block:: console |
| 43 | |
Paul Kehrer | 4ce11b1 | 2017-03-14 13:50:47 -0400 | [diff] [blame] | 44 | $ env LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" \ |
| 45 | CFLAGS="-I$(brew --prefix openssl@1.1)/include" \ |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 46 | pip install --requirement ./dev-requirements.txt |
| 47 | |
| 48 | Alternatively for a static build you can specify |
Paul Kehrer | adeaacf | 2017-05-24 12:49:18 -0700 | [diff] [blame] | 49 | ``CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1`` and ensure ``LDFLAGS`` points to the |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 50 | absolute path for the `OpenSSL`_ libraries before calling pip. |
| 51 | |
| 52 | .. tip:: |
| 53 | You will also need to set these values when `Building documentation`_. |
| 54 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 55 | Running tests |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 56 | ------------- |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 57 | |
| 58 | ``cryptography`` unit tests are found in the ``tests/`` directory and are |
| 59 | designed to be run using `pytest`_. `pytest`_ will discover the tests |
| 60 | automatically, so all you have to do is: |
| 61 | |
| 62 | .. code-block:: console |
| 63 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 64 | $ py.test |
| 65 | ... |
| 66 | 62746 passed in 220.43 seconds |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 67 | |
| 68 | This runs the tests with the default Python interpreter. |
| 69 | |
| 70 | You can also verify that the tests pass on other supported Python interpreters. |
| 71 | For this we use `tox`_, which will automatically create a `virtualenv`_ for |
| 72 | each supported Python version and run the tests. For example: |
| 73 | |
| 74 | .. code-block:: console |
| 75 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 76 | $ tox |
| 77 | ... |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 78 | py27: commands succeeded |
| 79 | ERROR: pypy: InterpreterNotFound: pypy |
Paul Kehrer | 4cf6e78 | 2017-10-12 06:06:01 +0800 | [diff] [blame] | 80 | py34: commands succeeded |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 81 | docs: commands succeeded |
| 82 | pep8: commands succeeded |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 83 | |
| 84 | You may not have all the required Python versions installed, in which case you |
| 85 | will see one or more ``InterpreterNotFound`` errors. |
| 86 | |
| 87 | |
Alex Stapleton | c5fffd3 | 2014-03-18 15:29:00 +0000 | [diff] [blame] | 88 | Building documentation |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 89 | ---------------------- |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 90 | |
| 91 | ``cryptography`` documentation is stored in the ``docs/`` directory. It is |
| 92 | written in `reStructured Text`_ and rendered using `Sphinx`_. |
| 93 | |
| 94 | Use `tox`_ to build the documentation. For example: |
| 95 | |
| 96 | .. code-block:: console |
| 97 | |
Paul Kehrer | 450cd02 | 2014-02-11 22:46:39 -0600 | [diff] [blame] | 98 | $ tox -e docs |
| 99 | ... |
| 100 | docs: commands succeeded |
| 101 | congratulations :) |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 102 | |
| 103 | The HTML documentation index can now be found at |
| 104 | ``docs/_build/html/index.html``. |
| 105 | |
Alex Gaynor | 5ad6df9 | 2017-02-18 12:52:50 -0500 | [diff] [blame] | 106 | .. _`Homebrew`: https://brew.sh |
Chris Collis | 2f27a8b | 2016-04-23 15:28:23 +0100 | [diff] [blame] | 107 | .. _`MacPorts`: https://www.macports.org |
Alex Gaynor | 769d5c6 | 2016-11-06 04:30:36 -0500 | [diff] [blame] | 108 | .. _`OpenSSL`: https://www.openssl.org |
Paul Kehrer | 0839aa8 | 2014-02-11 22:36:51 -0600 | [diff] [blame] | 109 | .. _`pytest`: https://pypi.python.org/pypi/pytest |
| 110 | .. _`tox`: https://pypi.python.org/pypi/tox |
| 111 | .. _`virtualenv`: https://pypi.python.org/pypi/virtualenv |
| 112 | .. _`pip`: https://pypi.python.org/pypi/pip |
| 113 | .. _`sphinx`: https://pypi.python.org/pypi/Sphinx |
Alex Gaynor | b9051a3 | 2018-04-01 09:16:41 -0400 | [diff] [blame^] | 114 | .. _`reStructured Text`: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html |
Nick Badger | 63bbf18 | 2016-09-03 10:10:36 -0700 | [diff] [blame] | 115 | .. _`this Github issue`: https://github.com/rfk/pyenchant/issues/42 |