blob: 63555abc0e8b8cfbda56f7c7b872f8bc47868100 [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
skeuomorfbc26efb2014-01-29 08:31:47 +020010On Windows
11----------
Alex Gaynor84d5c6b2014-02-02 10:12:34 -080012
skeuomorfb0293bf2014-01-29 21:41:02 +020013If you're on Windows you'll need to make sure you have OpenSSL installed.
14There are `pre-compiled binaries`_ available. If your installation is in
15an unusual location set the ``LIB`` and ``INCLUDE`` environment variables
16to include the corresponding locations. For example:
skeuomorfbc26efb2014-01-29 08:31:47 +020017
skeuomorfb0293bf2014-01-29 21:41:02 +020018.. code-block:: console
19
20 C:\> \path\to\vcvarsall.bat x86_amd64
21 C:\> set LIB=C:\OpenSSL-1.0.1f-64bit\lib;%LIB%
22 C:\> set INCLUDE=C:\OpenSSL-1.0.1f-64bit\include;%INCLUDE%
23 C:\> pip install cryptography
skeuomorfbc26efb2014-01-29 08:31:47 +020024
Chris Glass2e15c7f2014-02-13 19:10:10 +010025Building cryptography on Linux
26------------------------------
Chris Glass87c4edb2014-02-13 09:34:21 +010027
Chris Glass2e15c7f2014-02-13 19:10:10 +010028``cryptography`` should build very easily on Linux provided you have a C
Alex Gaynor49923842014-02-13 10:32:56 -080029compiler, headers for Python (if you're not using ``pypy``), and headers for
30the OpenSSL and ``libffi`` libraries available on your system.
Chris Glass87c4edb2014-02-13 09:34:21 +010031
Ayrxd9702f92014-02-15 23:57:13 +080032For Debian and Ubuntu, the following command will ensure that the required
Chris Glassf82d94f2014-02-13 11:46:49 +010033dependencies are installed:
Chris Glass87c4edb2014-02-13 09:34:21 +010034
35.. code-block:: console
36
Alex Gaynor49923842014-02-13 10:32:56 -080037 $ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Chris Glass87c4edb2014-02-13 09:34:21 +010038
Ayrxd9702f92014-02-15 23:57:13 +080039For Fedora and RHEL-derivatives, the following command will ensure that the
40required dependencies are installed:
Ayrxa674c6b2014-02-15 21:24:23 +080041
42.. code-block:: console
43
44 $ sudo yum install gcc libffi-devel python-devel openssl-devel
45
Chris Glass87c4edb2014-02-13 09:34:21 +010046You should now be able to build and install cryptography with the usual
47
48.. code-block:: console
49
Alex Gaynor49923842014-02-13 10:32:56 -080050 $ pip install cryptography
Chris Glass87c4edb2014-02-13 09:34:21 +010051
Chris Glass2e15c7f2014-02-13 19:10:10 +010052Using your own OpenSSL on Linux
53~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skeuomorfbc26efb2014-01-29 08:31:47 +020054
55Python links to OpenSSL for its own purposes and this can sometimes cause
56problems when you wish to use a different version of OpenSSL with cryptography.
57If you want to use cryptography with your own build of OpenSSL you will need to
58make sure that the build is configured correctly so that your version of
59OpenSSL doesn't conflict with Python's.
60
61The options you need to add allow the linker to identify every symbol correctly
62even when multiple versions of the library are linked into the same program. If
63you are using your distribution's source packages these will probably be
64patched in for you already, otherwise you'll need to use options something like
65this when configuring OpenSSL:
66
67.. code-block:: console
68
69 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
70
71You'll also need to generate your own ``openssl.ld`` file. For example::
72
73 OPENSSL_1.0.1F_CUSTOM {
74 global:
75 *;
76 };
77
78You should replace the version string on the first line as appropriate for your
79build.
80
81Using your own OpenSSL on OS X
82------------------------------
83
84To link cryptography against a custom version of OpenSSL you'll need to set
85``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
86`Homebrew`_:
87
88.. code-block:: console
89
90 $ brew install openssl
91
92Then install cryptography linking against the brewed version:
93
94.. code-block:: console
95
96 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
97
98
99.. _`Homebrew`: http://brew.sh
100.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html