blob: f5d6c1901c9810e9e6f6aa53bb0658325dac876a [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
47 ERROR: py32: InterpreterNotFound: python3.2
48 py33: commands succeeded
49 docs: commands succeeded
50 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060051
52You may not have all the required Python versions installed, in which case you
53will see one or more ``InterpreterNotFound`` errors.
54
55
Alex Stapletonc5fffd32014-03-18 15:29:00 +000056Explicit backend selection
Paul Kehrer0839aa82014-02-11 22:36:51 -060057~~~~~~~~~~~~~~~~~~~~~~~~~~
58
59While testing you may want to run tests against a subset of the backends that
60cryptography supports. Explicit backend selection can be done via the
61``--backend`` flag. This flag should be passed to ``py.test`` with a comma
Paul Kehrer18962cc2014-02-11 22:54:40 -060062delimited list of backend names.
63
64
65.. code-block:: console
66
67 $ tox -- --backend=openssl
68 $ py.test --backend=openssl,commoncrypto
Paul Kehrer0839aa82014-02-11 22:36:51 -060069
Alex Stapletonc5fffd32014-03-18 15:29:00 +000070Building documentation
Paul Kehrer0839aa82014-02-11 22:36:51 -060071~~~~~~~~~~~~~~~~~~~~~~
72
73``cryptography`` documentation is stored in the ``docs/`` directory. It is
74written in `reStructured Text`_ and rendered using `Sphinx`_.
75
76Use `tox`_ to build the documentation. For example:
77
78.. code-block:: console
79
Paul Kehrer450cd022014-02-11 22:46:39 -060080 $ tox -e docs
81 ...
82 docs: commands succeeded
83 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -060084
85The HTML documentation index can now be found at
86``docs/_build/html/index.html``.
87
88.. _`pytest`: https://pypi.python.org/pypi/pytest
89.. _`tox`: https://pypi.python.org/pypi/tox
90.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
91.. _`pip`: https://pypi.python.org/pypi/pip
92.. _`sphinx`: https://pypi.python.org/pypi/Sphinx
93.. _`reStructured Text`: http://sphinx-doc.org/rest.html