blob: b347400203bb3bf073738b2edbecd3fa6f1a8c30 [file] [log] [blame]
Alex Stapletonc5fffd32014-03-18 15:29:00 +00001Getting started
Paul Kehrer0839aa82014-02-11 22:36:51 -06002===============
3
4Working on ``cryptography`` requires the installation of a small number of
Alex Gaynorcefcf2d2014-06-26 11:00:33 -07005development dependencies in addition to the dependencies for
6:doc:`/installation`. These are listed in ``dev-requirements.txt`` and they can
7be installed in a `virtualenv`_ using `pip`_. Once you've installed the
8dependencies, install ``cryptography`` in ``editable`` mode. For example:
Paul Kehrer0839aa82014-02-11 22:36:51 -06009
10.. code-block:: console
11
Paul Kehrer450cd022014-02-11 22:46:39 -060012 $ # Create a virtualenv and activate it
13 $ pip install --requirement dev-requirements.txt
14 $ pip install --editable .
Paul Kehrer0839aa82014-02-11 22:36:51 -060015
Paul Kehrer2ac87782014-06-27 11:12:24 -060016You will also need to install ``enchant`` using your system's package manager
17to check spelling in the documentation.
18
Paul Kehrer0839aa82014-02-11 22:36:51 -060019You are now ready to run the tests and build the documentation.
20
Alex Stapletonc5fffd32014-03-18 15:29:00 +000021Running tests
Paul Kehrer0839aa82014-02-11 22:36:51 -060022~~~~~~~~~~~~~
23
24``cryptography`` unit tests are found in the ``tests/`` directory and are
25designed to be run using `pytest`_. `pytest`_ will discover the tests
26automatically, so all you have to do is:
27
28.. code-block:: console
29
Paul Kehrer450cd022014-02-11 22:46:39 -060030 $ py.test
31 ...
32 62746 passed in 220.43 seconds
Paul Kehrer0839aa82014-02-11 22:36:51 -060033
34This runs the tests with the default Python interpreter.
35
36You can also verify that the tests pass on other supported Python interpreters.
37For this we use `tox`_, which will automatically create a `virtualenv`_ for
38each supported Python version and run the tests. For example:
39
40.. code-block:: console
41
Paul Kehrer450cd022014-02-11 22:46:39 -060042 $ tox
43 ...
44 ERROR: py26: InterpreterNotFound: python2.6
45 py27: commands succeeded
46 ERROR: pypy: InterpreterNotFound: pypy
Paul Kehrer450cd022014-02-11 22:46:39 -060047 py33: commands succeeded
48 docs: commands succeeded
49 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060050
51You may not have all the required Python versions installed, in which case you
52will see one or more ``InterpreterNotFound`` errors.
53
54
Alex Stapletonc5fffd32014-03-18 15:29:00 +000055Explicit backend selection
Paul Kehrer0839aa82014-02-11 22:36:51 -060056~~~~~~~~~~~~~~~~~~~~~~~~~~
57
58While testing you may want to run tests against a subset of the backends that
59cryptography supports. Explicit backend selection can be done via the
60``--backend`` flag. This flag should be passed to ``py.test`` with a comma
Paul Kehrer18962cc2014-02-11 22:54:40 -060061delimited list of backend names.
62
63
64.. code-block:: console
65
66 $ tox -- --backend=openssl
67 $ py.test --backend=openssl,commoncrypto
Paul Kehrer0839aa82014-02-11 22:36:51 -060068
Alex Stapletonc5fffd32014-03-18 15:29:00 +000069Building documentation
Paul Kehrer0839aa82014-02-11 22:36:51 -060070~~~~~~~~~~~~~~~~~~~~~~
71
72``cryptography`` documentation is stored in the ``docs/`` directory. It is
73written in `reStructured Text`_ and rendered using `Sphinx`_.
74
75Use `tox`_ to build the documentation. For example:
76
77.. code-block:: console
78
Paul Kehrer450cd022014-02-11 22:46:39 -060079 $ tox -e docs
80 ...
81 docs: commands succeeded
82 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -060083
84The HTML documentation index can now be found at
85``docs/_build/html/index.html``.
86
87.. _`pytest`: https://pypi.python.org/pypi/pytest
88.. _`tox`: https://pypi.python.org/pypi/tox
89.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
90.. _`pip`: https://pypi.python.org/pypi/pip
91.. _`sphinx`: https://pypi.python.org/pypi/Sphinx
92.. _`reStructured Text`: http://sphinx-doc.org/rest.html