blob: ea21f5e67ca72f1a46d848474ff2bef0ff2ea1d1 [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
Chris Collis2f27a8b2016-04-23 15:28:23 +010033OpenSSL on OS X
34~~~~~~~~~~~~~~~
35
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
44 $ env LDFLAGS="-L$(brew --prefix openssl)/lib" \
45 CFLAGS="-I$(brew --prefix openssl)/include" \
46 pip install --requirement ./dev-requirements.txt
47
48Alternatively for a static build you can specify
49``CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1`` and ensure ``LDFLAGS`` points to the
50absolute 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
Paul Kehrer450cd022014-02-11 22:46:39 -060064 $ py.test
65 ...
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 ...
78 ERROR: py26: InterpreterNotFound: python2.6
79 py27: commands succeeded
80 ERROR: pypy: InterpreterNotFound: pypy
Paul Kehrer450cd022014-02-11 22:46:39 -060081 py33: commands succeeded
82 docs: commands succeeded
83 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060084
85You may not have all the required Python versions installed, in which case you
86will see one or more ``InterpreterNotFound`` errors.
87
88
Alex Stapletonc5fffd32014-03-18 15:29:00 +000089Explicit backend selection
Chris Collis2f27a8b2016-04-23 15:28:23 +010090--------------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060091
92While testing you may want to run tests against a subset of the backends that
93cryptography supports. Explicit backend selection can be done via the
94``--backend`` flag. This flag should be passed to ``py.test`` with a comma
Paul Kehrer18962cc2014-02-11 22:54:40 -060095delimited list of backend names.
96
97
98.. code-block:: console
99
100 $ tox -- --backend=openssl
101 $ py.test --backend=openssl,commoncrypto
Paul Kehrer0839aa82014-02-11 22:36:51 -0600102
Alex Stapletonc5fffd32014-03-18 15:29:00 +0000103Building documentation
Chris Collis2f27a8b2016-04-23 15:28:23 +0100104----------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -0600105
106``cryptography`` documentation is stored in the ``docs/`` directory. It is
107written in `reStructured Text`_ and rendered using `Sphinx`_.
108
109Use `tox`_ to build the documentation. For example:
110
111.. code-block:: console
112
Paul Kehrer450cd022014-02-11 22:46:39 -0600113 $ tox -e docs
114 ...
115 docs: commands succeeded
116 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -0600117
118The HTML documentation index can now be found at
119``docs/_build/html/index.html``.
120
Chris Collis2f27a8b2016-04-23 15:28:23 +0100121.. _`Homebrew`: http://brew.sh
122.. _`MacPorts`: https://www.macports.org
123.. _`OpenSSL`: https://openssl.org
Paul Kehrer0839aa82014-02-11 22:36:51 -0600124.. _`pytest`: https://pypi.python.org/pypi/pytest
125.. _`tox`: https://pypi.python.org/pypi/tox
126.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
127.. _`pip`: https://pypi.python.org/pypi/pip
128.. _`sphinx`: https://pypi.python.org/pypi/Sphinx
129.. _`reStructured Text`: http://sphinx-doc.org/rest.html
Nick Badger63bbf182016-09-03 10:10:36 -0700130.. _`this Github issue`: https://github.com/rfk/pyenchant/issues/42