blob: 1d939a9c378643915e7cabeffa72220fba22bd59 [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
André Almeida8a35a202018-10-18 23:20:03 -030022Make sure that ``pip install --requirement ...`` has installed the Python
23package ``vectors/`` and packages on ``tests/`` . If it didn't, you may
24install them manually by using ``pip`` on each directory.
25
Paul Kehrer2ac87782014-06-27 11:12:24 -060026You will also need to install ``enchant`` using your system's package manager
27to check spelling in the documentation.
28
Nick Badger63bbf182016-09-03 10:10:36 -070029.. note::
30 There is an upstream bug in ``enchant`` that prevents its installation on
31 Windows with 64-bit Python. See `this Github issue`_ for more information.
32 The easiest workaround is to use 32-bit Python for ``cryptography``
33 development, even on 64-bit Windows.
34
Paul Kehrer0839aa82014-02-11 22:36:51 -060035You are now ready to run the tests and build the documentation.
36
Paul Kehrer4ce11b12017-03-14 13:50:47 -040037OpenSSL on macOS
38~~~~~~~~~~~~~~~~
Chris Collis2f27a8b2016-04-23 15:28:23 +010039
40You must have installed `OpenSSL`_ via `Homebrew`_ or `MacPorts`_ and must set
41``CFLAGS`` and ``LDFLAGS`` environment variables before installing the
42``dev-requirements.txt`` otherwise pip will fail with include errors.
43
Alex Gaynor0c11d042016-06-02 22:24:22 -070044For example, with `Homebrew`_:
Chris Collis2f27a8b2016-04-23 15:28:23 +010045
46.. code-block:: console
47
Paul Kehrer4ce11b12017-03-14 13:50:47 -040048 $ env LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" \
49 CFLAGS="-I$(brew --prefix openssl@1.1)/include" \
Chris Collis2f27a8b2016-04-23 15:28:23 +010050 pip install --requirement ./dev-requirements.txt
51
52Alternatively for a static build you can specify
Paul Kehreradeaacf2017-05-24 12:49:18 -070053``CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1`` and ensure ``LDFLAGS`` points to the
Chris Collis2f27a8b2016-04-23 15:28:23 +010054absolute path for the `OpenSSL`_ libraries before calling pip.
55
56.. tip::
57 You will also need to set these values when `Building documentation`_.
58
Alex Stapletonc5fffd32014-03-18 15:29:00 +000059Running tests
Chris Collis2f27a8b2016-04-23 15:28:23 +010060-------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060061
62``cryptography`` unit tests are found in the ``tests/`` directory and are
63designed to be run using `pytest`_. `pytest`_ will discover the tests
64automatically, so all you have to do is:
65
66.. code-block:: console
67
Ville Skyttä40c6d402018-05-13 16:23:49 +020068 $ pytest
Paul Kehrer450cd022014-02-11 22:46:39 -060069 ...
70 62746 passed in 220.43 seconds
Paul Kehrer0839aa82014-02-11 22:36:51 -060071
72This runs the tests with the default Python interpreter.
73
74You can also verify that the tests pass on other supported Python interpreters.
75For this we use `tox`_, which will automatically create a `virtualenv`_ for
76each supported Python version and run the tests. For example:
77
78.. code-block:: console
79
Paul Kehrer450cd022014-02-11 22:46:39 -060080 $ tox
81 ...
Paul Kehrer450cd022014-02-11 22:46:39 -060082 py27: commands succeeded
83 ERROR: pypy: InterpreterNotFound: pypy
Lucia Lic6ba99d2021-11-08 22:06:11 +080084 py38: commands succeeded
Paul Kehrer450cd022014-02-11 22:46:39 -060085 docs: commands succeeded
86 pep8: commands succeeded
Paul Kehrer0839aa82014-02-11 22:36:51 -060087
88You may not have all the required Python versions installed, in which case you
89will see one or more ``InterpreterNotFound`` errors.
90
91
Alex Stapletonc5fffd32014-03-18 15:29:00 +000092Building documentation
Chris Collis2f27a8b2016-04-23 15:28:23 +010093----------------------
Paul Kehrer0839aa82014-02-11 22:36:51 -060094
95``cryptography`` documentation is stored in the ``docs/`` directory. It is
96written in `reStructured Text`_ and rendered using `Sphinx`_.
97
98Use `tox`_ to build the documentation. For example:
99
100.. code-block:: console
101
Paul Kehrer450cd022014-02-11 22:46:39 -0600102 $ tox -e docs
103 ...
104 docs: commands succeeded
105 congratulations :)
Paul Kehrer0839aa82014-02-11 22:36:51 -0600106
107The HTML documentation index can now be found at
108``docs/_build/html/index.html``.
109
Alex Gaynor5ad6df92017-02-18 12:52:50 -0500110.. _`Homebrew`: https://brew.sh
Chris Collis2f27a8b2016-04-23 15:28:23 +0100111.. _`MacPorts`: https://www.macports.org
Alex Gaynor769d5c62016-11-06 04:30:36 -0500112.. _`OpenSSL`: https://www.openssl.org
Alex Gaynor3414f5c2018-04-15 19:41:11 -0400113.. _`pytest`: https://pypi.org/project/pytest/
114.. _`tox`: https://pypi.org/project/tox/
115.. _`virtualenv`: https://pypi.org/project/virtualenv/
116.. _`pip`: https://pypi.org/project/pip/
117.. _`sphinx`: https://pypi.org/project/Sphinx/
Alex Gaynorebaa5702018-12-30 14:28:48 -0600118.. _`reStructured Text`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
Nick Badger63bbf182016-09-03 10:10:36 -0700119.. _`this Github issue`: https://github.com/rfk/pyenchant/issues/42