blob: 953ae9597790bba8a284539d922bb3bca9eab707 [file] [log] [blame]
Alex Stapletonc5fffd32014-03-18 15:29:00 +00001Getting started
Paul Kehrer0839aa82014-02-11 22:36:51 -06002===============
3
Chris Collis2f27a8b2016-04-23 15:28:23 +01004Development dependencies
5------------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -06006Working on ``cryptography`` requires the installation of a small number of
Alex Gaynorcefcf2d2014-06-26 11:00:33 -07007development dependencies in addition to the dependencies for
8:doc:`/installation`. These are listed in ``dev-requirements.txt`` and they can
Nick Badger63bbf182016-09-03 10:10:36 -07009be installed in a `virtualenv`_ using `pip`_. Before you install them, follow
10the **build** instructions in :doc:`/installation` (be sure to stop before
11actually installing ``cryptography``). Once you've done that, install the
12development dependencies, and then install ``cryptography`` in ``editable``
13mode. For example:
Paul Kehrer0839aa82014-02-11 22:36:51 -060014
15.. code-block:: console
16
Paul Kehrer450cd022014-02-11 22:46:39 -060017 $ # Create a virtualenv and activate it
Nick Badger63bbf182016-09-03 10:10:36 -070018 $ # Set up your cryptography build environment
Paul Kehrer450cd022014-02-11 22:46:39 -060019 $ pip install --requirement dev-requirements.txt
20 $ pip install --editable .
Paul Kehrer0839aa82014-02-11 22:36:51 -060021
Paul Kehrer2ac87782014-06-27 11:12:24 -060022You will also need to install ``enchant`` using your system's package manager
23to check spelling in the documentation.
24
Nick Badger63bbf182016-09-03 10:10:36 -070025.. 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 Kehrer0839aa82014-02-11 22:36:51 -060031You are now ready to run the tests and build the documentation.
32
Paul Kehrer4ce11b12017-03-14 13:50:47 -040033OpenSSL on macOS
34~~~~~~~~~~~~~~~~
Chris Collis2f27a8b2016-04-23 15:28:23 +010035
36You 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 Gaynor0c11d042016-06-02 22:24:22 -070040For example, with `Homebrew`_:
Chris Collis2f27a8b2016-04-23 15:28:23 +010041
42.. code-block:: console
43
Paul Kehrer4ce11b12017-03-14 13:50:47 -040044 $ env LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" \
45 CFLAGS="-I$(brew --prefix openssl@1.1)/include" \
Chris Collis2f27a8b2016-04-23 15:28:23 +010046 pip install --requirement ./dev-requirements.txt
47
48Alternatively for a static build you can specify
Paul Kehreradeaacf2017-05-24 12:49:18 -070049``CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1`` and ensure ``LDFLAGS`` points to the
Chris Collis2f27a8b2016-04-23 15:28:23 +010050absolute 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 Stapletonc5fffd32014-03-18 15:29:00 +000055Running tests
Chris Collis2f27a8b2016-04-23 15:28:23 +010056-------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060057
58``cryptography`` unit tests are found in the ``tests/`` directory and are
59designed to be run using `pytest`_. `pytest`_ will discover the tests
60automatically, so all you have to do is:
61
62.. code-block:: console
63
Ville Skyttä40c6d402018-05-13 16:23:49 +020064 $ pytest
Paul Kehrer450cd022014-02-11 22:46:39 -060065 ...
66 62746 passed in 220.43 seconds
Paul Kehrer0839aa82014-02-11 22:36:51 -060067
68This runs the tests with the default Python interpreter.
69
70You can also verify that the tests pass on other supported Python interpreters.
71For this we use `tox`_, which will automatically create a `virtualenv`_ for
72each supported Python version and run the tests. For example:
73
74.. code-block:: console
75
Paul Kehrer450cd022014-02-11 22:46:39 -060076 $ tox
77 ...
Paul Kehrer450cd022014-02-11 22:46:39 -060078 py27: commands succeeded
79 ERROR: pypy: InterpreterNotFound: pypy
Paul Kehrer4cf6e782017-10-12 06:06:01 +080080 py34: commands succeeded
Paul Kehrer450cd022014-02-11 22:46:39 -060081 docs: commands succeeded
82 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060083
84You may not have all the required Python versions installed, in which case you
85will see one or more ``InterpreterNotFound`` errors.
86
87
Alex Stapletonc5fffd32014-03-18 15:29:00 +000088Building documentation
Chris Collis2f27a8b2016-04-23 15:28:23 +010089----------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060090
91``cryptography`` documentation is stored in the ``docs/`` directory. It is
92written in `reStructured Text`_ and rendered using `Sphinx`_.
93
94Use `tox`_ to build the documentation. For example:
95
96.. code-block:: console
97
Paul Kehrer450cd022014-02-11 22:46:39 -060098 $ tox -e docs
99 ...
100 docs: commands succeeded
101 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -0600102
103The HTML documentation index can now be found at
104``docs/_build/html/index.html``.
105
Alex Gaynor5ad6df92017-02-18 12:52:50 -0500106.. _`Homebrew`: https://brew.sh
Chris Collis2f27a8b2016-04-23 15:28:23 +0100107.. _`MacPorts`: https://www.macports.org
Alex Gaynor769d5c62016-11-06 04:30:36 -0500108.. _`OpenSSL`: https://www.openssl.org
Alex Gaynor3414f5c2018-04-15 19:41:11 -0400109.. _`pytest`: https://pypi.org/project/pytest/
110.. _`tox`: https://pypi.org/project/tox/
111.. _`virtualenv`: https://pypi.org/project/virtualenv/
112.. _`pip`: https://pypi.org/project/pip/
113.. _`sphinx`: https://pypi.org/project/Sphinx/
Alex Gaynorb9051a32018-04-01 09:16:41 -0400114.. _`reStructured Text`: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
Nick Badger63bbf182016-09-03 10:10:36 -0700115.. _`this Github issue`: https://github.com/rfk/pyenchant/issues/42