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