blob: a2fc5b7c79a32a76a60ed706db96bb20e5d592a1 [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 Glass87c4edb2014-02-13 09:34:21 +010025Building cryptography on Linux
26------------------------------
27
28``cryptography`` should build very easily on linux provided you have headers
29for the OpenSSL and libffi available on your system.
30
31For Ubuntu, the following command line will ensure this is the case:
32
33.. code-block:: console
34
35 sudo apt-get install libssl-dev libffi-dev
36
37You should now be able to build and install cryptography with the usual
38
39.. code-block:: console
40
41 python setup.py install
42
skeuomorfbc26efb2014-01-29 08:31:47 +020043Using your own OpenSSL on Linux
Chris Glass87c4edb2014-02-13 09:34:21 +010044...............................
skeuomorfbc26efb2014-01-29 08:31:47 +020045
46Python links to OpenSSL for its own purposes and this can sometimes cause
47problems when you wish to use a different version of OpenSSL with cryptography.
48If you want to use cryptography with your own build of OpenSSL you will need to
49make sure that the build is configured correctly so that your version of
50OpenSSL doesn't conflict with Python's.
51
52The options you need to add allow the linker to identify every symbol correctly
53even when multiple versions of the library are linked into the same program. If
54you are using your distribution's source packages these will probably be
55patched in for you already, otherwise you'll need to use options something like
56this when configuring OpenSSL:
57
58.. code-block:: console
59
60 $ ./config -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared
61
62You'll also need to generate your own ``openssl.ld`` file. For example::
63
64 OPENSSL_1.0.1F_CUSTOM {
65 global:
66 *;
67 };
68
69You should replace the version string on the first line as appropriate for your
70build.
71
72Using your own OpenSSL on OS X
73------------------------------
74
75To link cryptography against a custom version of OpenSSL you'll need to set
76``ARCHFLAGS``, ``LDFLAGS``, and ``CFLAGS``. OpenSSL can be installed via
77`Homebrew`_:
78
79.. code-block:: console
80
81 $ brew install openssl
82
83Then install cryptography linking against the brewed version:
84
85.. code-block:: console
86
87 $ env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography
88
89
90.. _`Homebrew`: http://brew.sh
91.. _`pre-compiled binaries`: https://www.openssl.org/related/binaries.html