blob: 3be3ae89ef79ea7992620485bed359081213d74f [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
Alex Stapletonbd0c7a62014-03-15 18:08:21 +000013Currently we test ``cryptography`` on Python 2.6, 2.7, 3.2, 3.3 and PyPy on
14these operating systems.
Alex Stapletonb4684172014-03-15 18:02:13 +000015
Alex Stapletonb4684172014-03-15 18:02:13 +000016* x86-64 CentOS 6.4 and CentOS 5
17* x86-64 FreeBSD 9.2 and FreeBSD 10
Paul Kehrer8ec8a862014-04-15 18:01:51 -040018* OS X 10.9, 10.8, and 10.7
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
skeuomorfbc26efb2014-01-29 08:31:47 +020023On Windows
24----------
Alex Gaynor84d5c6b2014-02-02 10:12:34 -080025
skeuomorfb0293bf2014-01-29 21:41:02 +020026If you're on Windows you'll need to make sure you have OpenSSL installed.
27There are `pre-compiled binaries`_ available. If your installation is in
28an unusual location set the ``LIB`` and ``INCLUDE`` environment variables
29to include the corresponding locations. For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020030
skeuomorfb0293bf2014-01-29 21:41:02 +020031.. code-block:: console
32
33 C:\> \path\to\vcvarsall.bat x86_amd64
Paul Kehrer8ec8a862014-04-15 18:01:51 -040034 C:\> set LIB=C:\OpenSSL-1.0.1g-64bit\lib;%LIB%
35 C:\> set INCLUDE=C:\OpenSSL-1.0.1g-64bit\include;%INCLUDE%
skeuomorfb0293bf2014-01-29 21:41:02 +020036 C:\> pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +020037
Chris Glass2e15c7f2014-02-13 19:10:10 +010038Building cryptography on Linux
39------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010040
Chris Glass2e15c7f2014-02-13 19:10:10 +010041``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080042compiler, headers for Python (if you're not using ``pypy``), and headers for
43the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010044
Ayrxd9702f92014-02-15 23:57:13 +080045For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010046dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010047
48.. code-block:: console
49
Alex Gaynor49923842014-02-13 10:32:56 -080050 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010051
Ayrxd9702f92014-02-15 23:57:13 +080052For Fedora and RHEL-derivatives, the following command will ensure that the
53required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080054
55.. code-block:: console
56
57 $ sudo yum install gcc libffi-devel python-devel openssl-devel
58
Chris Glass87c4edb2014-02-13 09:34:21 +010059You should now be able to build and install cryptography with the usual
60
61.. code-block:: console
62
Alex Gaynor49923842014-02-13 10:32:56 -080063 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010064
Chris Glass2e15c7f2014-02-13 19:10:10 +010065Using your own OpenSSL on Linux
66~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +020067
68Python links to OpenSSL for its own purposes and this can sometimes cause
69problems when you wish to use a different version of OpenSSL with cryptography.
70If you want to use cryptography with your own build of OpenSSL you will need to
71make sure that the build is configured correctly so that your version of
72OpenSSL doesn't conflict with Python's.
73
74The options you need to add allow the linker to identify every symbol correctly
75even when multiple versions of the library are linked into the same program. If
76you are using your distribution's source packages these will probably be
77patched in for you already, otherwise you'll need to use options something like
78this when configuring OpenSSL:
79
80.. code-block:: console
81
82 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
83
84You'll also need to generate your own ``openssl.ld`` file. For example::
85
86 OPENSSL_1.0.1F_CUSTOM {
87 global:
88 *;
89 };
90
91You should replace the version string on the first line as appropriate for your
92build.
93
94Using your own OpenSSL on OS X
95------------------------------
96
97To link cryptography against a custom version of OpenSSL you'll need to set
Ayrx1ced5b82014-04-08 19:41:26 +080098``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via `Homebrew`_ or `MacPorts`_:
99
100`Homebrew`_
skeuomorfbc26efb2014-01-29 08:31:47 +0200101
102.. code-block:: console
103
104 $ brew install openssl
Ayrx1ced5b82014-04-08 19:41:26 +0800105 $ 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 +0200106
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200107or `MacPorts`_:
108
109.. code-block:: console
110
111 $ sudo port install openssl
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200112 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +0200113
114.. _`Homebrew`: http://brew.sh
Kimmo Parviainen-Jalankoe01e0bf2014-03-19 18:57:09 +0200115.. _`MacPorts`: http://www.macports.org
skeuomorfbc26efb2014-01-29 08:31:47 +0200116.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html