blob: c061903e7a7f29a665bf7c2537e69267216b7973 [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
Paul Kehrerbd88ee62015-02-20 10:38:31 -060017* x86-64 FreeBSD 10
Paul Kehrercebb31a2014-11-26 10:09:19 -100018* OS X 10.10 Yosemite, 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
Paul Kehrer698e8062014-12-28 15:01:54 -070020* x86-64 Debian Wheezy (7.x) and Jessie (8.x)
Alex Stapleton13432b22014-03-15 19:18:16 +000021* 32-bit Python on 64-bit Windows Server 2008
Paul Kehrer8ec8a862014-04-15 18:01:51 -040022* 64-bit Python on 64-bit Windows Server 2012
Alex Stapletonb4684172014-03-15 18:02:13 +000023
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050024We test compiling with ``clang`` as well as ``gcc`` and use the following
25OpenSSL releases:
26
27* ``OpenSSL 0.9.8e-fips-rhel5`` (``RHEL/CentOS 5``)
Alex Stapleton2c688a42014-05-04 15:22:29 +010028* ``OpenSSL 0.9.8k``
Paul Kehrera5a432a2014-10-15 23:47:19 -050029* ``OpenSSL 0.9.8za``
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050030* ``OpenSSL 1.0.0-fips`` (``RHEL/CentOS 6.4``)
31* ``OpenSSL 1.0.1``
Paul Kehrere683dee2014-08-09 08:15:23 -100032* ``OpenSSL 1.0.1e-fips`` (``RHEL/CentOS 7``)
Paul Kehrer96a08272015-02-21 18:37:38 -060033* ``OpenSSL 1.0.1j-freebsd``
Paul Kehrera5a432a2014-10-15 23:47:19 -050034* ``OpenSSL 1.0.1-latest`` (The most recent 1.0.1 release)
Paul Kehrer49945972015-01-22 20:59:19 -060035* ``OpenSSL 1.0.2``
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050036
skeuomorfbc26efb2014-01-29 08:31:47 +020037On Windows
38----------
Alex Gaynor84d5c6b2014-02-02 10:12:34 -080039
Paul Kehrer156360a2014-06-30 12:14:01 -060040The wheel package on Windows is a statically linked build (as of 0.5) so all
41dependencies are included. Just run
42
43.. code-block:: console
44
45 $ pip install cryptography
46
47If you prefer to compile it yourself you'll need to have OpenSSL installed.
48There are `pre-compiled binaries`_ available. If your installation is in an
49unusual location set the ``LIB`` and ``INCLUDE`` environment variables to
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050050include the corresponding locations.For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020051
skeuomorfb0293bf2014-01-29 21:41:02 +020052.. code-block:: console
53
54 C:\> \path\to\vcvarsall.bat x86_amd64
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050055 C:\> set LIB=C:\OpenSSL\lib\VC\static;C:\OpenSSL\lib;%LIB%
56 C:\> set INCLUDE=C:\OpenSSL\include;%INCLUDE%
57 C:\> pip install cryptography
58
59You can also choose to build statically or dynamically using the
Paul Kehrer419e67a2014-07-05 11:15:55 -050060``PYCA_WINDOWS_LINK_TYPE`` variable. Allowed values are ``static`` (default)
61and ``dynamic``.
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050062
63.. code-block:: console
64
65 C:\> \path\to\vcvarsall.bat x86_amd64
66 C:\> set LIB=C:\OpenSSL\lib\VC\static;C:\OpenSSL\lib;%LIB%
67 C:\> set INCLUDE=C:\OpenSSL\include;%INCLUDE%
Paul Kehrer419e67a2014-07-05 11:15:55 -050068 C:\> set PYCA_WINDOWS_LINK_TYPE=dynamic
skeuomorfb0293bf2014-01-29 21:41:02 +020069 C:\> pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +020070
Chris Glass2e15c7f2014-02-13 19:10:10 +010071Building cryptography on Linux
72------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010073
Chris Glass2e15c7f2014-02-13 19:10:10 +010074``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080075compiler, headers for Python (if you're not using ``pypy``), and headers for
76the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010077
Ayrxd9702f92014-02-15 23:57:13 +080078For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010079dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010080
81.. code-block:: console
82
Alex Gaynor49923842014-02-13 10:32:56 -080083 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010084
Ayrxd9702f92014-02-15 23:57:13 +080085For Fedora and RHEL-derivatives, the following command will ensure that the
86required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080087
88.. code-block:: console
89
90 $ sudo yum install gcc libffi-devel python-devel openssl-devel
91
Chris Glass87c4edb2014-02-13 09:34:21 +010092You should now be able to build and install cryptography with the usual
93
94.. code-block:: console
95
Alex Gaynor49923842014-02-13 10:32:56 -080096 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010097
Alex Gaynoreb50a2c2014-05-02 09:38:33 -070098
Chris Glass2e15c7f2014-02-13 19:10:10 +010099Using your own OpenSSL on Linux
100~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +0200101
102Python links to OpenSSL for its own purposes and this can sometimes cause
103problems when you wish to use a different version of OpenSSL with cryptography.
104If you want to use cryptography with your own build of OpenSSL you will need to
105make sure that the build is configured correctly so that your version of
106OpenSSL doesn't conflict with Python's.
107
108The options you need to add allow the linker to identify every symbol correctly
109even when multiple versions of the library are linked into the same program. If
110you are using your distribution's source packages these will probably be
111patched in for you already, otherwise you'll need to use options something like
112this when configuring OpenSSL:
113
114.. code-block:: console
115
116 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
117
118You'll also need to generate your own ``openssl.ld`` file. For example::
119
120 OPENSSL_1.0.1F_CUSTOM {
121 global:
122 *;
123 };
124
125You should replace the version string on the first line as appropriate for your
126build.
127
128Using your own OpenSSL on OS X
129------------------------------
130
131To link cryptography against a custom version of OpenSSL you'll need to set
Alex Gaynorf2441502014-05-17 20:09:33 -0700132``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
133`Homebrew`_ or `MacPorts`_:
Ayrx1ced5b82014-04-08 19:41:26 +0800134
135`Homebrew`_
skeuomorfbc26efb2014-01-29 08:31:47 +0200136
137.. code-block:: console
138
139 $ brew install openssl
Ayrx1ced5b82014-04-08 19:41:26 +0800140 $ 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 +0200141
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200142or `MacPorts`_:
143
144.. code-block:: console
145
146 $ sudo port install openssl
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200147 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200148
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700149Building cryptography with conda
150--------------------------------
151
Alex Gaynord6948382014-05-02 14:10:14 -0700152Because of a `bug in conda`_, attempting to install cryptography out of the box
David Reide162e262014-05-07 16:21:00 -0700153will result in an error. This can be resolved by setting the library path
154environment variable for your platform.
David Reide43861d2014-05-07 16:19:08 -0700155
156On OS X:
Alex Gaynord8fc2572014-05-02 10:33:36 -0700157
158.. code-block:: console
159
160 $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
161
David Reid18563e62014-05-07 16:20:09 -0700162and on Linux:
David Reide43861d2014-05-07 16:19:08 -0700163
164.. code-block:: console
165
166 $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
167
Alex Gaynord8fc2572014-05-02 10:33:36 -0700168You will need to set this variable every time you start Python. For more
Alex Gaynorf65cba22014-05-02 10:40:57 -0700169information, consult `Greg Wilson's blog post`_ on the subject.
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700170
171
skeuomorfbc26efb2014-01-29 08:31:47 +0200172.. _`Homebrew`: http://brew.sh
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200173.. _`MacPorts`: http://www.macports.org
skeuomorfbc26efb2014-01-29 08:31:47 +0200174.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html
Alex Gaynord6948382014-05-02 14:10:14 -0700175.. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110
Alex Gaynord8fc2572014-05-02 10:33:36 -0700176.. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html