blob: dd94a98ffb90a54030a4941ca16b4f8ea434d551 [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
16* x86-64 Ubuntu 12.04 LTS
17* x86-64 CentOS 6.4 and CentOS 5
18* x86-64 FreeBSD 9.2 and FreeBSD 10
19* OS X 10.9 and OS X 10.8.5
20* 64-bit Windows Server 2008
21
skeuomorfbc26efb2014-01-29 08:31:47 +020022On Windows
23----------
Alex Gaynor84d5c6b2014-02-02 10:12:34 -080024
skeuomorfb0293bf2014-01-29 21:41:02 +020025If you're on Windows you'll need to make sure you have OpenSSL installed.
26There are `pre-compiled binaries`_ available. If your installation is in
27an unusual location set the ``LIB`` and ``INCLUDE`` environment variables
28to include the corresponding locations. For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020029
skeuomorfb0293bf2014-01-29 21:41:02 +020030.. code-block:: console
31
32 C:\> \path\to\vcvarsall.bat x86_amd64
33 C:\> set LIB=C:\OpenSSL-1.0.1f-64bit\lib;%LIB%
34 C:\> set INCLUDE=C:\OpenSSL-1.0.1f-64bit\include;%INCLUDE%
35 C:\> pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +020036
Chris Glass2e15c7f2014-02-13 19:10:10 +010037Building cryptography on Linux
38------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010039
Chris Glass2e15c7f2014-02-13 19:10:10 +010040``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080041compiler, headers for Python (if you're not using ``pypy``), and headers for
42the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010043
Ayrxd9702f92014-02-15 23:57:13 +080044For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010045dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010046
47.. code-block:: console
48
Alex Gaynor49923842014-02-13 10:32:56 -080049 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010050
Ayrxd9702f92014-02-15 23:57:13 +080051For Fedora and RHEL-derivatives, the following command will ensure that the
52required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080053
54.. code-block:: console
55
56 $ sudo yum install gcc libffi-devel python-devel openssl-devel
57
Chris Glass87c4edb2014-02-13 09:34:21 +010058You should now be able to build and install cryptography with the usual
59
60.. code-block:: console
61
Alex Gaynor49923842014-02-13 10:32:56 -080062 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010063
Chris Glass2e15c7f2014-02-13 19:10:10 +010064Using your own OpenSSL on Linux
65~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +020066
67Python links to OpenSSL for its own purposes and this can sometimes cause
68problems when you wish to use a different version of OpenSSL with cryptography.
69If you want to use cryptography with your own build of OpenSSL you will need to
70make sure that the build is configured correctly so that your version of
71OpenSSL doesn't conflict with Python's.
72
73The options you need to add allow the linker to identify every symbol correctly
74even when multiple versions of the library are linked into the same program. If
75you are using your distribution's source packages these will probably be
76patched in for you already, otherwise you'll need to use options something like
77this when configuring OpenSSL:
78
79.. code-block:: console
80
81 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
82
83You'll also need to generate your own ``openssl.ld`` file. For example::
84
85 OPENSSL_1.0.1F_CUSTOM {
86 global:
87 *;
88 };
89
90You should replace the version string on the first line as appropriate for your
91build.
92
93Using your own OpenSSL on OS X
94------------------------------
95
96To link cryptography against a custom version of OpenSSL you'll need to set
97``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
98`Homebrew`_:
99
100.. code-block:: console
101
102 $ brew install openssl
103
104Then install cryptography linking against the brewed version:
105
106.. code-block:: console
107
108 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
109
110
111.. _`Homebrew`: http://brew.sh
112.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html