blob: 8fbbcb3076d74025d21c0432fc3d3aab9a69a234 [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 Kehrerfb8dcdb2014-04-20 19:25:18 -050016* x86-64 CentOS 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 Kehrerfb8dcdb2014-04-20 19:25:18 -050028* ``OpenSSL 0.9.8y``
29* ``OpenSSL 1.0.0-fips`` (``RHEL/CentOS 6.4``)
30* ``OpenSSL 1.0.1``
31* ``OpenSSL 1.0.1e-freebsd``
32* ``OpenSSL 1.0.1g``
33* ``OpenSSL 1.0.2 beta``
34
skeuomorfbc26efb2014-01-29 08:31:47 +020035On Windows
36----------
Alex Gaynor84d5c6b2014-02-02 10:12:34 -080037
skeuomorfb0293bf2014-01-29 21:41:02 +020038If you're on Windows you'll need to make sure you have OpenSSL installed.
39There are `pre-compiled binaries`_ available. If your installation is in
40an unusual location set the ``LIB`` and ``INCLUDE`` environment variables
41to include the corresponding locations. For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020042
skeuomorfb0293bf2014-01-29 21:41:02 +020043.. code-block:: console
44
45 C:\> \path\to\vcvarsall.bat x86_amd64
Paul Kehrer8ec8a862014-04-15 18:01:51 -040046 C:\> set LIB=C:\OpenSSL-1.0.1g-64bit\lib;%LIB%
47 C:\> set INCLUDE=C:\OpenSSL-1.0.1g-64bit\include;%INCLUDE%
skeuomorfb0293bf2014-01-29 21:41:02 +020048 C:\> pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +020049
Chris Glass2e15c7f2014-02-13 19:10:10 +010050Building cryptography on Linux
51------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010052
Chris Glass2e15c7f2014-02-13 19:10:10 +010053``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080054compiler, headers for Python (if you're not using ``pypy``), and headers for
55the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010056
Ayrxd9702f92014-02-15 23:57:13 +080057For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010058dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010059
60.. code-block:: console
61
Alex Gaynor49923842014-02-13 10:32:56 -080062 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010063
Ayrxd9702f92014-02-15 23:57:13 +080064For Fedora and RHEL-derivatives, the following command will ensure that the
65required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080066
67.. code-block:: console
68
69 $ sudo yum install gcc libffi-devel python-devel openssl-devel
70
Chris Glass87c4edb2014-02-13 09:34:21 +010071You should now be able to build and install cryptography with the usual
72
73.. code-block:: console
74
Alex Gaynor49923842014-02-13 10:32:56 -080075 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010076
Alex Gaynoreb50a2c2014-05-02 09:38:33 -070077
Chris Glass2e15c7f2014-02-13 19:10:10 +010078Using your own OpenSSL on Linux
79~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +020080
81Python links to OpenSSL for its own purposes and this can sometimes cause
82problems when you wish to use a different version of OpenSSL with cryptography.
83If you want to use cryptography with your own build of OpenSSL you will need to
84make sure that the build is configured correctly so that your version of
85OpenSSL doesn't conflict with Python's.
86
87The options you need to add allow the linker to identify every symbol correctly
88even when multiple versions of the library are linked into the same program. If
89you are using your distribution's source packages these will probably be
90patched in for you already, otherwise you'll need to use options something like
91this when configuring OpenSSL:
92
93.. code-block:: console
94
95 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
96
97You'll also need to generate your own ``openssl.ld`` file. For example::
98
99 OPENSSL_1.0.1F_CUSTOM {
100 global:
101 *;
102 };
103
104You should replace the version string on the first line as appropriate for your
105build.
106
107Using your own OpenSSL on OS X
108------------------------------
109
110To link cryptography against a custom version of OpenSSL you'll need to set
Alex Gaynorf2441502014-05-17 20:09:33 -0700111``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
112`Homebrew`_ or `MacPorts`_:
Ayrx1ced5b82014-04-08 19:41:26 +0800113
114`Homebrew`_
skeuomorfbc26efb2014-01-29 08:31:47 +0200115
116.. code-block:: console
117
118 $ brew install openssl
Ayrx1ced5b82014-04-08 19:41:26 +0800119 $ 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 +0200120
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200121or `MacPorts`_:
122
123.. code-block:: console
124
125 $ sudo port install openssl
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200126 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200127
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700128Building cryptography with conda
129--------------------------------
130
Alex Gaynord6948382014-05-02 14:10:14 -0700131Because of a `bug in conda`_, attempting to install cryptography out of the box
David Reide162e262014-05-07 16:21:00 -0700132will result in an error. This can be resolved by setting the library path
133environment variable for your platform.
David Reide43861d2014-05-07 16:19:08 -0700134
135On OS X:
Alex Gaynord8fc2572014-05-02 10:33:36 -0700136
137.. code-block:: console
138
139 $ env DYLD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
140
David Reid18563e62014-05-07 16:20:09 -0700141and on Linux:
David Reide43861d2014-05-07 16:19:08 -0700142
143.. code-block:: console
144
145 $ env LD_LIBRARY_PATH="$HOME/anaconda/lib" pip install cryptography
146
Alex Gaynord8fc2572014-05-02 10:33:36 -0700147You will need to set this variable every time you start Python. For more
Alex Gaynorf65cba22014-05-02 10:40:57 -0700148information, consult `Greg Wilson's blog post`_ on the subject.
Alex Gaynoreb50a2c2014-05-02 09:38:33 -0700149
150
skeuomorfbc26efb2014-01-29 08:31:47 +0200151.. _`Homebrew`: http://brew.sh
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200152.. _`MacPorts`: http://www.macports.org
skeuomorfbc26efb2014-01-29 08:31:47 +0200153.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html
Alex Gaynord6948382014-05-02 14:10:14 -0700154.. _`bug in conda`: https://github.com/conda/conda-recipes/issues/110
Alex Gaynord8fc2572014-05-02 10:33:36 -0700155.. _`Greg Wilson's blog post`: http://software-carpentry.org/blog/2014/04/mr-biczo-was-right.html