blob: 0bbb18ce0febfb61939700ba0a53a146139bbb0b [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
9be installed in a `virtualenv`_ using `pip`_. Once you've installed the
10dependencies, install ``cryptography`` in ``editable`` mode. For example:
Paul Kehrer0839aa82014-02-11 22:36:51 -060011
12.. code-block:: console
13
Paul Kehrer450cd022014-02-11 22:46:39 -060014 $ # Create a virtualenv and activate it
15 $ pip install --requirement dev-requirements.txt
16 $ pip install --editable .
Paul Kehrer0839aa82014-02-11 22:36:51 -060017
Paul Kehrer2ac87782014-06-27 11:12:24 -060018You will also need to install ``enchant`` using your system's package manager
19to check spelling in the documentation.
20
Paul Kehrer0839aa82014-02-11 22:36:51 -060021You are now ready to run the tests and build the documentation.
22
Chris Collis2f27a8b2016-04-23 15:28:23 +010023OpenSSL on OS X
24~~~~~~~~~~~~~~~
25
26You 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
30For example with `Homebrew`_:
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
38Alternatively for a static build you can specify
39``CRYPTOGRAPHY_OSX_NO_LINK_FLAGS=1`` and ensure ``LDFLAGS`` points to the
40absolute 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 Stapletonc5fffd32014-03-18 15:29:00 +000046Running tests
Chris Collis2f27a8b2016-04-23 15:28:23 +010047-------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060048
49``cryptography`` unit tests are found in the ``tests/`` directory and are
50designed to be run using `pytest`_. `pytest`_ will discover the tests
51automatically, so all you have to do is:
52
53.. code-block:: console
54
Paul Kehrer450cd022014-02-11 22:46:39 -060055 $ py.test
56 ...
57 62746 passed in 220.43 seconds
Paul Kehrer0839aa82014-02-11 22:36:51 -060058
59This runs the tests with the default Python interpreter.
60
61You can also verify that the tests pass on other supported Python interpreters.
62For this we use `tox`_, which will automatically create a `virtualenv`_ for
63each supported Python version and run the tests. For example:
64
65.. code-block:: console
66
Paul Kehrer450cd022014-02-11 22:46:39 -060067 $ tox
68 ...
69 ERROR: py26: InterpreterNotFound: python2.6
70 py27: commands succeeded
71 ERROR: pypy: InterpreterNotFound: pypy
Paul Kehrer450cd022014-02-11 22:46:39 -060072 py33: commands succeeded
73 docs: commands succeeded
74 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060075
76You may not have all the required Python versions installed, in which case you
77will see one or more ``InterpreterNotFound`` errors.
78
79
Alex Stapletonc5fffd32014-03-18 15:29:00 +000080Explicit backend selection
Chris Collis2f27a8b2016-04-23 15:28:23 +010081--------------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060082
83While testing you may want to run tests against a subset of the backends that
84cryptography supports. Explicit backend selection can be done via the
85``--backend`` flag. This flag should be passed to ``py.test`` with a comma
Paul Kehrer18962cc2014-02-11 22:54:40 -060086delimited list of backend names.
87
88
89.. code-block:: console
90
91 $ tox -- --backend=openssl
92 $ py.test --backend=openssl,commoncrypto
Paul Kehrer0839aa82014-02-11 22:36:51 -060093
Alex Stapletonc5fffd32014-03-18 15:29:00 +000094Building documentation
Chris Collis2f27a8b2016-04-23 15:28:23 +010095----------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060096
97``cryptography`` documentation is stored in the ``docs/`` directory. It is
98written in `reStructured Text`_ and rendered using `Sphinx`_.
99
100Use `tox`_ to build the documentation. For example:
101
102.. code-block:: console
103
Paul Kehrer450cd022014-02-11 22:46:39 -0600104 $ tox -e docs
105 ...
106 docs: commands succeeded
107 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -0600108
109The HTML documentation index can now be found at
110``docs/_build/html/index.html``.
111
Chris Collis2f27a8b2016-04-23 15:28:23 +0100112.. _`Homebrew`: http://brew.sh
113.. _`MacPorts`: https://www.macports.org
114.. _`OpenSSL`: https://openssl.org
Paul Kehrer0839aa82014-02-11 22:36:51 -0600115.. _`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