blob: f7a88b9852cf3ce9a69b576df7647418ccb0762c [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 Kehrer09586412015-04-18 20:26:03 -050013Currently we test ``cryptography`` on Python 2.6, 2.7, 3.3, 3.4 and PyPy
Paul Kehrerfb8dcdb2014-04-20 19:25:18 -050014on 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.
Paul Kehrer6608b7e2015-07-24 21:52:17 +010048You can compile OpenSSL yourself as well or use the binaries we build for our
49release infrastructure (`32-bit`_ and `64-bit`_). Wherever you place your copy
50of OpenSSL you'll need to set the ``LIB`` and ``INCLUDE`` environment variables
51to include the proper locations. For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020052
skeuomorfb0293bf2014-01-29 21:41:02 +020053.. code-block:: console
54
55 C:\> \path\to\vcvarsall.bat x86_amd64
Paul Kehrer6608b7e2015-07-24 21:52:17 +010056 C:\> set LIB=C:\OpenSSL-win64\lib;%LIB%
57 C:\> set INCLUDE=C:\OpenSSL-win64\include;%INCLUDE%
Paul Kehrer2a39f7f2014-07-02 22:56:01 -050058 C:\> pip install cryptography
59
skeuomorfbc26efb2014-01-29 08:31:47 +020060
Chris Glass2e15c7f2014-02-13 19:10:10 +010061Building cryptography on Linux
62------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010063
Chris Glass2e15c7f2014-02-13 19:10:10 +010064``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080065compiler, headers for Python (if you're not using ``pypy``), and headers for
66the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010067
Ayrxd9702f92014-02-15 23:57:13 +080068For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010069dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010070
71.. code-block:: console
72
Alex Gaynor49923842014-02-13 10:32:56 -080073 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010074
Ayrxd9702f92014-02-15 23:57:13 +080075For Fedora and RHEL-derivatives, the following command will ensure that the
76required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080077
78.. code-block:: console
79
80 $ sudo yum install gcc libffi-devel python-devel openssl-devel
81
Chris Glass87c4edb2014-02-13 09:34:21 +010082You should now be able to build and install cryptography with the usual
83
84.. code-block:: console
85
Alex Gaynor49923842014-02-13 10:32:56 -080086 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010087
Alex Gaynoreb50a2c2014-05-02 09:38:33 -070088
Chris Glass2e15c7f2014-02-13 19:10:10 +010089Using your own OpenSSL on Linux
90~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +020091
92Python links to OpenSSL for its own purposes and this can sometimes cause
93problems when you wish to use a different version of OpenSSL with cryptography.
94If you want to use cryptography with your own build of OpenSSL you will need to
95make sure that the build is configured correctly so that your version of
96OpenSSL doesn't conflict with Python's.
97
98The options you need to add allow the linker to identify every symbol correctly
99even when multiple versions of the library are linked into the same program. If
100you are using your distribution's source packages these will probably be
101patched in for you already, otherwise you'll need to use options something like
102this when configuring OpenSSL:
103
104.. code-block:: console
105
106 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
107
108You'll also need to generate your own ``openssl.ld`` file. For example::
109
110 OPENSSL_1.0.1F_CUSTOM {
111 global:
112 *;
113 };
114
115You should replace the version string on the first line as appropriate for your
116build.
117
Paul Kehrer451c8df2015-07-04 11:03:27 -0500118Building cryptography on OS X
119-----------------------------
120
Paul Kehrer47e1b602015-07-04 11:21:52 -0500121Building cryptography requires the presence of a C compiler and development
122headers. On OS X this is typically provided by Apple's Xcode development tools.
123To install the Xcode command line tools on open a terminal window and run:
Paul Kehrer451c8df2015-07-04 11:03:27 -0500124
125.. code-block:: console
126
127 $ xcode-select --install
128
129This will install a compiler (clang) along with the required development
130headers. If you wish to compile against a more recent OpenSSL than the
131version shipped with OS X see the next section.
132
skeuomorfbc26efb2014-01-29 08:31:47 +0200133Using your own OpenSSL on OS X
Paul Kehrer451c8df2015-07-04 11:03:27 -0500134~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +0200135
136To link cryptography against a custom version of OpenSSL you'll need to set
Alex Gaynorf2441502014-05-17 20:09:33 -0700137``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
138`Homebrew`_ or `MacPorts`_:
Ayrx1ced5b82014-04-08 19:41:26 +0800139
140`Homebrew`_
skeuomorfbc26efb2014-01-29 08:31:47 +0200141
142.. code-block:: console
143
144 $ brew install openssl
tim smith91596e22015-08-03 07:59:21 -0700145 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200146
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200147or `MacPorts`_:
148
149.. code-block:: console
150
151 $ sudo port install openssl
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200152 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200153
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700154Building cryptography with conda
155--------------------------------
156
Alex Gaynord6948382014-05-02 14:10:14 -0700157Because of a `bug in conda`_, attempting to install cryptography out of the box
David Reide162e262014-05-07 16:21:00 -0700158will result in an error. This can be resolved by setting the library path
159environment variable for your platform.
David Reide43861d2014-05-07 16:19:08 -0700160
161On OS X:
Alex Gaynord8fc2572014-05-02 10:33:36 -0700162
163.. code-block:: console
164
165 $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
166
David Reid18563e62014-05-07 16:20:09 -0700167and on Linux:
David Reide43861d2014-05-07 16:19:08 -0700168
169.. code-block:: console
170
171 $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
172
Alex Gaynord8fc2572014-05-02 10:33:36 -0700173You will need to set this variable every time you start Python. For more
Alex Gaynorf65cba22014-05-02 10:40:57 -0700174information, consult `Greg Wilson's blog post`_ on the subject.
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700175
176
skeuomorfbc26efb2014-01-29 08:31:47 +0200177.. _`Homebrew`: http://brew.sh
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200178.. _`MacPorts`: http://www.macports.org
Paul Kehrer6608b7e2015-07-24 21:52:17 +0100179.. _`32-bit`: https://jenkins.cryptography.io/job/openssl-win32-release/
180.. _`64-bit`: https://jenkins.cryptography.io/job/openssl-win64-release/
Alex Gaynord6948382014-05-02 14:10:14 -0700181.. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110
Alex Gaynord8fc2572014-05-02 10:33:36 -0700182.. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html