blob: 3d9012eb3cbdd610844a9bfbad097a99620a8ae9 [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
5development dependencies. These are listed in ``dev-requirements.txt`` and they
6can be installed in a `virtualenv`_ using `pip`_. Once you've installed the
7dependencies, install ``cryptography`` in ``editable`` mode. For example:
8
9.. code-block:: console
10
Paul Kehrer450cd022014-02-11 22:46:39 -060011 $ # Create a virtualenv and activate it
12 $ pip install --requirement dev-requirements.txt
13 $ pip install --editable .
Paul Kehrer0839aa82014-02-11 22:36:51 -060014
15You are now ready to run the tests and build the documentation.
16
Alex Stapletonc5fffd32014-03-18 15:29:00 +000017Running tests
Paul Kehrer0839aa82014-02-11 22:36:51 -060018~~~~~~~~~~~~~
19
20``cryptography`` unit tests are found in the ``tests/`` directory and are
21designed to be run using `pytest`_. `pytest`_ will discover the tests
22automatically, so all you have to do is:
23
24.. code-block:: console
25
Paul Kehrer450cd022014-02-11 22:46:39 -060026 $ py.test
27 ...
28 62746 passed in 220.43 seconds
Paul Kehrer0839aa82014-02-11 22:36:51 -060029
30This runs the tests with the default Python interpreter.
31
32You can also verify that the tests pass on other supported Python interpreters.
33For this we use `tox`_, which will automatically create a `virtualenv`_ for
34each supported Python version and run the tests. For example:
35
36.. code-block:: console
37
Paul Kehrer450cd022014-02-11 22:46:39 -060038 $ tox
39 ...
40 ERROR: py26: InterpreterNotFound: python2.6
41 py27: commands succeeded
42 ERROR: pypy: InterpreterNotFound: pypy
43 ERROR: py32: InterpreterNotFound: python3.2
44 py33: commands succeeded
45 docs: commands succeeded
46 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060047
48You may not have all the required Python versions installed, in which case you
49will see one or more ``InterpreterNotFound`` errors.
50
51
Alex Stapletonc5fffd32014-03-18 15:29:00 +000052Explicit backend selection
Paul Kehrer0839aa82014-02-11 22:36:51 -060053~~~~~~~~~~~~~~~~~~~~~~~~~~
54
55While testing you may want to run tests against a subset of the backends that
56cryptography supports. Explicit backend selection can be done via the
57``--backend`` flag. This flag should be passed to ``py.test`` with a comma
Paul Kehrer18962cc2014-02-11 22:54:40 -060058delimited list of backend names.
59
60
61.. code-block:: console
62
63 $ tox -- --backend=openssl
64 $ py.test --backend=openssl,commoncrypto
Paul Kehrer0839aa82014-02-11 22:36:51 -060065
Alex Stapletonc5fffd32014-03-18 15:29:00 +000066Building documentation
Paul Kehrer0839aa82014-02-11 22:36:51 -060067~~~~~~~~~~~~~~~~~~~~~~
68
69``cryptography`` documentation is stored in the ``docs/`` directory. It is
70written in `reStructured Text`_ and rendered using `Sphinx`_.
71
72Use `tox`_ to build the documentation. For example:
73
74.. code-block:: console
75
Paul Kehrer450cd022014-02-11 22:46:39 -060076 $ tox -e docs
77 ...
78 docs: commands succeeded
79 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -060080
81The HTML documentation index can now be found at
82``docs/_build/html/index.html``.
83
84.. _`pytest`: https://pypi.python.org/pypi/pytest
85.. _`tox`: https://pypi.python.org/pypi/tox
86.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
87.. _`pip`: https://pypi.python.org/pypi/pip
88.. _`sphinx`: https://pypi.python.org/pypi/Sphinx
89.. _`reStructured Text`: http://sphinx-doc.org/rest.html