blob: d1b6e69d20f0625102aa95d9c0af9f0b269c15e4 [file] [log] [blame]
Alex Gaynor84d5c6b2014-02-02 10:12:34 -08001Installation
2============
skeuomorfbc26efb2014-01-29 08:31:47 +02003
4You can install ``cryptography`` with ``pip``:
5
6.. code-block:: console
7
8 $ pip install cryptography
9
Alex Stapletonb4684172014-03-15 18:02:13 +000010Supported platforms
11-------------------
12
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050013Currently we test ``cryptography`` on Python 2.6, 2.7, 3.2, 3.3, 3.4 and PyPy
14on these operating systems.
Alex Stapletonb4684172014-03-15 18:02:13 +000015
Paul Kehrer73667de2014-07-14 12:33:27 -050016* x86-64 CentOS 7.x, 6.4 and CentOS 5.x
Alex Stapletonb4684172014-03-15 18:02:13 +000017* x86-64 FreeBSD 9.2 and FreeBSD 10
Paul Kehrerc354a2b2014-04-15 18:34:27 -040018* OS X 10.9 Mavericks, 10.8 Mountain Lion, and 10.7 Lion
Alex Stapletonb10e9542014-03-15 18:09:33 +000019* x86-64 Ubuntu 12.04 LTS
Alex Stapleton13432b22014-03-15 19:18:16 +000020* 32-bit Python on 64-bit Windows Server 2008
Paul Kehrer8ec8a862014-04-15 18:01:51 -040021* 64-bit Python on 64-bit Windows Server 2012
Alex Stapletonb4684172014-03-15 18:02:13 +000022
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050023We test compiling with ``clang`` as well as ``gcc`` and use the following
24OpenSSL releases:
25
26* ``OpenSSL 0.9.8e-fips-rhel5`` (``RHEL/CentOS 5``)
Alex Stapleton2c688a42014-05-04 15:22:29 +010027* ``OpenSSL 0.9.8k``
Paul Kehrera5a432a2014-10-15 23:47:19 -050028* ``OpenSSL 0.9.8za``
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050029* ``OpenSSL 1.0.0-fips`` (``RHEL/CentOS 6.4``)
30* ``OpenSSL 1.0.1``
Paul Kehrere683dee2014-08-09 08:15:23 -100031* ``OpenSSL 1.0.1e-fips`` (``RHEL/CentOS 7``)
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050032* ``OpenSSL 1.0.1e-freebsd``
Paul Kehrera5a432a2014-10-15 23:47:19 -050033* ``OpenSSL 1.0.1-latest`` (The most recent 1.0.1 release)
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050034* ``OpenSSL 1.0.2 beta``
35
skeuomorfbc26efb2014-01-29 08:31:47 +020036On Windows
37----------
Alex Gaynor84d5c6b2014-02-02 10:12:34 -080038
Paul Kehrer156360a2014-06-30 12:14:01 -060039The wheel package on Windows is a statically linked build (as of 0.5) so all
40dependencies are included. Just run
41
42.. code-block:: console
43
44 $ pip install cryptography
45
46If you prefer to compile it yourself you'll need to have OpenSSL installed.
47There are `pre-compiled binaries`_ available. If your installation is in an
48unusual location set the ``LIB`` and ``INCLUDE`` environment variables to
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050049include the corresponding locations.For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020050
skeuomorfb0293bf2014-01-29 21:41:02 +020051.. code-block:: console
52
53 C:\> \path\to\vcvarsall.bat x86_amd64
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050054 C:\> set LIB=C:\OpenSSL\lib\VC\static;C:\OpenSSL\lib;%LIB%
55 C:\> set INCLUDE=C:\OpenSSL\include;%INCLUDE%
56 C:\> pip install cryptography
57
58You can also choose to build statically or dynamically using the
Paul Kehrer419e67a2014-07-05 11:15:55 -050059``PYCA_WINDOWS_LINK_TYPE`` variable. Allowed values are ``static`` (default)
60and ``dynamic``.
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050061
62.. code-block:: console
63
64 C:\> \path\to\vcvarsall.bat x86_amd64
65 C:\> set LIB=C:\OpenSSL\lib\VC\static;C:\OpenSSL\lib;%LIB%
66 C:\> set INCLUDE=C:\OpenSSL\include;%INCLUDE%
Paul Kehrer419e67a2014-07-05 11:15:55 -050067 C:\> set PYCA_WINDOWS_LINK_TYPE=dynamic
skeuomorfb0293bf2014-01-29 21:41:02 +020068 C:\> pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +020069
Chris Glass2e15c7f2014-02-13 19:10:10 +010070Building cryptography on Linux
71------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010072
Chris Glass2e15c7f2014-02-13 19:10:10 +010073``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080074compiler, headers for Python (if you're not using ``pypy``), and headers for
75the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010076
Ayrxd9702f92014-02-15 23:57:13 +080077For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010078dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010079
80.. code-block:: console
81
Alex Gaynor49923842014-02-13 10:32:56 -080082 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010083
Ayrxd9702f92014-02-15 23:57:13 +080084For Fedora and RHEL-derivatives, the following command will ensure that the
85required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080086
87.. code-block:: console
88
89 $ sudo yum install gcc libffi-devel python-devel openssl-devel
90
Chris Glass87c4edb2014-02-13 09:34:21 +010091You should now be able to build and install cryptography with the usual
92
93.. code-block:: console
94
Alex Gaynor49923842014-02-13 10:32:56 -080095 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010096
Alex Gaynoreb50a2c2014-05-02 09:38:33 -070097
Chris Glass2e15c7f2014-02-13 19:10:10 +010098Using your own OpenSSL on Linux
99~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +0200100
101Python links to OpenSSL for its own purposes and this can sometimes cause
102problems when you wish to use a different version of OpenSSL with cryptography.
103If you want to use cryptography with your own build of OpenSSL you will need to
104make sure that the build is configured correctly so that your version of
105OpenSSL doesn't conflict with Python's.
106
107The options you need to add allow the linker to identify every symbol correctly
108even when multiple versions of the library are linked into the same program. If
109you are using your distribution's source packages these will probably be
110patched in for you already, otherwise you'll need to use options something like
111this when configuring OpenSSL:
112
113.. code-block:: console
114
115 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
116
117You'll also need to generate your own ``openssl.ld`` file. For example::
118
119 OPENSSL_1.0.1F_CUSTOM {
120 global:
121 *;
122 };
123
124You should replace the version string on the first line as appropriate for your
125build.
126
127Using your own OpenSSL on OS X
128------------------------------
129
130To link cryptography against a custom version of OpenSSL you'll need to set
Alex Gaynorf2441502014-05-17 20:09:33 -0700131``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
132`Homebrew`_ or `MacPorts`_:
Ayrx1ced5b82014-04-08 19:41:26 +0800133
134`Homebrew`_
skeuomorfbc26efb2014-01-29 08:31:47 +0200135
136.. code-block:: console
137
138 $ brew install openssl
Ayrx1ced5b82014-04-08 19:41:26 +0800139 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200140
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200141or `MacPorts`_:
142
143.. code-block:: console
144
145 $ sudo port install openssl
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200146 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200147
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700148Building cryptography with conda
149--------------------------------
150
Alex Gaynord6948382014-05-02 14:10:14 -0700151Because of a `bug in conda`_, attempting to install cryptography out of the box
David Reide162e262014-05-07 16:21:00 -0700152will result in an error. This can be resolved by setting the library path
153environment variable for your platform.
David Reide43861d2014-05-07 16:19:08 -0700154
155On OS X:
Alex Gaynord8fc2572014-05-02 10:33:36 -0700156
157.. code-block:: console
158
159 $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
160
David Reid18563e62014-05-07 16:20:09 -0700161and on Linux:
David Reide43861d2014-05-07 16:19:08 -0700162
163.. code-block:: console
164
165 $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
166
Alex Gaynord8fc2572014-05-02 10:33:36 -0700167You will need to set this variable every time you start Python. For more
Alex Gaynorf65cba22014-05-02 10:40:57 -0700168information, consult `Greg Wilson's blog post`_ on the subject.
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700169
170
skeuomorfbc26efb2014-01-29 08:31:47 +0200171.. _`Homebrew`: http://brew.sh
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200172.. _`MacPorts`: http://www.macports.org
skeuomorfbc26efb2014-01-29 08:31:47 +0200173.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html
Alex Gaynord6948382014-05-02 14:10:14 -0700174.. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110
Alex Gaynord8fc2572014-05-02 10:33:36 -0700175.. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html